I’m using Gradle to deploy to Tomcat with the Cargo library. Every now and again we get the following error:
* What went wrong:
Execution failed for task ':copyWar'.
Cause: Could not resolve all dependencies for configuration ':publish'.
Cause: Could not resolve group:ch.hedgesphere, module:HSMtWebServer, version:latest.integration.
Required by:
:build:unspecified
Cause: java.text.ParseException: [[Fatal Error] 7e4254cb6607c572a3c45570f612282b17ee36da:1:1: Premature end of file. in HttpResource: http://artifactory:8081/artifactory/gradle-snapshot/ch.hedgesphere/HSMtWebServer/5.2.0-20120208132235/ivy-5.2.0-20120208132235.xml
]
Looking at the XML file from Artifactory, it looks fine. If I go and look in the Gradle cache on our Windows 7 build server, I find the shortcut file, but it points to a 0 byte file.
Deleting the entire cache fixes the problem, but it is re-occurring about once per day.
Here’s the Gradle script we use:
apply from: '../HSMtBuild/hsserv-repos.gradle'
apply from: '../HSMtBuild/third-party-repos.gradle'
def warFileName = System.getProperty('warFileName')
configurations {
publish
classpath
all*.exclude group: 'maven-plugins'
}
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 1, 'minutes'
}
dependencies {
publish group: 'ch.hedgesphere', name: warFileName, version: 'latest.integration', ext: 'war'
classpath 'org.codehaus.cargo:cargo-core-uberjar:1.2.0','org.codehaus.cargo:cargo-ant:1.2.0','jaxen:jaxen:1.1.3', 'commons-logging:commons-logging:1.1.1'
}
ant.taskdef(resource: 'cargo.tasks', classpath: configurations.classpath.asPath)
targetWarFileName = System.properties['user.home'] + "/${warFileName}.war"
task copyWar << {
ant.copy file: configurations.publish.singleFile.path,
tofile: targetWarFileName
}
task install(dependsOn: copyWar) << {
outputs.upToDateWhen { false }
for (def attempt = 0; attempt < 3; attempt ++) {
try {
ant.cargo(containerId: 'tomcat7x', action: 'redeploy', type: 'remote') {
configuration(type: 'runtime'){
property(name: 'cargo.servlet.port', value: '8080')
property(name: 'cargo.hostname', value: 'localhost')
property(name: 'cargo.remote.username', value: 'tomcat')
property name: 'cargo.remote.password', value: 'tomcat'
deployable(type: 'war', file: targetWarFileName) {
property(name: 'context', value: 'HSMtFlexWebServer')
}
}
}
break
}
catch(Exception e) {
println e
if(attempt == 2) throw e
Thread.sleep 15000
}
}
}