Skip to content

Commit

Permalink
Use org.openrewrite.build plugins 1.4.0 which remove Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Dec 26, 2022
1 parent dbd7ce8 commit eedab65
Show file tree
Hide file tree
Showing 21 changed files with 28 additions and 53 deletions.
8 changes: 2 additions & 6 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@ NOTE: windows-style users should ensure that they configure `core.autocrlf = fal

### CLI Environment Configuration:

* [JDK](https://adoptopenjdk.net/) version: 11
* JDK language & bytecode level: 1.8
* [JDK](https://adoptium.net/) version: 17
* [Gradle](https://gradle.org/) version: Defined in wrapper
* [Kotlin](https://kotlinlang.org/) version: 1.5
* Kotlin language level: 1.5
* Kotlin JVM bytecode level: 1.8

### IDE Configuration

We use [IntelliJ IDEA](https://www.jetbrains.com/idea/) to develop this project.
Other IDEs or versions of this IDE can be made to work.
These are one set of versions we know works:

* IDEA version: 2021.1.3
* IDEA version: 2022.2.3

You must set the `-parameters` compiler flag to run Rewrite tests.
If your system does not have UTF-8 as its default character encoding (e.g., Windows) you must also add `-encoding utf8`.
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ org.gradle.parallel=true
org.gradle.caching=true
org.gradle.workers.max=6
org.gradle.jvmargs=-Xmx3g
kotlin.stdlib.default.dependency=false
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite;

import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.marker.SearchResult;

@Incubating(since = "7.25.0")
public class Applicability {
Expand All @@ -26,7 +27,7 @@ public static <P> TreeVisitor<?, P> not(TreeVisitor<?, P> v) {
public Tree visit(@Nullable Tree tree, P p) {
Tree t2 = v.visit(tree, p);
return tree == t2 && tree != null ?
((SourceFile) tree).withMarkers(((SourceFile) tree).getMarkers().searchResult()) :
SearchResult.found(tree) :
tree;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public PrintOutputCapture<P> clone() {
return new PrintOutputCapture<>(p, markerPrinter);
}

@Incubating(since = "7.31.0")
public interface MarkerPrinter {
MarkerPrinter DEFAULT = new MarkerPrinter() {
@Override
Expand Down
1 change: 0 additions & 1 deletion rewrite-core/src/main/java/org/openrewrite/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ public String diff(@Nullable Path relativeTo) {
return diff(relativeTo, null);
}

@Incubating(since = "7.31.0")
public String diff(@Nullable Path relativeTo, @Nullable PrintOutputCapture.MarkerPrinter markerPrinter) {
return diff(relativeTo, markerPrinter, false);
}
Expand Down
2 changes: 0 additions & 2 deletions rewrite-core/src/main/java/org/openrewrite/TreeVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ protected void doAfterVisit(TreeVisitor<T, P> visitor) {
*
* @param recipe The recipe whose visitor to run.
*/
@Incubating(since = "7.0.0")
protected void doAfterVisit(Recipe recipe) {
//noinspection unchecked
afterVisit.add((TreeVisitor<T, P>) recipe.getVisitor());
Expand Down Expand Up @@ -359,7 +358,6 @@ protected final <T2 extends T> T2 visitAndCast(@Nullable Tree tree, P p) {
return (T2) visit(tree, p);
}

@Incubating(since = "7.2.0")
public Markers visitMarkers(Markers markers, P p) {
return markers.withMarkers(ListUtils.map(markers.getMarkers(), marker -> this.visitMarker(marker, p)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public Recipe activateRecipes(String... activeRecipes) {
return activateRecipes(Arrays.asList(activeRecipes));
}

@Incubating(since = "7.0.0")
public Recipe activateAll() {
Recipe root = new CompositeRecipe();
listRecipes().forEach(root::doNext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class SetRangeTest {
void exclusiveRange() {
SetRange setRange = SetRange.build("(1,2)", null).getValue();

assertThat(setRange).isNotNull();
assertThat(setRange.isValid(null, "0.1")).isFalse();
assertThat(setRange.isValid(null, "1")).isFalse();
assertThat(setRange.isValid(null, "1.0")).isFalse();
Expand All @@ -37,6 +38,7 @@ void exclusiveRange() {
void inclusiveRange() {
SetRange setRange = SetRange.build("[1,2]", null).getValue();

assertThat(setRange).isNotNull();
assertThat(setRange.isValid(null, "0.1")).isFalse();
assertThat(setRange.isValid(null, "1")).isTrue();
assertThat(setRange.isValid(null, "1.0")).isTrue();
Expand All @@ -50,6 +52,7 @@ void inclusiveRange() {
void inclusiveLowOnly() {
SetRange setRange = SetRange.build("[1,2)", null).getValue();

assertThat(setRange).isNotNull();
assertThat(setRange.isValid(null, "0.1")).isFalse();
assertThat(setRange.isValid(null, "1")).isTrue();
assertThat(setRange.isValid(null, "1.0")).isTrue();
Expand All @@ -63,6 +66,7 @@ void inclusiveLowOnly() {
void inclusiveHighOnly() {
SetRange setRange = SetRange.build("(1,2]", null).getValue();

assertThat(setRange).isNotNull();
assertThat(setRange.isValid(null, "0.1")).isFalse();
assertThat(setRange.isValid(null, "1")).isFalse();
assertThat(setRange.isValid(null, "1.0")).isFalse();
Expand All @@ -76,6 +80,7 @@ void inclusiveHighOnly() {
void inclusiveLowUnqualifiedHigh() {
SetRange setRange = SetRange.build("[1,)", null).getValue();

assertThat(setRange).isNotNull();
assertThat(setRange.isValid(null, "0")).isFalse();
assertThat(setRange.isValid(null, "1")).isTrue();
assertThat(setRange.isValid(null, "1.0")).isTrue();
Expand All @@ -87,6 +92,7 @@ void inclusiveLowUnqualifiedHigh() {
void inclusiveHighUnqualifiedLow() {
SetRange setRange = SetRange.build("(,9999]", null).getValue();

assertThat(setRange).isNotNull();
assertThat(setRange.isValid(null, "1")).isTrue();
assertThat(setRange.isValid(null, "1.0")).isTrue();
assertThat(setRange.isValid(null, "2.0")).isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void changeSetTargetCompatibility() {
}

@Test
void changeSourceCompatibility_JavaPluginExtension() {
void changeSourceCompatibilityJavaPluginExtension() {
rewriteRun(
spec -> spec.recipe(new ChangeJavaCompatibility(newVersion, "source")),
buildGradle(
Expand All @@ -200,7 +200,7 @@ void changeSourceCompatibility_JavaPluginExtension() {
}

@Test
void changeTargetCompatibility_JavaPluginExtension() {
void changeTargetCompatibilityJavaPluginExtension() {
rewriteRun(
spec -> spec.recipe(new ChangeJavaCompatibility(newVersion, "target")),
buildGradle(
Expand All @@ -227,7 +227,7 @@ void changeTargetCompatibility_JavaPluginExtension() {
}

@Test
void changeSourceCompatibility_CompileJava() {
void changeSourceCompatibilityCompileJava() {
rewriteRun(
spec -> spec.recipe(new ChangeJavaCompatibility(newVersion, "source")),
buildGradle(
Expand All @@ -254,7 +254,7 @@ void changeSourceCompatibility_CompileJava() {
}

@Test
void changeTargetCompatibility_CompileJava() {
void changeTargetCompatibilityCompileJava() {
rewriteRun(
spec -> spec.recipe(new ChangeJavaCompatibility(newVersion, "target")),
buildGradle(
Expand All @@ -281,7 +281,7 @@ void changeTargetCompatibility_CompileJava() {
}

@Test
void changeSourceCompatibility_TasksNamedCompileJava() {
void changeSourceCompatibilityTasksNamedCompileJava() {
rewriteRun(
spec -> spec.recipe(new ChangeJavaCompatibility(newVersion, "source")),
buildGradle(
Expand All @@ -308,7 +308,7 @@ void changeSourceCompatibility_TasksNamedCompileJava() {
}

@Test
void changeTargetCompatibility_TasksNamedCompileJava() {
void changeTargetCompatibilityTasksNamedCompileJava() {
rewriteRun(
spec -> spec.recipe(new ChangeJavaCompatibility(newVersion, "target")),
buildGradle(
Expand All @@ -335,7 +335,7 @@ void changeTargetCompatibility_TasksNamedCompileJava() {
}

@Test
void changeSourceCompatibility_TasksWithTypeJavaCompile() {
void changeSourceCompatibilityTasksWithTypeJavaCompile() {
rewriteRun(
spec -> spec.recipe(new ChangeJavaCompatibility(newVersion, "source")),
buildGradle(
Expand All @@ -362,7 +362,7 @@ void changeSourceCompatibility_TasksWithTypeJavaCompile() {
}

@Test
void changeTargetCompatibility_TasksWithTypeJavaCompile() {
void changeTargetCompatibilityTasksWithTypeJavaCompile() {
rewriteRun(
spec -> spec.recipe(new ChangeJavaCompatibility(newVersion, "target")),
buildGradle(
Expand All @@ -389,7 +389,7 @@ void changeTargetCompatibility_TasksWithTypeJavaCompile() {
}

@Test
void changeSourceCompatibility_JavaPluginExtensionFieldAccess() {
void changeSourceCompatibilityJavaPluginExtensionFieldAccess() {
rewriteRun(
spec -> spec.recipe(new ChangeJavaCompatibility(newVersion, "source")),
buildGradle(
Expand All @@ -412,7 +412,7 @@ void changeSourceCompatibility_JavaPluginExtensionFieldAccess() {
}

@Test
void changeTargetCompatibility_JavaPluginExtensionFieldAccess() {
void changeTargetCompatibilityJavaPluginExtensionFieldAccess() {
rewriteRun(
spec -> spec.recipe(new ChangeJavaCompatibility(newVersion, "target")),
buildGradle(
Expand Down
3 changes: 0 additions & 3 deletions rewrite-java-11/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ java {
}

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_11.toString()
targetCompatibility = JavaVersion.VERSION_11.toString()

options.release.set(null as? Int?) // remove `--release 8` set in `org.openrewrite.java-base`
options.compilerArgs.addAll(
listOf(
Expand Down
3 changes: 0 additions & 3 deletions rewrite-java-17/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ dependencies {
}

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()

options.release.set(null as Int?) // remove `--release 8` set in `org.openrewrite.java-base`
options.compilerArgs.addAll(
listOf(
Expand Down
10 changes: 0 additions & 10 deletions rewrite-java-8/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.openrewrite.build.language-library")
}
Expand Down Expand Up @@ -31,15 +29,7 @@ java {
}
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
}
}

tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
options.isFork = true
options.release.set(null as? Int?) // remove `--release 8` set in `org.openrewrite.java-base`
}
Expand Down
5 changes: 1 addition & 4 deletions rewrite-java-tck/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ tasks.withType<Javadoc> {
}

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()

options.release.set(null as Int?) // remove `--release 8` set in `org.openrewrite.java-base`
options.release.set(null as? Int?) // remove `--release 8` set in `org.openrewrite.java-base`
}

configurations.all {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public J.MemberReference visitMemberReference(J.MemberReference memberRef, Execu
JavaType.Variable varType = memberRef.getVariableType();
if (varType != null && TypeUtils.isOfClassType(varType.getOwner(), fullyQualifiedTypeName) &&
varType.getName().equals(fieldName)) {
m = m.withReference(m.getReference().withMarkers(m.getReference().getMarkers().searchResult()));
m = m.withReference(SearchResult.found(m.getReference()));
}
return m;
}
Expand Down
1 change: 0 additions & 1 deletion rewrite-json/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id("org.openrewrite.build.language-library")
}

// run manually with -x compileKotlin when you need to regenerate
tasks.register<JavaExec>("generateAntlrSources") {
mainClass.set("org.antlr.v4.Tool")

Expand Down
2 changes: 0 additions & 2 deletions rewrite-maven/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ dependencies {
api("com.fasterxml.jackson.core:jackson-annotations")

compileOnly(project(":rewrite-test"))
compileOnly(kotlin("bom"))
compileOnly(kotlin("stdlib"))

// Caffeine 2.x works with Java 8, Caffeine 3.x is Java 11 only.
implementation("com.github.ben-manes.caffeine:caffeine:2.+")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
import org.openrewrite.*;
import org.openrewrite.internal.NameCaseConvention;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.marker.SearchResult;
import org.openrewrite.properties.PropertiesVisitor;
import org.openrewrite.properties.tree.Properties;

import java.util.HashSet;
import java.util.Set;

import static org.openrewrite.Tree.randomId;

@Value
@EqualsAndHashCode(callSuper = true)
public class FindProperties extends Recipe {
Expand Down Expand Up @@ -82,8 +85,8 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
@Override
public Properties visitEntry(Properties.Entry entry, ExecutionContext ctx) {
if (!Boolean.FALSE.equals(relaxedBinding) ? NameCaseConvention.equalsRelaxedBinding(entry.getKey(), propertyKey) : entry.getKey().equals(propertyKey)) {
//noinspection deprecation
entry = entry.withValue(entry.getValue().withMarkers(entry.getValue().getMarkers().searchResult()));
entry = entry.withValue(entry.getValue().withMarkers(entry.getValue().getMarkers()
.computeByType(new SearchResult(randomId(), null), (s1, s2) -> s1 == null ? s2 : s1)));
}
return super.visitEntry(entry, ctx);
}
Expand Down
1 change: 0 additions & 1 deletion rewrite-protobuf/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id("org.openrewrite.build.language-library")
}

// run manually with -x compileKotlin when you need to regenerate
tasks.register<JavaExec>("generateAntlrSources") {
mainClass.set("org.antlr.v4.Tool")

Expand Down
1 change: 0 additions & 1 deletion rewrite-xml/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id("org.openrewrite.build.language-library")
}

// run manually with -x compileKotlin when you need to regenerate
tasks.register<JavaExec>("generateAntlrSources") {
mainClass.set("org.antlr.v4.Tool")

Expand Down
1 change: 0 additions & 1 deletion rewrite-yaml/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id("org.openrewrite.build.language-library")
}

// run manually with -x compileKotlin when you need to regenerate
tasks.register<JavaExec>("generateAntlrSources") {
mainClass.set("org.antlr.v4.Tool")

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.namespace!!.startsWith("org.openrewrite.build")) {
useVersion("latest.release")
useVersion("1.4.0")
}
}
}
Expand Down

0 comments on commit eedab65

Please sign in to comment.