Skip to content

Commit d1461ab

Browse files
committed
Migrate build to shared convention plugins setup
1 parent 8f24458 commit d1461ab

File tree

9 files changed

+75
-165
lines changed

9 files changed

+75
-165
lines changed

build.gradle.kts

Lines changed: 26 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,26 @@
1-
plugins {
2-
id("groovy")
3-
id("org.gradlex.internal.plugin-publish-conventions") version "0.6"
4-
}
5-
6-
group = "org.gradlex"
7-
version = "1.7"
8-
9-
tasks.withType<JavaCompile>().configureEach { options.release = 8 }
10-
11-
dependencies {
12-
testImplementation("org.spockframework:spock-core:2.3-groovy-4.0")
13-
testImplementation("org.gradle.exemplar:samples-check:1.0.3")
14-
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
15-
}
16-
17-
pluginPublishConventions {
18-
id("${project.group}.${project.name}")
19-
implementationClass("org.gradlex.javamodule.testing.JavaModuleTestingPlugin")
20-
displayName("Java Module Testing Gradle Plugin")
21-
description("A plugin to test Java Modules (whitebox and blackbox) without the hassle.")
22-
tags("gradlex", "java", "modularity", "jigsaw", "jpms", "testing")
23-
gitHub("https://github.com/gradlex-org/java-module-testing")
24-
developer {
25-
id.set("jjohannes")
26-
name.set("Jendrik Johannes")
27-
email.set("[email protected]")
28-
}
29-
}
30-
31-
testing.suites.named<JvmTestSuite>("test") {
32-
useJUnitJupiter()
33-
listOf("7.4", "7.6.5", "8.0.2", "8.14.2").forEach { gradleVersionUnderTest ->
34-
targets.register("test${gradleVersionUnderTest}") {
35-
testTask {
36-
group = LifecycleBasePlugin.VERIFICATION_GROUP
37-
description = "Runs tests against Gradle $gradleVersionUnderTest"
38-
systemProperty("gradleVersionUnderTest", gradleVersionUnderTest)
39-
exclude("**/*SamplesTest.class") // Not yet cross-version ready
40-
}
41-
}
42-
}
43-
targets.all {
44-
testTask {
45-
maxParallelForks = 4
46-
inputs.dir(layout.projectDirectory.dir("samples"))
47-
inputs.dir("samples")
48-
}
49-
}
50-
}
1+
version = "1.7"
2+
3+
publishingConventions {
4+
pluginPortal("${project.group}.${project.name}") {
5+
implementationClass("org.gradlex.javamodule.testing.JavaModuleTestingPlugin")
6+
displayName("Java Module Testing Gradle Plugin")
7+
description("A plugin to test Java Modules (whitebox and blackbox) without the hassle.")
8+
tags("gradlex", "java", "modularity", "jigsaw", "jpms", "testing")
9+
}
10+
gitHub("https://github.com/gradlex-org/java-module-testing")
11+
developer {
12+
id.set("jjohannes")
13+
name.set("Jendrik Johannes")
14+
email.set("[email protected]")
15+
}
16+
}
17+
18+
testingConventions { testGradleVersions("7.4", "7.6.5", "8.0.2", "8.14.2") }
19+
20+
// === the following custom configuration should be removed once tests are migrated to Java
21+
apply(plugin = "groovy")
22+
23+
tasks.named<GroovyCompile>("compileTestGroovy") { targetCompatibility = "11" } // allow tests to run against 6.x
24+
25+
dependencies { testImplementation("org.spockframework:spock-core:2.3-groovy-4.0") } //
26+
// ====================================================================================

gradle/checkstyle/checkstyle.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

gradle/checkstyle/header.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
toolchainVersion=17

settings.gradle.kts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
plugins {
2-
id("com.gradle.develocity") version "4.2.2"
3-
}
4-
5-
dependencyResolutionManagement {
6-
repositories.mavenCentral()
7-
}
1+
plugins { id("org.gradlex.internal-build-conventions") version "0.7" }
82

93
rootProject.name = "java-module-testing"
10-
11-
develocity {
12-
buildScan {
13-
val isCi = providers.environmentVariable("CI").getOrElse("false").toBoolean()
14-
if (isCi) {
15-
termsOfUseUrl = "https://gradle.com/help/legal-terms-of-use"
16-
termsOfUseAgree = "yes"
17-
} else {
18-
publishing.onlyIf { false }
19-
}
20-
}
21-
}

src/test/java/org/gradlex/javamodule/testing/test/samples/PluginBuildLocationSampleModifier.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/test/java/org/gradlex/javamodule/testing/test/samples/SamplesTest.java

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package org.gradlex.javamodule.testing.test.samples;
3+
4+
import java.io.File;
5+
import java.util.stream.Collectors;
6+
import java.util.stream.Stream;
7+
import org.gradle.exemplar.model.Command;
8+
import org.gradle.exemplar.model.Sample;
9+
import org.gradle.exemplar.test.runner.SampleModifier;
10+
11+
public class PluginBuildLocationSampleModifier implements SampleModifier {
12+
@Override
13+
public Sample modify(Sample sampleIn) {
14+
Command cmd = sampleIn.getCommands().remove(0);
15+
File pluginProjectDir = new File(".");
16+
sampleIn.getCommands()
17+
.add(new Command(
18+
new File(pluginProjectDir, "gradlew").getAbsolutePath(),
19+
cmd.getExecutionSubdirectory(),
20+
Stream.concat(
21+
cmd.getArgs().stream(),
22+
Stream.of(
23+
"build",
24+
"--warning-mode=all",
25+
"-PpluginLocation=" + pluginProjectDir.getAbsolutePath()))
26+
.collect(Collectors.toList()),
27+
cmd.getFlags(),
28+
cmd.getExpectedOutput(),
29+
cmd.isExpectFailure(),
30+
true,
31+
cmd.isAllowDisorderedOutput(),
32+
cmd.getUserInputs()));
33+
return sampleIn;
34+
}
35+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package org.gradlex.javamodule.testing.test.samples;
3+
4+
import org.gradle.exemplar.test.runner.SampleModifiers;
5+
import org.gradle.exemplar.test.runner.SamplesRoot;
6+
import org.gradle.exemplar.test.runner.SamplesRunner;
7+
import org.junit.runner.RunWith;
8+
9+
@RunWith(SamplesRunner.class)
10+
@SamplesRoot("samples")
11+
@SampleModifiers(PluginBuildLocationSampleModifier.class)
12+
public class SamplesTest {}

0 commit comments

Comments
 (0)