From 34c076f6d1d1b200db8f95bc28a905cbc61acb90 Mon Sep 17 00:00:00 2001 From: Jun Rao Date: Fri, 29 Aug 2014 14:05:54 -0700 Subject: [PATCH] 1. No longer wrapping creation of srcJar and javadocJar in the "tasks.withType(Javadoc)". We know that javadoc task was added because we have applied the java plugin. The previous implementation would break if another Javadoc task was added. 2. No longer overwrite the jar and docsJar tasks - there is no need to overwrite those tasks. We can simply update them and add extra scala-related configuration. 3. Started using plugins.withType(ScalaPlugin) {} block to configure the scala-specific settings 4. docsJar task does not seem to be a jar task. It looks like it is a task that aggregates other documentation tasks. Updated the code accordingly. --- build.gradle | 66 +++++++++++++++++++++++++++--------------------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/build.gradle b/build.gradle index 45cf502..6d6f1a4 100644 --- a/build.gradle +++ b/build.gradle @@ -74,47 +74,31 @@ subprojects { from '../NOTICE' } - tasks.withType(Javadoc) { - task srcJar(type:Jar) { - classifier = 'sources' - from '../LICENSE' - from '../NOTICE' - from sourceSets.main.java - } - - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier 'javadoc' - from '../LICENSE' - from '../NOTICE' - from javadoc.destinationDir - } - - task docsJar(type: Jar, dependsOn: javadocJar) { } - - artifacts { - archives srcJar - archives javadocJar - } + task srcJar(type:Jar) { + classifier = 'sources' + from '../LICENSE' + from '../NOTICE' + from sourceSets.main.java } - tasks.withType(ScalaCompile) { - task srcJar(type:Jar, overwrite: true) { - classifier = 'sources' - from '../LICENSE' - from '../NOTICE' - from sourceSets.main.scala - from sourceSets.main.java - } + task javadocJar(type: Jar, dependsOn: javadoc) { + classifier 'javadoc' + from '../LICENSE' + from '../NOTICE' + from javadoc.destinationDir + } - scalaCompileOptions.useAnt = false + task docsJar(dependsOn: javadocJar) - configure(scalaCompileOptions.forkOptions) { - memoryMaximumSize = '1g' - jvmArgs = ['-XX:MaxPermSize=512m'] - } + artifacts { + archives srcJar + archives javadocJar } + + plugins.withType(ScalaPlugin) { + //source jar should also contain scala source: + srcJar.from sourceSets.main.scala - tasks.withType(ScalaDoc) { task scaladocJar(type:Jar) { classifier = 'scaladoc' from '../LICENSE' @@ -122,12 +106,22 @@ subprojects { from scaladoc } - task docsJar(type: Jar, dependsOn: ['javadocJar', 'scaladocJar'], overwrite: true) { } + //documentation task should also trigger building scala doc jar + docsJar.dependsOn scaladocJar artifacts { archives scaladocJar } } + + tasks.withType(ScalaCompile) { + scalaCompileOptions.useAnt = false + + configure(scalaCompileOptions.forkOptions) { + memoryMaximumSize = '1g' + jvmArgs = ['-XX:MaxPermSize=512m'] + } + } } for ( sv in ['2_9_1', '2_9_2', '2_10_1', '2_11'] ) { -- 1.8.3.4 (Apple Git-47)