Skip to content

Commit

Permalink
Also test with Groovy 2.5 on classpath for Gradle 4, 5 & 6
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Sep 24, 2024
1 parent 2f24d50 commit 83054dc
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 30 deletions.
37 changes: 37 additions & 0 deletions rewrite-groovy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ plugins {
id("org.openrewrite.build.language-library")
}

// As per: https://docs.gradle.org/current/userguide/java_testing.html#sec:configuring_java_integration_tests
sourceSets {
create("intTest") {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
}
}
val intTestImplementation by configurations.getting {
extendsFrom(configurations.implementation.get())
}
val intTestRuntimeOnly by configurations.getting
configurations["intTestRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get())

dependencies {
api(project(":rewrite-java"))

Expand All @@ -21,4 +34,28 @@ dependencies {
testImplementation("org.junit-pioneer:junit-pioneer:2.0.0")
testRuntimeOnly("org.codehaus.groovy:groovy-all:latest.release")
testRuntimeOnly(project(":rewrite-java-17"))

intTestImplementation(project(":rewrite-test"))
intTestImplementation("org.junit.jupiter:junit-jupiter:latest.release")
intTestImplementation("org.codehaus.groovy:groovy:[2.5,2.6)")
intTestRuntimeOnly("org.codehaus.groovy:groovy-all:[2.5,2.6)")
intTestRuntimeOnly(project(":rewrite-java-17"))
intTestRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

// As per: https://docs.gradle.org/current/userguide/java_testing.html#sec:configuring_java_integration_tests
val integrationTest = task<Test>("integrationTest") {
description = "Runs integration tests."
group = "verification"

testClassesDirs = sourceSets["intTest"].output.classesDirs
classpath = sourceSets["intTest"].runtimeClasspath
shouldRunAfter("test")

useJUnitPlatform()

testLogging {
events("passed")
}
}
tasks.check { dependsOn(integrationTest) }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = true

[*.java]
indent_size = 4
ij_continuation_indent_size = 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2024 the original author or authors.
* <p>
* 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
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.groovy;

import org.junit.jupiter.api.Test;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.groovy.Assertions.groovy;

class Groovy2Test implements RewriteTest {

@Test
void useInt() {
rewriteRun(
groovy(
"""
def variable = "12345"
"""
)
);
}

@Test
void useJavaUtilDate() {
rewriteRun(
groovy(
"""
def variable = new java.util.Date()
"""
)
);
}

@Test
void useStringMultiplicationInParentheses() {
rewriteRun(
groovy(
"""
def variable = ("#" * 6)
"""
)
);
}
}
60 changes: 30 additions & 30 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ pluginManagement {
// ---------------------------------------------------------------

val allProjects = listOf(
"rewrite-benchmarks",
"rewrite-bom",
"rewrite-core",
"rewrite-gradle",
"rewrite-groovy",
"rewrite-hcl",
"rewrite-java",
"rewrite-java-tck",
"rewrite-java-test",
"rewrite-java-17", // remove this when rewrite recipe gradle plugin moves to 21
"rewrite-java-21",
"rewrite-json",
"rewrite-maven",
"rewrite-properties",
"rewrite-protobuf",
"rewrite-test",
"rewrite-xml",
"rewrite-yaml",
"rewrite-benchmarks",
"rewrite-bom",
"rewrite-core",
"rewrite-gradle",
"rewrite-groovy",
"rewrite-hcl",
"rewrite-java",
"rewrite-java-tck",
"rewrite-java-test",
"rewrite-java-17", // remove this when rewrite recipe gradle plugin moves to 21
"rewrite-java-21",
"rewrite-json",
"rewrite-maven",
"rewrite-properties",
"rewrite-protobuf",
"rewrite-test",
"rewrite-xml",
"rewrite-yaml",
)

val includedProjects = file("IDE.properties").let {
Expand All @@ -42,7 +42,7 @@ val includedProjects = file("IDE.properties").let {
}
}.toSet()

if(!file("IDE.properties").exists() || includedProjects.contains("tools")) {
if (!file("IDE.properties").exists() || includedProjects.contains("tools")) {
includeBuild("tools")
}

Expand All @@ -52,23 +52,23 @@ gradle.allprojects {
configurations.all {
resolutionStrategy.dependencySubstitution {
allProjects
.minus(includedProjects)
.minus(arrayOf("rewrite-bom"))
.forEach {
substitute(project(":$it"))
.using(module("org.openrewrite:$it:latest.integration"))
}
.minus(includedProjects)
.minus(arrayOf("rewrite-benchmarks", "rewrite-bom"))
.forEach {
substitute(project(":$it"))
.using(module("org.openrewrite:$it:latest.integration"))
}
}
}
}

if (System.getProperty("idea.active") == null &&
System.getProperty("idea.sync.active") == null) {
System.getProperty("idea.sync.active") == null) {
include(
"rewrite-java-8",
"rewrite-java-11",
"rewrite-java-17",
"rewrite-java-21"
"rewrite-java-8",
"rewrite-java-11",
"rewrite-java-17",
"rewrite-java-21"
)
}

Expand Down

0 comments on commit 83054dc

Please sign in to comment.