0

I am using gradle release plugin to push artifacts to artifactory. I want to run the following the tasks before publishing - build, assemble

The documentation says that build task is executed during release task.

1) I want to include the app.war and the assets.zip (configured below) to be published. how would I do that?

2) the current build fails when i do ./gradlew clean release with the error

Cannot cast object 'task ':assemble'' with class 'org.gradle.api.DefaultTask_Decorated' to class 'groovy.lang.Closure'

what is wrong with with configuration - release.dependsOn assemble ?

3) If I comment out that line, and execute, I see the release task executed prompting me to enter version number. when I quit the process (ctrl + C), I do not see a build directory created. release task is executed after build. then I expect to see a build directory. why I dont see it?

Here is the build.gradle

buildscript {
    repositories {
        jcenter()
        mavenLocal()
        maven {
            url "http://internal-repo"
        }
    }
    dependencies {
        classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3'
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:+" 
        classpath 'net.researchgate:gradle-release:2.+'
    }
}

allprojects {
    apply plugin: "com.jfrog.artifactory"    
    apply plugin: 'net.researchgate.release'
}

repositories {
    mavenLocal()
    mavenCentral()
    maven { url "http://internal-external-repo" }
}

apply plugin: "java"
apply plugin: "maven"
apply plugin: "war"
apply plugin: 'tomcat'
apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: "jacoco"

group 'com.mycompany.services'

sourceCompatibility = '1.7'
targetCompatibility = '1.7'

war {
    archiveName = "app.war"
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.11'
}
task copyJars(dependsOn: classes, type: Jar) {
  //
}
assemble.dependsOn copyJars

task copyAssets(type: Copy) {
    //
}
compileJava.dependsOn copyAssets

task makeZips(type: Zip) {

    baseName = 'dependencies'
    version = null
    from('lib/') {  
      // 
           }

            doLast {
        copy {
            from "$buildDir/distributions/dependencies.zip"
            into "$project.rootProject.rootDir/apps/"
        }
    }
}

assemble.dependsOn(makeZips)

task archiveZip (type: Zip, dependsOn: makeZip) {

    from "$project.rootProject.rootDir/apps/dependencies.zip"
}

artifacts {
    archives archiveZip
}

release {
    git {
        versionPropertyFile = 'version.txt'
    }
}

afterReleaseBuild.dependsOn artifactoryPublish
release.dependsOn build
release.dependsOn assemble


dependencies {
    //
}

artifactory {
    contextUrl = "http:/my-interal-repo"
    publish {
        repository {
            repoKey = 'local'
            maven = true
            username = "foo"
            password = "bar"
        }
        defaults {
            publishConfigs ('archives')
        }
    }
    resolve {
        repository {
            repoKey = 'release' 
            maven = true
            username = 'foo'
            password = 'bar'
        }
    }
}

when I run

brain storm
  • 30,124
  • 69
  • 225
  • 393
  • Could you try printing out both build and assemble task objects and comparing their class names? Also try and see what happens if you use 'release.dependsOn build, assemble' instead of the two corresponding lines. – Andrei LED Jul 08 '16 at 18:03
  • I removed release.dependsOn build and had only release.dependsOn assemble. I get same error – brain storm Jul 08 '16 at 18:06

1 Answers1

0

You can configure the build tasks in the plugin config closure.

release {
    buildTasks = ['build']
}
Hillkorn
  • 633
  • 4
  • 12