Skip to content

Commit

Permalink
Add support for Gradle 8 in source jar plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalcolea committed Dec 13, 2022
1 parent 53a68cd commit 5bd6112
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
plugins {
id 'com.netflix.nebula.plugin-plugin' version '20.0.0'
id 'com.netflix.nebula.plugin-plugin' version '20.1.0'
}

description 'Gradle plugin to ease use of ivy-publish and maven-publish'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ class SourceJarPlugin implements Plugin<Project> {
ConfigurationContainer configurations = project.getConfigurations()
JavaPluginExtension javaPluginExtension = project.extensions.getByType(JavaPluginExtension)
SourceSet main = (SourceSet) javaPluginExtension.getSourceSets().getByName("main")
if(GradleVersion.current() >= GradleVersion.version("7.4-rc-1")) {
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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ class SourceJarPluginIntegrationSpec extends IntegrationSpec {
new File(mavenPublishDir, 'sourcetest-0.1.0-sources.jar').exists()
}

def 'creates a source jar with maven publishing with Gradle 8'() {
gradleVersion = '8.0-milestone-5'
buildFile << '''\
apply plugin: 'java'
'''.stripIndent()

when:
runTasksSuccessfully('publishNebulaPublicationToTestMavenRepository')

then:
new File(mavenPublishDir, 'sourcetest-0.1.0-sources.jar').exists()
}

def 'creates a source jar with ivy publishing'() {
buildFile << '''\
apply plugin: 'java'
Expand Down

0 comments on commit 5bd6112

Please sign in to comment.