[GRADLE-436] archive_war task fails if the target build dir is a nested directory Created: 06/Apr/09  Updated: 04/Jan/13  Resolved: 18/Apr/09

Status: Resolved
Project: Gradle
Affects Version/s: 0.5.2
Fix Version/s: 0.6

Type: Bug
Reporter: Colin Yates Assignee: Hans Dockter
Resolution: Not A Bug Votes: 0

Attachments: Zip Archive nested-web.zip    

 Description   

(this looks like a duplicate of http://jira.codehaus.org/browse/GRADLE-131)

Hi,

I have the following structure:

  • root
  • (F) build.gradle
  • (F) settings.grade
  • (D) jarA
  • (D) jonah
  • - (D) nah
  • - (F) build.gradle

root/settings.gradle includes jonah/nah

If I build webapps/webapp1 then it fails with the following error message:

— start
:jonah/nah:archive_war

Build failed with an exception.
Run with -s or -d option to get more details. Run with -f option to get the full (very verbose) stacktrace.

Build file '/Users/colinyates/Projects/orca/jonah/trunk/jonah/nah/build.gradle'

Execution failed for task :jonah/nah:archive_war.
Cause: Problem creating war: /Users/colinyates/Projects/orca/jonah/trunk/jonah/nah/build/jonah/nah-1.0.war (No such file or directory) (and the archive is probably corrupt but I could not delete it)

BUILD FAILED

— end

jonah/nah/build.gradle:

— start
// name still becomes nah-1.0.war
// archivesBaseName = 'nah'

usePlugin('war')

dependencies

{ compile project(':test-utils') compile project(':orca-core') compile project(':orca-support') // REVIEW - move these to a common parent build.settings providedCompile('javax.servlet:servlet-api:2.5') providedCompile('javax.servlet:jsp-api:2.0') compile('javax.servlet:jstl:1.2') }

// REVIEW - urgh! The jars on the dependant projects aren't being copied
// http://jira.codehaus.org/browse/GRADLE-425
archive_war {
additionalLibs(dir: '../../orca-core/build/')

{ include('*.jar') }
additionalLibs(dir: '../../orca-support/build/') { include('*.jar') }

}
archive_war.doLast {
File nahWarFile = "$buildDir/nah.war" as File
ant.copy(file: archive_war.getArchivePath(), tofile: nahWarFile)
}

// create the exploded war
File explodedDir = "$buildDir/exploded" as File
createTask('explodedWar', dependsOn: archive_war) {
ant.unzip(src: archive_war.getArchivePath(), dest: explodedDir)
}

— end



 Comments   
Comment by Hans Dockter [ 15/Apr/09 ]

From your snipped I can't see where you set the non standard build dir. I have played around with what I think are similar scenarios but could not reproduce the bug. A test project that reproduces this bug would help a lot.

Comment by Colin Yates [ 17/Apr/09 ]

Attached is a skeleton project.

Running gradle dists in the root results in the following:

colin-yatess-macbook-pro:nested-web colinyates$ gradle dists
:init
:resources
:compile
:testResources
:testCompile
:test
:archive_jar
[ant:jar] Warning: skipping jar archive /Users/colinyates/Projects/gradle-test/nested-web/build/nested-web-1.0.jar because no files were included.
[ant:jar] Warning: skipping jar archive /Users/colinyates/Projects/gradle-test/nested-web/build/nested-web-1.0.jar because no files were included.
:libs
:dists
:a-module:init
:a-module:resources
:a-module:compile
:a-module:testResources
:a-module:testCompile
:a-module:test
:a-module:archive_jar
[ant:jar] Warning: skipping jar archive /Users/colinyates/Projects/gradle-test/nested-web/a-module/build/a-module-1.0.jar because no files were included.
[ant:jar] Warning: skipping jar archive /Users/colinyates/Projects/gradle-test/nested-web/a-module/build/a-module-1.0.jar because no files were included.
:a-module:libs
:a-module:dists
:wars/a-webapp:init
:wars/a-webapp:resources
:wars/a-webapp:compile
:wars/a-webapp:testResources
:wars/a-webapp:testCompile
:wars/a-webapp:test
:wars/a-webapp:archive_jar SKIPPED
:wars/a-webapp:archive_war

Build failed with an exception.
Run with -s or -d option to get more details. Run with -f option to get the full (very verbose) stacktrace.

Build file '/Users/colinyates/Projects/gradle-test/nested-web/wars/a-webapp/build.gradle'

Execution failed for task :wars/a-webapp:archive_war.
Cause: Problem creating war: /Users/colinyates/Projects/gradle-test/nested-web/wars/a-webapp/build/wars/a-webapp-1.0.war (No such file or directory) (and the archive is probably corrupt but I could not delete it)

BUILD FAILED

Total time: 4.689 secs
colin-yatess-macbook-pro:nested-web colinyates$

Comment by Hans Dockter [ 17/Apr/09 ]

Thanks for the test case. I have the problem that when I unpack nested-web.tgz, the nested-web/build.gradle is an empty document and I can't reproduce the above output.

Comment by Colin Yates [ 17/Apr/09 ]

uploaded a new zip file. Apologies for that

Comment by Hans Dockter [ 18/Apr/09 ]

There is a bug in your settings.gradle. Instead of "wars/a-project" the path must be described as "wars:a-project". We use a different path separator, because Gradle has special tasks where the normal path separator can be part of the task name. We are aware that this is not intuitive. For 0.7 we are thinking about ways to use the normal path separator for project paths and still be able to use the path separator in task names.

Generated at Wed Jun 30 11:30:05 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.