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 org.asciidoctor.gradle.base.AsciidoctorAttributeProvider
2+ import java.net.URLClassLoader
3+
4+ plugins { id(" groovy" ) } // TODO migrate tests to Java
75
86group = " org.gradlex"
97version = " 2.4"
108
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" )
25- }
26- }
27-
289val tagsList = listOf (
2910 " dependency" , " dependencies" , " dependency-management" , " capabilities" , " java" , " logging" ,
3011 " asm" , " bouncycastle" , " cglib" , " commons-io" , " dom4j" , " guava" , " hamcrest" , " javax" , " jakarta" , " junit" ,
@@ -58,7 +39,7 @@ pluginPublishConventions {
5839
5940gradlePlugin {
6041 plugins {
61- create (" jvm-dependency-conflict-detection" ) {
42+ register (" jvm-dependency-conflict-detection" ) {
6243 id = " org.gradlex.jvm-dependency-conflict-detection"
6344 implementationClass = " org.gradlex.jvm.dependency.conflict.detection.JvmDependencyConflictDetectionPlugin"
6445 displayName = " JVM Conflict Detection Gradle Plugin"
@@ -74,28 +55,52 @@ dependencies {
7455 testRuntimeOnly(" org.junit.vintage:junit-vintage-engine" )
7556}
7657
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" )
86- }
87- systemProperty(" gradleVersionUnderTest" , gradleVersionUnderTest)
88-
89- exclude(" **/*SamplesTest.class" ) // Not yet cross-version ready
90- }
91- }
58+ testingConventions {
59+ testGradleVersions(" 6.8.3" , " 6.9.4" , " 7.0.2" , " 8.0.2" , " 8.14.3" )
60+ }
61+
62+ val generateCapabilitiesList = tasks.register<CapabilityListing >(" generateCapabilitiesList" ) {
63+ pluginClasses.from(tasks.jar)
64+ outputFile = layout.buildDirectory.file(" generated/docs/asciidoc/parts/capabilities-listing.adoc" )
65+ }
66+
67+ tasks.asciidoctor {
68+ dependsOn(generateCapabilitiesList)
69+ attributeProviders + = AsciidoctorAttributeProvider {
70+ mapOf (" capabilities-listing" to generateCapabilitiesList.get().outputFile.get().asFile.absolutePath)
9271 }
93- targets.all {
94- testTask {
95- maxParallelForks = 4
96- inputs.dir(layout.projectDirectory.dir(" samples" ))
97- inputs.dir(" src/docs/samples" )
72+ }
73+
74+ abstract class CapabilityListing : DefaultTask () {
75+
76+ @get:OutputFile
77+ abstract val outputFile: RegularFileProperty
78+
79+ @get:Classpath
80+ abstract val pluginClasses: ConfigurableFileCollection
81+
82+ @TaskAction
83+ fun update () {
84+ val classesUrls = pluginClasses.files.map { it.toURI().toURL() }
85+ val loader = URLClassLoader (" pluginClasspath" , classesUrls.toTypedArray(), ComponentMetadataRule ::class .java.classLoader)
86+ val definitions = loader.loadClass(" org.gradlex.jvm.dependency.conflict.detection.rules.CapabilityDefinition" )
87+
88+ val allCapabilities = definitions.enumConstants.map { rule ->
89+ val capability = definitions.getDeclaredMethod(" getCapability" ).invoke(rule) as String
90+ val modules = definitions.getDeclaredMethod(" getModules" ).invoke(rule) as List <* >
91+
92+ Pair (capability, modules)
93+ }.sortedBy { it.first }
94+
95+ val capabilityList = allCapabilities.joinToString(" " ) { c ->
96+ " * ${c.first} \n ${c.second.joinToString(" " ) { " ** ${(it as String ).asRepoLink()} \n " }} "
97+ }
98+
99+ outputFile.get().asFile.also {
100+ it.parentFile.mkdirs()
101+ it.writeText(capabilityList)
98102 }
99103 }
100- }
101104
105+ private fun String.asRepoLink () = " https://search.maven.org/artifact/${replace(" :" , " /" )} [$this ]"
106+ }
0 commit comments