From 19aaba47f14ecde48faf6c82644d5ae2148d4865 Mon Sep 17 00:00:00 2001 From: Nicholas Mathison Date: Thu, 27 Oct 2016 10:11:52 -0400 Subject: [PATCH] Package of .groovy files - Compiled Groovy classes are no longer added to the jar file. This prevents errors with mismatching of Groovy compile and runtime versions. Compiled Java classes are still added. --- build.gradle | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index b85b902..4901173 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,7 @@ ['groovy', 'maven', 'signing'].each { apply plugin: it } -//defaultTasks 'clean', 'jar', 'copyDocs' -defaultTasks 'clean', 'compileJava', 'compileGroovy', 'processResources', 'classes', 'createJar', 'copyGroovyJar', 'copyDocs' +defaultTasks 'clean', 'jar', 'copyDocs' group = 'com.ibm.urbancode.plugins' archivesBaseName = 'groovy-plugin-utils' @@ -23,6 +22,13 @@ dependencies { compile 'com.google.code.gson:gson:2.3.1' } +/* + * Uploading artifacts requires properties be defined in $GRADLE_USER_HOME/gradle.properties. $GRADLE_USER_HOME defaults to $USER_HOME/.gradle + * ossrhUsername=your-jira-id + * ossrhPassword=your-jira-password + * See: http://central.sonatype.org/pages/gradle.html + * Then follow: http://central.sonatype.org/pages/releasing-the-deployment.html + */ uploadArchives { repositories { mavenDeployer { @@ -76,25 +82,30 @@ task groovyDocJar(type: Jar) { from groovydoc } -task createJar(type: Exec) { - commandLine "jar", "cf", "build/tmp/${jar.archiveName}", "-C", "src/main/groovy", "." +// Copy the source into the build jar directory +jar { + dependsOn 'copyGroovy' +} + +// Change the Groovy Compile output directory to not combine in final Jar build folder +compileGroovy { + destinationDir = file('build/tmp/groovyClasses') } -task copyGroovyJar(type: Copy) { - from "build/tmp/${jar.archiveName}" - into 'build/libs' +task copyGroovy(type:Copy) { + from sourceSets.main.groovy + into 'build/classes/main' } -def groovyJar = file("build/libs/${jar.archiveName}") artifacts { - archives groovyJar, sourcesJar, groovyDocJar + archives jar, sourcesJar, groovyDocJar } /** * Signing requires that the following properties be defined in $GRADLE_USER_HOME/gradle.properties. $GRADLE_USER_HOME defaults to $USER_HOME/.gradle - * signing.keyId= - * signing.password= - * signing.secretKeyRingFile= + * signing.keyId=YourKeyId + * signing.password=YourPublicKeyPassword + * signing.secretKeyRingFile=PathToYourKeyRingFile * See http://www.gradle.org/docs/current/userguide/signing_plugin.html */ signing {