Skip to content

Commit

Permalink
Package of .groovy files
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Nicholas Mathison committed Oct 27, 2016
1 parent 911d358 commit 19aaba4
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 19aaba4

Please sign in to comment.