Skip to content

Commit

Permalink
Added simplistic test to build.gradle to check validity of mod.zip on…
Browse files Browse the repository at this point in the history
… dist
  • Loading branch information
timyates committed Nov 16, 2012
1 parent 683222f commit 7296a53
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,27 @@ task prepareVertxModule( type:Copy, dependsOn: 'classes' ) {
}

// Package into build/libs/mod.zip
task dist( type: Zip, dependsOn: 'prepareVertxModule' ) {
task distZip( type: Zip, dependsOn: 'prepareVertxModule' ) {
group = 'vert.x'
description = "Assembles a vert.x module in 'mod.zip' format"
destinationDir = project.file('build/libs')
archiveName = 'mod.zip'
from( project.file( "build/mod/${modulename}-v${version}" ) ).into( "${modulename}-v${version}" )
}

// Package into build/libs/mod.zip
task dist( dependsOn: 'distZip' ) << {
def entries = new java.util.zip.ZipFile( project.file( 'build/libs/mod.zip' ) ).entries().collect { it.name }
def oneRoot = entries.every { it.startsWith "${modulename}-v${version}/" }
def modjson = entries.find { it == "${modulename}-v${version}/mod.json" }
if( !oneRoot ) {
throw new GradleException( "Invalid mod.zip. Multiple root folders located!" )
}
else if( !modjson ) {
throw new GradleException( "Invalid mod.zip. Cannot locate ${modulename}-v${version}/mod.json" )
}
}

task prepareVertxTest(type: Sync, dependsOn: ['prepareVertxModule']) {
from 'build/mod'
into 'build/tmp/mod-test'
Expand Down

0 comments on commit 7296a53

Please sign in to comment.