GradleUp / shadow

Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.
https://www.gradleup.com/shadow/
Apache License 2.0
3.76k stars 395 forks source link

Publishing a Gradle Plugin with submodule #602

Open vinz486 opened 4 years ago

vinz486 commented 4 years ago

Shadow Version

6.0.0

Gradle Version

6.4.1

Expected Behavior

Plugin on nexus

Actual Behavior

Plugin not found

Gradle Build Script(s)

plugins { id 'com.github.johnrengelman.shadow' version '6.0.0' id 'java-gradle-plugin' id 'groovy' id 'maven-publish' id 'idea' }

allprojects {

sourceCompatibility = '1.8'

group 'xxx.dxl'
version = new File('version.txt').text.trim()

repositories {
    maven {
        url = "../maven"
    }
    maven {
        url = "http://nexus-nexus3.dxl-pre.xxx.com/repository/libs-release"
    }
    maven {
        url = "http://nexus-nexus3.dxl-pre.xxx.com/repository/maven2-virtual"
        allowInsecureProtocol = true
    }
}

}

publishing {

publications {
    shadow(MavenPublication) { publication ->
        project.shadow.component(publication)
    }
}

repositories {
    if (project.hasProperty('repositoryUrl')) {
        maven {
            url = repositoryUrl
            credentials {
                username = repositoryUser
                password = repositoryPass
            }
            allowInsecureProtocol = true
        }
    } else {
        maven {
            url = "../maven"
        }
    }
}

} compileJava { options.compilerArgs += ['-Xlint:deprecation'] }

dependencies {

implementation project(path: ":clientgen")

implementation 'it.xxx.dxl:spring-dxl-swagger-codegen:1.3.1'

implementation 'io.swagger:swagger-codegen:2.4.15'
implementation 'org.reflections:reflections:0.9.12'
implementation 'org.projectlombok:lombok:1.18.10'

annotationProcessor 'org.projectlombok:lombok:1.18.10'

implementation gradleApi()
implementation localGroovy()

}

gradlePlugin { plugins { dxl { id = 'xxx.dxl' implementationClass = 'xxx.dxl.DxlPlugin' } } }

test { useJUnitPlatform() }


Hi, my goal is to include a submodule in my custom gradle plugin. I need to add only the submodule in the jar, not all the dependencies.

Plugin publication works fine, without Shadow.

When I add Shadow and configure the publication as stated in the guide:

publications { shadow(MavenPublication) { publication -> project.shadow.component(publication) } }

the plugin in not found anymore in the user project. Seem like gradle plugin metadata and id is lost.

How can I solve?

Thank you.

vinz486 commented 4 years ago

Also, I have on gradle console:

Task :publishShadowPublicationToMavenRepository Multiple publications with coordinates 'xxx.dxl:dxl:2.0.45-SNAPSHOT' are published to repository 'maven'. The publications will overwrite each other!

vinz486 commented 4 years ago

This is the consumer gradle output: Could not apply requested plugin [id: 'xxx.dxl', version: '2.0.45-SNAPSHOT'] as it does not provide a plugin with id 'xxx.dxl'. This is caused by an incorrect plugin implementation. Please contact the plugin author(s).