1- plugins {
2- id(" groovy" )
3- id(" gradlexbuild.lifecycle" )
4- id(" gradlexbuild.asciidoctor-conventions" )
5- id(" org.gradlex.internal.plugin-publish-conventions" ) version " 0.6"
6- }
1+ import java.net.URLClassLoader
2+ import org.asciidoctor.gradle.base.AsciidoctorAttributeProvider
73
8- group = " org.gradlex"
94version = " 2.4"
105
11- java {
12- toolchain.languageVersion = JavaLanguageVersion .of(17 )
13- }
14-
15- tasks.withType<JavaCompile >().configureEach {
16- options.release = 8
17- }
18-
19- tasks.withType<Javadoc >().configureEach {
20- options {
21- this as StandardJavadocDocletOptions
22- encoding = " UTF-8"
23- addStringOption(" Xdoclint:all,-missing" , " -quiet" )
24- addStringOption(" Xwerror" , " -quiet" )
6+ publishingConventions {
7+ pluginPortal(" org.gradlex.jvm-dependency-conflict-resolution" ) {
8+ implementationClass(" org.gradlex.jvm.dependency.conflict.resolution.JvmDependencyConflictResolutionPlugin" )
9+ displayName(" JVM Conflict Resolution Gradle Plugin" )
10+ description(" Convenient dependency conflict management for Java projects." )
11+ tags(
12+ " dependency" ,
13+ " dependencies" ,
14+ " dependency-management" ,
15+ " capabilities" ,
16+ " java" ,
17+ " logging" ,
18+ " asm" ,
19+ " bouncycastle" ,
20+ " cglib" ,
21+ " commons-io" ,
22+ " dom4j" ,
23+ " guava" ,
24+ " hamcrest" ,
25+ " javax" ,
26+ " jakarta" ,
27+ " junit" ,
28+ " mysql" ,
29+ " postgresql" ,
30+ " stax" ,
31+ " slf4j" ,
32+ " log4j2" ,
33+ " velocity" ,
34+ " woodstox" ,
35+ )
36+ }
37+ pluginPortal(" org.gradlex.jvm-dependency-conflict-detection" ) {
38+ implementationClass(" org.gradlex.jvm.dependency.conflict.detection.JvmDependencyConflictDetectionPlugin" )
39+ displayName(" JVM Conflict Detection Gradle Plugin" )
40+ description(" Adds Capabilities to well-known Components hosted on Maven Central." )
2541 }
26- }
27-
28- val tagsList = listOf (
29- " dependency" , " dependencies" , " dependency-management" , " capabilities" , " java" , " logging" ,
30- " asm" , " bouncycastle" , " cglib" , " commons-io" , " dom4j" , " guava" , " hamcrest" , " javax" , " jakarta" , " junit" ,
31- " mysql" , " postgresql" , " stax" , " slf4j" , " log4j2" , " velocity" , " woodstox"
32- )
33-
34- pluginPublishConventions {
35- id(" org.gradlex.jvm-dependency-conflict-resolution" )
36- implementationClass(" org.gradlex.jvm.dependency.conflict.resolution.JvmDependencyConflictResolutionPlugin" )
37- displayName(" JVM Conflict Resolution Gradle Plugin" )
38- description(" Convenient dependency conflict management for Java projects." )
39- tags(* tagsList.toTypedArray())
4042 gitHub(" https://github.com/gradlex-org/jvm-dependency-conflict-resolution" )
4143 website(" https://github.com/gradlex-org/jvm-dependency-conflict-resolution" )
4244 developer {
@@ -56,46 +58,64 @@ pluginPublishConventions {
5658 }
5759}
5860
59- gradlePlugin {
60- plugins {
61- create(" jvm-dependency-conflict-detection" ) {
62- id = " org.gradlex.jvm-dependency-conflict-detection"
63- implementationClass = " org.gradlex.jvm.dependency.conflict.detection.JvmDependencyConflictDetectionPlugin"
64- displayName = " JVM Conflict Detection Gradle Plugin"
65- description = " Adds Capabilities to well-known Components hosted on Maven Central."
66- tags = tagsList
67- }
61+ testingConventions { testGradleVersions(" 6.8.3" , " 6.9.4" , " 7.0.2" , " 8.0.2" , " 8.14.3" ) }
62+
63+ tasks.compileTestJava { options.release = 11 } // allow tests to run against 6.x
64+
65+ val generateCapabilitiesList =
66+ tasks.register<CapabilityListing >(" generateCapabilitiesList" ) {
67+ pluginClasses.from(tasks.jar)
68+ outputFile = layout.buildDirectory.file(" generated/docs/asciidoc/parts/capabilities-listing.adoc" )
6869 }
69- }
7070
71- dependencies {
72- testImplementation(" org.gradle.exemplar:samples-check:1.0.3" )
73- testImplementation(" org.spockframework:spock-core:2.3-groovy-4.0" )
74- testRuntimeOnly(" org.junit.vintage:junit-vintage-engine" )
71+ tasks.asciidoctor {
72+ dependsOn(generateCapabilitiesList)
73+ attributeProviders + = AsciidoctorAttributeProvider {
74+ mapOf (" capabilities-listing" to generateCapabilitiesList.get().outputFile.get().asFile.absolutePath)
75+ }
7576}
7677
77- testing.suites.named<JvmTestSuite >(" test" ) {
78- useJUnitJupiter()
79- listOf (" 6.8.3" , " 6.9.4" , " 7.0.2" , " 8.0.2" , " 8.14.3" ).forEach { gradleVersionUnderTest ->
80- targets.register(" test${gradleVersionUnderTest} " ) {
81- testTask {
82- group = LifecycleBasePlugin .VERIFICATION_GROUP
83- description = " Runs tests against Gradle $gradleVersionUnderTest "
84- useJUnitPlatform {
85- excludeTags(" no-cross-version" )
78+ abstract class CapabilityListing : DefaultTask () {
79+
80+ @get:OutputFile abstract val outputFile: RegularFileProperty
81+
82+ @get:Classpath abstract val pluginClasses: ConfigurableFileCollection
83+
84+ @TaskAction
85+ fun update () {
86+ val classesUrls = pluginClasses.files.map { it.toURI().toURL() }
87+ val loader =
88+ URLClassLoader (" pluginClasspath" , classesUrls.toTypedArray(), ComponentMetadataRule ::class .java.classLoader)
89+ val definitions = loader.loadClass(" org.gradlex.jvm.dependency.conflict.detection.rules.CapabilityDefinition" )
90+
91+ val allCapabilities =
92+ definitions.enumConstants
93+ .map { rule ->
94+ val capability = definitions.getDeclaredMethod(" getCapability" ).invoke(rule) as String
95+ val modules = definitions.getDeclaredMethod(" getModules" ).invoke(rule) as List <* >
96+
97+ Pair (capability, modules)
8698 }
87- systemProperty( " gradleVersionUnderTest " , gradleVersionUnderTest)
99+ .sortedBy { it.first }
88100
89- exclude(" **/*SamplesTest.class" ) // Not yet cross-version ready
101+ val capabilityList =
102+ allCapabilities.joinToString(" " ) { c ->
103+ " * ${c.first} \n ${c.second.joinToString(" " ) { " ** ${(it as String ).asRepoLink()} \n " }} "
90104 }
105+
106+ outputFile.get().asFile.also {
107+ it.parentFile.mkdirs()
108+ it.writeText(capabilityList)
91109 }
92110 }
93- targets.all {
94- testTask {
95- maxParallelForks = 4
96- inputs.dir(layout.projectDirectory.dir(" samples" ))
97- inputs.dir(" src/docs/samples" )
98- }
99- }
111+
112+ private fun String.asRepoLink () = " https://search.maven.org/artifact/${replace(" :" , " /" )} [$this ]"
100113}
101114
115+ // === the following custom configuration should be removed once tests are migrated to Java
116+ apply (plugin = " groovy" )
117+
118+ tasks.named<GroovyCompile >(" compileTestGroovy" ) { targetCompatibility = " 11" } // allow tests to run against 6.x
119+
120+ dependencies { testImplementation(" org.spockframework:spock-core:2.3-groovy-4.0" ) } //
121+ // ====================================================================================
0 commit comments