Frage

I have a build.gradle file I am using to replace an old maven pom.xml composed of 2 modules and a third sub-module. I moved it to gradle in this way:

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'groovy'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.gradle.plugins:shadow:0.7.4'
    }
}

apply plugin: 'shadow'

sourceCompatibility = 1.7
version = '0.1'
jar {
    manifest {
        attributes 'Implementation-Title': 'mainprj', 'Implementation-Version': version
    }
}

subprojects {
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'groovy'

    repositories {
        mavenCentral()
        maven { url 'http://nexus.codehaus.org/snapshots' }
    }

    dependencies {
    //some deps here
    }
}

project(':mainprj') {
    dependencies {
        compile project(':subprj1')
        compile project(':subprj2')
    }
}

project(':subprj1') {
    dependencies {
    compile project(':subprj3')
        //deps here
    }
}

project(':subprj2') {
    dependencies {
    compile project(':subprj3')
        //deps here
    }
}

project(':subprj3') {
    dependencies {
        //deps here
    }
}

shadow {
    exclude 'META-INF/*.SF'
    exclude 'META-INF/*.DSA'
    exclude 'META-INF/*.RSA'

    transformer(org.gradle.api.plugins.shadow.transformers.AppendingTransformer) { resource = 'META-INF/stuff' }
}

I would like to know how to get a "shadowed" package when I run "gradle shadow" from command line as if I run "gradle shadow" I get an empty jar. Any idea?

War es hilfreich?

Lösung

It looks like you want to create a shadow Jar comprising the Jar created by :mainprj and its dependencies. In this case, you'd probably have to apply the plugin to :mainprj, not the root project. Also, unless you do have code in the root project, the java and groovy plugins shouldn't be applied there (but eclipse should).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top