diff --git a/build.gradle.kts b/build.gradle.kts index b5bdb83..598fd6a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -64,12 +64,6 @@ tasks.test { jvmArgs = listOf("-XX:+UnlockDiagnosticVMOptions", "-XX:+ShowHiddenFrames") } -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} - configure { val j = Contact("sghill.dev@gmail.com") j.moniker("Steve Hill") diff --git a/src/main/java/net/sghill/jenkins/rewrite/UpgradeVersionProperty.java b/src/main/java/org/openrewrite/jenkins/UpgradeVersionProperty.java similarity index 95% rename from src/main/java/net/sghill/jenkins/rewrite/UpgradeVersionProperty.java rename to src/main/java/org/openrewrite/jenkins/UpgradeVersionProperty.java index 3f7b2cf..7ce2bc8 100644 --- a/src/main/java/net/sghill/jenkins/rewrite/UpgradeVersionProperty.java +++ b/src/main/java/org/openrewrite/jenkins/UpgradeVersionProperty.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package net.sghill.jenkins.rewrite; +package org.openrewrite.jenkins; import lombok.EqualsAndHashCode; import lombok.Value; @@ -22,9 +22,7 @@ import org.openrewrite.Preconditions; import org.openrewrite.Recipe; import org.openrewrite.TreeVisitor; -import org.openrewrite.marker.Markers; import org.openrewrite.marker.SearchResult; -import org.openrewrite.maven.MavenIsoVisitor; import org.openrewrite.maven.MavenVisitor; import org.openrewrite.semver.Semver; import org.openrewrite.semver.VersionComparator; @@ -35,8 +33,6 @@ import java.util.Collections; import java.util.Optional; -import static org.openrewrite.Tree.randomId; - /** * Updates the version property unless it is already greater than minimumVersion */ diff --git a/src/test/java/org/openrewrite/jenkins/UpgradeVersionPropertyTest.java b/src/test/java/org/openrewrite/jenkins/UpgradeVersionPropertyTest.java new file mode 100644 index 0000000..2e85eda --- /dev/null +++ b/src/test/java/org/openrewrite/jenkins/UpgradeVersionPropertyTest.java @@ -0,0 +1,102 @@ +/* + * Copyright 2023 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.jenkins; + +import org.junit.jupiter.api.Test; +import org.openrewrite.test.RecipeSpec; +import org.openrewrite.test.RewriteTest; + +import static org.openrewrite.maven.Assertions.pomXml; + +public class UpgradeVersionPropertyTest implements RewriteTest { + @Override + public void defaults(RecipeSpec spec) { + spec.recipe(new UpgradeVersionProperty("jenkins.version", "2.364.1")); + } + + @Test + void shouldUpgrade() { + rewriteRun(pomXml( + """ + + + org.jenkins-ci.plugins + plugin + 4.40 + + + example-plugin + 0.8-SNAPSHOT + + 2.303.1 + + + + repo.jenkins-ci.org + http://repo.jenkins-ci.org/public/ + + + + """, + """ + + + org.jenkins-ci.plugins + plugin + 4.40 + + + example-plugin + 0.8-SNAPSHOT + + 2.364.1 + + + + repo.jenkins-ci.org + http://repo.jenkins-ci.org/public/ + + + + """)); + } + + @Test + void shouldNotDowngrade() { + rewriteRun(pomXml( + """ + + + org.jenkins-ci.plugins + plugin + 4.40 + + + example-plugin + 0.8-SNAPSHOT + + 2.387.1 + + + + repo.jenkins-ci.org + http://repo.jenkins-ci.org/public/ + + + + """)); + } +} diff --git a/src/test/kotlin/net/sghill/jenkins/rewrite/UpgradeVersionPropertyTest.kt b/src/test/kotlin/net/sghill/jenkins/rewrite/UpgradeVersionPropertyTest.kt deleted file mode 100644 index 2ebb8dc..0000000 --- a/src/test/kotlin/net/sghill/jenkins/rewrite/UpgradeVersionPropertyTest.kt +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2023 the original author or authors. - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * https://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sghill.jenkins.rewrite - -import org.junit.jupiter.api.Test -import org.openrewrite.maven.Assertions.pomXml -import org.openrewrite.test.RecipeSpec -import org.openrewrite.test.RewriteTest - -class UpgradeVersionPropertyTest : RewriteTest { - - override fun defaults(spec: RecipeSpec) { - spec.recipe(UpgradeVersionProperty("jenkins.version", "2.364.1")) - } - - @Test - fun upgrades() = rewriteRun( - pomXml( - """ - - - org.jenkins-ci.plugins - plugin - 4.40 - - - example-plugin - 0.8-SNAPSHOT - - 2.303.1 - - - - repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ - - - - """, - """ - - - org.jenkins-ci.plugins - plugin - 4.40 - - - example-plugin - 0.8-SNAPSHOT - - 2.364.1 - - - - repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ - - - - """ - ) - ) - - @Test - fun doesNotDowngrade() = rewriteRun( - pomXml( - """ - - - org.jenkins-ci.plugins - plugin - 4.67 - - - example-plugin - 0.8-SNAPSHOT - - 2.375.1 - - - - repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ - - - - """ ) - ) -}