33package com.vanniktech.maven.publish.workaround
44
55import com.vanniktech.maven.publish.baseExtension
6- import org.gradle.api.Action
76import org.gradle.api.Project
8- import org.gradle.api.artifacts.Configuration
97import org.gradle.api.attributes.DocsType
108import org.gradle.api.component.AdhocComponentWithVariants
119import org.gradle.api.internal.project.ProjectInternal
1210import org.gradle.api.plugins.JavaPluginExtension
1311import org.gradle.api.plugins.internal.JavaConfigurationVariantMapping
1412import org.gradle.api.plugins.internal.JvmPluginsHelper
15- import org.gradle.api.provider.Provider
1613import org.gradle.internal.component.external.model.ProjectDerivedCapability
1714import org.gradle.util.GradleVersion
1815
@@ -35,46 +32,19 @@ internal fun addTestFixturesSourcesJar(project: Project) {
3532 }.newInstance(projectInternal, " testFixtures" )
3633
3734 // use reflection because return type changed in Gradle 9.2.0-milestone-1
38- val sourceElements = JvmPluginsHelper ::class .java
39- .getMethod(
40- " createDocumentationVariantWithArtifact" ,
41- String ::class .java,
42- String ::class .java,
43- String ::class .java,
44- Set ::class .java,
45- String ::class .java,
46- Object ::class .java,
47- ProjectInternal ::class .java,
48- ).invoke(
49- null ,
50- testFixturesSourceSet.sourcesElementsConfigurationName,
51- testFixtureSourceSetName,
52- DocsType .SOURCES ,
53- setOf (projectDerivedCapability),
54- testFixturesSourceSet.sourcesJarTaskName,
55- testFixturesSourceSet.allSource,
56- projectInternal,
57- )
35+ val sourceElements = JvmPluginsHelper .createDocumentationVariantWithArtifact(
36+ testFixturesSourceSet.sourcesElementsConfigurationName,
37+ testFixtureSourceSetName,
38+ DocsType .SOURCES ,
39+ setOf (projectDerivedCapability),
40+ testFixturesSourceSet.sourcesJarTaskName,
41+ testFixturesSourceSet.allSource,
42+ projectInternal,
43+ )
5844
5945 // the following is not using private APIs just needs to adapt to the API change in the method above
6046 val component = project.components.findByName(" java" ) as AdhocComponentWithVariants
61- if (GradleVersion .current() >= GradleVersion .version(" 9.2.0-milestone-1" )) {
62- AdhocComponentWithVariants ::class .java.getMethod(
63- " addVariantsFromConfiguration" ,
64- Provider ::class .java,
65- Action ::class .java,
66- )
67- } else {
68- AdhocComponentWithVariants ::class .java.getMethod(
69- " addVariantsFromConfiguration" ,
70- Configuration ::class .java,
71- Action ::class .java,
72- )
73- }.invoke(
74- component,
75- sourceElements,
76- JavaConfigurationVariantMapping (" compile" , true ),
77- )
47+ component.addVariantsFromConfiguration(sourceElements, JavaConfigurationVariantMapping (" compile" , true ))
7848}
7949
8050/* *
0 commit comments