vivin / gradle-semantic-build-versioning

Gradle plugin to generate version-numbers and tags using semantic versioning
MIT License
85 stars 32 forks source link

Build failed while generating version for my project jar #35

Closed varora1975 closed 7 years ago

varora1975 commented 7 years ago

Hi ,

I am trying to use version plugin and getting error when using following command

gradlew clean jar bumpMinor --stacktrace

gradlew clean jar autobump --stacktrace

I am getting below error

My Git Tags are git tag 1.0.0

build.gradle

buildscript { ext { grailsVersion = project.grailsVersion } repositories { mavenLocal() // maven { url "https://repo.grails.org/grails/core" }

    maven {
        credentials {
            username 'vishal'
            password 'London01'
        }
        url "https://sonarqube.qvmonarch.co.nz/nexus/repository/grails-plugins/"
    }

}
dependencies {
    classpath "org.grails:grails-gradle-plugin:$grailsVersion"
    classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.7.4"
    classpath "org.grails.plugins:hibernate4:5.0.4"
    classpath 'se.transmode.gradle:gradle-docker:1.2'
    classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2"
}

}

plugins { id "net.vivin.gradle-semantic-build-versioning" version "2.0.2" }

plugins { id "org.sonarqube" version "2.2" }

group "propertyservice"

apply plugin:"eclipse" apply plugin:"idea"

// Disable war plugin to create a jar file otherwise a fully executable war file is created. apply plugin:"war"

apply plugin:"org.grails.grails-web" apply plugin:"org.grails.grails-gsp" apply plugin:"asset-pipeline" apply plugin: 'docker' // apply plugin:"codenarc" apply plugin: "jacoco" apply plugin: "org.sonarqube" apply plugin: 'net.vivin.gradle-semantic-build-versioning' project.version.with { startingVersion = '1.0.0' }

ext { grailsVersion = project.grailsVersion gradleWrapperVersion = project.gradleWrapperVersion grails { pathingJar = true } }

/*

dependencies { compile "org.grails.plugins:aws-sdk:1.10.44" }

repositories { mavenLocal()

maven {
    credentials {
        username 'vishal'
        password 'London01'
    }
    url "https://sonarqube.qvmonarch.co.nz/nexus/repository/grails-plugins/"
}

}

dependencyManagement { imports { mavenBom "org.grails:grails-bom:$grailsVersion" } applyMavenExclusions false }

dependencies { compile "org.springframework.boot:spring-boot-starter-logging" compile "org.springframework.boot:spring-boot-autoconfigure" compile "org.grails:grails-core" compile "org.springframework.boot:spring-boot-starter-actuator" compile "org.springframework.boot:spring-boot-starter-tomcat" compile "org.grails:grails-dependencies" compile "org.grails:grails-web-boot" compile "org.grails.plugins:cache" compile "org.grails.plugins:scaffolding" compile "org.grails.plugins:hibernate4" compile "org.hibernate:hibernate-ehcache" compile "org.grails:grails-datastore-rest-client:5.0.5.RELEASE" compile "org.grails.plugins:elasticsearch:1.0.0.2" // compile "org.grails.plugins:aws-sdk:1.10.44" compile "org.grails.plugins:quartz:2.0.1" compile 'com.auth0:auth0-spring-mvc:0.0.1' compile group: 'javax.servlet', name: 'jstl', version: '1.2' compile'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0'

console "org.grails:grails-console"
profile "org.grails.profiles:web:3.1.5"
runtime "org.grails.plugins:asset-pipeline"
runtime "com.h2database:h2"
runtime "org.postgresql:postgresql:9.4-1204-jdbc42"
runtime "org.grails.plugins:grails-melody-plugin:1.60.1"
runtime "com.thoughtworks.xstream:xstream:1.4.9"

testCompile "org.gebish:geb-spock:0.9.0-RC-1"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testCompile "com.github.tomakehurst:wiremock:2.0.10-beta"
testCompile "com.github.tomjankes:wiremock-groovy:0.2.0"
testCompile "org.elasticmq:elasticmq-server_2.11:0.9.3"
testCompile "org.grails:grails-datastore-test-support:6.0.0.M1"
testCompile group: 'org.spockframework', name: 'spock-core', version: '1.1-groovy-2.4-rc-2'
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"

}

task wrapper(type: Wrapper) { gradleVersion = gradleWrapperVersion }

assets { minifyJs = false minifyCss = false }

grails { agent { enabled = false } // Pathing Jar fixes the file length exceeding command line character limit issue in Windows pathingJar = true }

test { forkEvery 1 ignoreFailures = true }

docker { maintainer 'Tenzing "tenzing@tenzing.co.nz"' }

task docker(type: Docker, dependsOn: build) { // push = true // applicationName = jar.baseName applicationName = "property-service" // tagVersion = "1.0" dockerfile = file('src/main/docker/Dockerfile') doFirst { copy { from war into stageDir } } }

vivin commented 7 years ago

It looks like some task tries (docker maybe?) to serialize its task inputs (or something to that effect), and project.version appears to be one of those inputs. Unfortunately the version object from the plugin is not serializable. I'm not sure why a task would be trying to do that - you certainly can't assume that the version will always be serializable if it is Object. One way around it would be to set the version property in that task explicitly to project.version.toString(). But this will cause another problem. Since the versioning plugin uses tasks to control the version number, the actual version number is only available after the configuration phase. This means that the version property will get the wrong version. To get around that, you can set the version property explicitly inside a taskGraph.whenReady block.

A newer version of this plugin is in the works and will aim to address this "delayed configuration" issue.

varora1975 commented 7 years ago

I tried removing docker tasks and added below snippet in my build.gradle. But still getting same error

gradle.taskGraph.whenReady {taskGraph -> version = "1.0.0" }

vivin commented 7 years ago

From the stack trace I can't really tell what it could be. I would suggest disabling plugins one by one and also possibly clearing out the cache?

varora1975 commented 7 years ago

I tried disabling all the plugins not no luck. Just wanted to let you know that when I run

gradlew printVersion

Output is

_version_1.0.1-SNAPSHOT:printVersion 1.0.0

BUILD SUCCESSFUL

But while running

gradlew clean jar

It prints project.version property as _version_1.0.1-SNAPSHOT:clean and fails with same error

If you can provide any suggestion will be helpful

vivin commented 7 years ago

During which task does it fail? Also, did you clear out your gradle cache?

varora1975 commented 7 years ago

When I run gradlew jar --stacktrace task it fails and gradlew printVersion or gradlew clean is successful.

I deleted my .gradle folder but still same error

vivin commented 7 years ago

So even after deleting ~/.gradle you run into the same error? From researching, this looks to be an issue with the gradle cache and unrelated to the plugin. If this continues, I suggest asking for help on the gradle forum - they will probably be able to help you out better.