diff --git a/build.gradle b/build.gradle index 5cf5f93..91e032e 100644 --- a/build.gradle +++ b/build.gradle @@ -69,7 +69,7 @@ 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') @@ -77,6 +77,19 @@ task dist( type: Zip, dependsOn: 'prepareVertxModule' ) { 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'