Skip to content

Commit

Permalink
SourceJarPlugin.groovy: remove custom logic in favor of javaPluginExt…
Browse files Browse the repository at this point in the history
…ension.withSourcesJar()
  • Loading branch information
rpalcolea committed Jan 20, 2023
1 parent e1b372b commit 53e3d65
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,9 @@ package nebula.plugin.publishing.publications
import groovy.transform.CompileDynamic
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.ConfigurationContainer
import org.gradle.api.internal.file.FileResolver
import org.gradle.api.internal.project.ProjectInternal
import org.gradle.api.model.ObjectFactory
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.plugins.internal.JvmPluginsHelper
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.TaskContainer
import org.gradle.util.GradleVersion

import javax.inject.Inject

Expand All @@ -44,26 +37,8 @@ class SourceJarPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.plugins.withType(JavaPlugin) {
TaskContainer tasks = project.getTasks()
ConfigurationContainer configurations = project.getConfigurations()
JavaPluginExtension javaPluginExtension = project.extensions.getByType(JavaPluginExtension)
SourceSet main = (SourceSet) javaPluginExtension.getSourceSets().getByName("main")
if(GradleVersion.current() >= GradleVersion.version("8.0-milestone-4")) {
FileResolver resolver = ((ProjectInternal) project).getFileResolver()
def taskDependencyFactory = project.getTaskDependencyFactory()
JvmPluginsHelper.configureDocumentationVariantWithArtifact(
"sourcesElements", (String)null, "sources", Collections.emptyList(),
"sourceJar", main.getAllSource(), project.components.java, configurations, tasks, this.objectFactory, resolver, taskDependencyFactory)
} else if(GradleVersion.current() >= GradleVersion.version("7.4-rc-1")) {
FileResolver resolver = ((ProjectInternal) project).getFileResolver()
JvmPluginsHelper.configureDocumentationVariantWithArtifact(
"sourcesElements", (String)null, "sources", Collections.emptyList(),
"sourceJar", main.getAllSource(), project.components.java, configurations, tasks, this.objectFactory, resolver)
} else {
JvmPluginsHelper.configureDocumentationVariantWithArtifact(
"sourcesElements", (String)null, "sources", Collections.emptyList(),
"sourceJar", main.getAllSource(), project.components.java, configurations, tasks, this.objectFactory)
}
javaPluginExtension.withSourcesJar()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ apply plugin: "org.jenkins-ci.jpi"
def 'maintains backwards compatibility with sourceJar task - configure baseName'() {
buildFile << '''\
apply plugin: 'java'
sourceJar.archiveBaseName = 'some-jar-name'
sourcesJar.archiveBaseName = 'some-jar-name'
'''.stripIndent()

writeHelloWorld('example')
Expand Down

0 comments on commit 53e3d65

Please sign in to comment.