建筑uberjar与gradle在jenkins失败

时间:2016-01-28 19:25:47

标签: jenkins gradle uberjar

您好我正在使用gradle创建一个胖罐。 它在我的本地机器上正常工作,但在从Jenkins运行时失败。

我的本​​地gradle版本是:GradleVersion.current()。getVersion()= 2.2.1 Jenkins中的那个:GradleVersion.current()。getVersion()= 2.4

build.gradle看起来像

gradle版本有什么用吗?

我只是运行任务:干净的uberjar

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

sourceCompatibility = 1.5

version = '1.0'

repositories {
    mavenLocal()
    mavenCentral()
}
def classifier = 'producao'

println "GradleVersion.current().getVersion()="+ GradleVersion.current().getVersion()

println "Project env = '${project.hasProperty('env')}'"

// para passar parametros -Penv=homologacao

if (project.hasProperty('env') && project.getProperty('env') == 'homologacao') {
    classifier = 'homologacao'
}
println "Classifier = ${classifier}"
println "Using 'com.mundi:OneStop:1.0:${classifier}'"
dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.3.10'
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    compile  'net.sf.opencsv:opencsv:2.3'
    compile "com.mundi:OneStop:1.0:${classifier}"
    compile 'org.apache.commons:commons-lang3:3.4'
    testCompile group: 'junit', name: 'junit', version: '4.+'
    testCompile "org.spockframework:spock-core:1.0-groovy-2.3"
}

task listJars << {
    configurations.compile.each { File file -> println file.name }
}

test { systemProperties 'property': 'value' }

uploadArchives {
    repositories { flatDir { dirs 'repos'
        } }
}

task copyToLib(type: Copy) {
    into "build/classes/main"

    sourceSets {
        main { resources { srcDir 'src/main/resources' } }
    }

    from sourceSets.main.resources
}

task uberjar(type: Jar, group:'Extra Jars', description: 'Assembles a single uber jar archive containing the main classes along with all its dependencies.', 
    dependsOn:[':copyToLib',
    ':compileJava',
    ':compileGroovy',
    ':processResources'
]) {
    classifier = 'uber'
    destinationDir new File("$buildDir")
    from files(sourceSets.main.output.classesDir)
    from(configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }) { 

        //exclude all META-INF that may appear in any dependant jar         
        exclude "META-INF/**"     
    }

    version = '1.0'

    baseName = "OneStopMonitor"

    manifest {
        attributes 'Main-Class':  "com.onestop.monitor.AirMonitor",
        'Implementation-Title': 'OneStop Monitor',
        'Implementation-Version': version
    }
}
group = 'com.onestop'
uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "file:///Users/eduardorodrigues/.m2/repository")
        }
    }
}

0 个答案:

没有答案