Permalink
Browse files

Preliminary support for InvokeDynamic builds

   - activate indy support using -Pindy=true
   - indy jars are produced with the "indy" classifier
   - OSGI support is disabled if indy is activated
   - distribution is still unaware of indy
 Misc
    - ensure that all output build directories are named "target" (some were "target", some where "build")
  • Loading branch information...
1 parent 6eaa05e commit 1dd2f130e2a1775dee702879cd9c4ee4f10f83aa @melix melix committed May 24, 2012
View
79 build.gradle
@@ -1,12 +1,18 @@
apply plugin: 'groovy'
apply plugin: 'codenarc'
apply plugin: 'checkstyle'
+apply from: "$projectDir/gradle/indy.gradle"
+
// TODO use antlr plugin
//apply plugin: 'antlr'
allprojects { p ->
apply plugin: 'java'
+ buildDir = 'target'
+ sourceCompatibility = 1.5
+ targetCompatibility = 1.5
+
group = 'org.codehaus.groovy'
version = groovyVersion
// tasks.withType(Checkstyle).all { t -> t.ignoreFailures = true }
@@ -18,10 +24,6 @@ allprojects { p ->
compile.transitive = true
testCompile.transitive = true
}
- // TODO why doesn't this work?
-// test {
-// excludes = ['**/*TestCase.class', '**/*$*.class']
-// }
// todo: when we get rid of the Ant build, it will be much cleaner to use
// the conventional "resources" directory for classpath resources
@@ -46,11 +48,52 @@ allprojects { p ->
from sourceSets.main.allSource
}
- apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'groovy'
apply plugin: 'codenarc'
apply from: "${project(':').projectDir}/gradle/groovydoc.gradle"
+ apply from: "${project(':').projectDir}/gradle/indy.gradle"
+
+ if (useIndy()) {
+ def indyGroovy = {
+ options.useAnt = true
+ // todo: when Gradle includes support for "indy" option, replace this
+ // with groovyOptions.indy = true
+ groovyOptions.metaClass.optionMap = {
+ ['indy':true,
+ memoryMaximumSize:'384m',
+ fork:true,
+ includeJavaRuntime:false,
+ verbose:false,
+ encoding:'UTF-8',
+ failonerror:true,
+ stacktrace:false,
+ listfiles:false]
+ }
+ groovyOptions.useAnt = true
+ sourceCompatibility = 1.7
+ targetCompatibility = 1.7
+ groovyClasspath = files(
+ project(':').compileJava.destinationDir,
+ project(':').compileJava.classpath,
+ { project(':subprojects:groovy-docgenerator').compileJava.destinationDir },
+ { project(':subprojects:groovy-groovydoc').compileJava.destinationDir },
+ { project(':subprojects:groovy-ant').compileJava.destinationDir },
+ { project(':subprojects:groovy-templates').compileJava.destinationDir },
+ )
+ }
+ // add tasks to compile the invokedynamic version
+
+ compileGroovy indyGroovy.clone()
+ compileTestGroovy indyGroovy.clone()
+
+ compileJava.sourceCompatibility = 1.7
+ compileJava.targetCompatibility = 1.7
+ jar {
+ classifier = 'indy'
+ }
+ }
+
}
// don't fail build on CodeNarc tasks
@@ -63,11 +106,6 @@ tasks.withType(Checkstyle).all { checkstyleTask ->
checkstyleTask.configFile = file("./config/checkstyle/checkstyle.xml")
}
-sourceCompatibility = 1.5
-targetCompatibility = 1.5
-
-buildDir = 'target'
-
repositories {
// todo Some repos are needed only for some configs. Declare them just for the configuration once Gradle allows this.
// mavenCentral() // default, tools
@@ -207,6 +245,11 @@ sourceSets {
"$projectDir/subprojects/groovy-xml/src/main",
"$projectDir/subprojects/groovy-jmx/src/main",
]
+ if (!useIndy()) {
+ exclude '**/indy/*'
+ exclude '**/v7/*'
+ exclude '**/vm7/*'
+ }
}
}
main {
@@ -221,6 +264,11 @@ sourceSets {
}.visit {details ->
exclude "groovy/ui/$details.path"
}
+ if (!useIndy()) {
+ exclude '**/indy/*'
+ exclude '**/v7/*'
+ exclude '**/vm7/*'
+ }
}
groovy {
srcDirs = [
@@ -341,6 +389,11 @@ compileJava {
}
compileGroovy {
+ doFirst {
+ if (useIndy()) {
+ logger.info('Building with InvokeDynamic support activated')
+ }
+ }
groovyOptions.fork(memoryMaximumSize: groovycMain_mx)
}
@@ -379,4 +432,8 @@ task wrapper(type: Wrapper) {
}
// Define a GroovyDoc task which depends on the generated groovydoc tool
-apply from: "$projectDir/gradle/groovydoc.gradle"
+apply from: "$projectDir/gradle/groovydoc.gradle"
+
+class MyGroovyOptions extends org.gradle.api.tasks.compile.GroovyCompileOptions {
+ boolean indy = true
+}
View
17 buildSrc/build.gradle
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2008-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+buildDir = 'target'
View
68 gradle/assemble.gradle
@@ -1,7 +1,9 @@
import org.apache.tools.ant.filters.ReplaceTokens
import java.text.SimpleDateFormat
-apply plugin: 'osgi'
+if (!rootProject.useIndy()) {
+ apply plugin: 'osgi'
+}
group = 'org.codehaus.groovy'
archivesBaseName = 'groovy'
@@ -45,19 +47,23 @@ task copy(type: Copy) {
with licenseSpec
}
-def commonOsgiManifest = {
- // We exclude the Bnd-LastModified attribute as it always triggers a rebuild without being really needed.
- from(allManifest) {
- eachEntry {details ->
- if (details.key == 'Bnd-LastModified') {
- details.exclude()
+def commonOsgiManifest
+
+if (!rootProject.useIndy()) {
+ commonOsgiManifest = {
+ // We exclude the Bnd-LastModified attribute as it always triggers a rebuild without being really needed.
+ from(allManifest) {
+ eachEntry {details ->
+ if (details.key == 'Bnd-LastModified') {
+ details.exclude()
+ }
}
}
+ version = groovyBundleVersion
+ instruction '-nouses', 'true'
+ instruction 'Export-Package', "*;version=${version}"
+ classpath = sourceSets.main.runtimeClasspath
}
- version = groovyBundleVersion
- instruction '-nouses', 'true'
- instruction 'Export-Package', "*;version=${version}"
- classpath = sourceSets.main.runtimeClasspath
}
jar {
@@ -76,12 +82,14 @@ jar {
}
}
}
- manifest = osgiManifest {
- symbolicName = 'groovy'
- instruction 'Import-Package', "antlr", "org.objectweb.asm", "*;resolution:=optional"
- classesDir = sourceSets.main.output.classesDir
+ if (!rootProject.useIndy()) {
+ manifest = osgiManifest {
+ symbolicName = 'groovy'
+ instruction 'Import-Package', "antlr", "org.objectweb.asm", "*;resolution:=optional"
+ classesDir = sourceSets.main.output.classesDir
+ }
+ manifest commonOsgiManifest
}
- manifest commonOsgiManifest
exclude '**/package-info.class', 'compiler', 'META-INF/groovy-release-info.properties'
}
@@ -125,6 +133,9 @@ def mergeModuleDescriptors() {
task jarAll(type: Jar, dependsOn: { modules()*.jar }) {
ext.metaInfDir = "$buildDir/tmp/groovy-all-metainf"
appendix = 'all'
+ if (rootProject.useIndy()) {
+ classifier = 'indy'
+ }
doLast {
manifest.writeTo("$metaInfDir/MANIFEST.MF")
copy {
@@ -156,16 +167,15 @@ task jarAll(type: Jar, dependsOn: { modules()*.jar }) {
}
}
}
- // We exclude the Bnd-LastModified attribute as it always triggers a rebuild without being really needed.
- manifest = osgiManifest {
- symbolicName = 'groovy-all'
- instruction 'Import-Package', "*;resolution:=optional"
- classesDir = jar.archivePath
+ if (!rootProject.useIndy()) {
+ // We exclude the Bnd-LastModified attribute as it always triggers a rebuild without being really needed.
+ manifest = osgiManifest {
+ symbolicName = 'groovy-all'
+ instruction 'Import-Package', "*;resolution:=optional"
+ classesDir = jar.archivePath
+ }
+ manifest commonOsgiManifest
}
- manifest commonOsgiManifest
-
- // TODO: scan the various org.codehaus.groovy.runtime.ExtensionModule extension module descriptors
- // and replace them with a single descriptor find which will be bundled into the groovy-all jar
}
task sourceAllJar(type: Jar, dependsOn: { modules()*.sourceJar }) {
@@ -174,18 +184,18 @@ task sourceAllJar(type: Jar, dependsOn: { modules()*.sourceJar }) {
with it.rootSpec
}
appendix = 'all'
- classifier = 'sources'
+ classifier = rootProject.useIndy()?'indy-sources':'sources'
//with sourceJar.rootSpec
}
task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
+ classifier = rootProject.useIndy()?'indy-javadoc':'javadoc'
from javadoc.destinationDir
}
task javadocAllJar(type: Jar, dependsOn: javadocJar) {
appendix = 'all'
- classifier = 'javadoc'
+ classifier = rootProject.useIndy()?'indy-javadoc':'javadoc'
with javadocJar.rootSpec
}
@@ -258,3 +268,5 @@ task distSrc(type: Zip, dependsOn: [javadoc, groovydoc, docGDK]) {
'cobertura.ser', 'junitvmwatcher*.properties'
}
}
+
+//task
View
31 gradle/indy.gradle
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2008-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// This file contains support tools for the Gradle build
+// with regards to invoke dynamic support (indy)
+
+project(':').ext.useIndy = {
+ boolean indy = false
+
+ // first, check if a system property activates indy support
+ indy |= System.hasProperty('indy') && Boolean.valueOf(System.getProperty('indy'))
+
+ // ultimately, check if the main project has an extension property setting indy to true
+ // which is the case if the build is started with -Pindy=true or during install/dist tasks
+ indy |= project(':').hasProperty('indy') && (Boolean.valueOf(project(':').indy))
+
+ indy
+}
View
8 src/main/org/codehaus/groovy/tools/FileSystemCompiler.java
@@ -17,6 +17,7 @@
package org.codehaus.groovy.tools;
import groovy.lang.GroovyResourceLoader;
+import groovy.util.FileLog;
import org.apache.commons.cli.*;
import org.codehaus.groovy.control.CompilationUnit;
import org.codehaus.groovy.control.CompilerConfiguration;
@@ -25,10 +26,7 @@
import groovy.lang.GroovySystem;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
+import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
@@ -160,7 +158,7 @@ public static void commandLineCompile(String[] args, boolean lookupUnnamedFiles)
* @param args command line arguments
*/
public static void main(String[] args) {
- commandLineCompileWithErrorHandling(args,true);
+ commandLineCompileWithErrorHandling(args, true);
}
/**
View
2 subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
@@ -17,6 +17,7 @@
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyResourceLoader;
+import groovy.util.FileLog;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
@@ -1146,6 +1147,7 @@ private void loadRegisteredScriptExtensions() {
* @param useIndy the indy flag
*/
public void setIndy(boolean useIndy){
+ FileLog.log(useIndy, "/tmp/context.txt");
this.useIndy = useIndy;
}
View
2 subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml
@@ -18,7 +18,7 @@
<project name="Test Groovyc Task" default="test1">
<property name="srcPath" value="."/>
- <property name="destPath" value="${user.dir}/build/classes/test"/>
+ <property name="destPath" value="${user.dir}/target/classes/test"/>
<property name="javaVersion" value="5"/>
View
2 subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest1.groovy
@@ -17,6 +17,6 @@ package org.codehaus.groovy.ant
class GroovycTest1 {
static void main ( String[] args ) {
- ( new File ( 'build/classes/test/org/codehaus/groovy/ant/GroovycTest1_Result.txt' ) ).write ( 'OK.' )
+ ( new File ( 'target/classes/test/org/codehaus/groovy/ant/GroovycTest1_Result.txt' ) ).write ( 'OK.' )
}
}
View
2 subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest2.java
@@ -21,7 +21,7 @@
class GroovycTest2 {
static void main(String[] args) throws IOException {
- File f = new File("build/classes/test/org/codehaus/groovy/ant/GroovycTest2_Result.txt");
+ File f = new File("target/classes/test/org/codehaus/groovy/ant/GroovycTest2_Result.txt");
FileOutputStream fout = new FileOutputStream(f);
try {
fout.write("OK.".getBytes());
View
4 subprojects/groovy-ant/src/test/groovy/groovy/util/AntTest.groovy
@@ -36,7 +36,7 @@ class AntTest extends GroovyTestCase {
// here's an example of a block of Ant inside GroovyMarkup
ant.sequential {
echo("inside sequential")
- def myDir = "build/AntTest/"
+ def myDir = "target/AntTest/"
mkdir(dir: myDir)
copy(todir: myDir) {
fileset(dir: "src/test/groovy") {
@@ -46,7 +46,7 @@ class AntTest extends GroovyTestCase {
echo("done")
}
// now let's do some normal Groovy again
- def file = new File("build/AntTest/groovy/util/AntTest.groovy")
+ def file = new File("target/AntTest/groovy/util/AntTest.groovy")
assert file.exists()
}
View
2 subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java
@@ -34,7 +34,7 @@
* @author Russel Winder
*/
public class GroovycTest extends GroovyTestCase {
- private final String classDirectory = "build/classes/test/org/codehaus/groovy/ant/";
+ private final String classDirectory = "target/classes/test/org/codehaus/groovy/ant/";
private final File antFile = new File("src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml");
private Project project;
private static boolean warned = false;
View
8 subprojects/groovy-groovydoc/src/test-resources/groovydoc/buildWithCustomGroovyDoc.xml
@@ -1,12 +1,12 @@
<project name="CustomGroovyDocTestProject" basedir="../../../">
<property name="test" location="src/test/groovy"/>
- <property name="target" location="build"/>
+ <property name="target" location="target"/>
<property name="tmpdir" value="${java.io.tmpdir}/${user.name}/${ant.project.name}"/>
<path id="classpath">
- <fileset dir="build/classes/main" includes="**/*.*"/>
- <fileset dir="build/resources/main" includes="**/*.*"/>
- <fileset dir="build/classes/test" includes="**/*.*"/>
+ <fileset dir="target/classes/main" includes="**/*.*"/>
+ <fileset dir="target/resources/main" includes="**/*.*"/>
+ <fileset dir="target/classes/test" includes="**/*.*"/>
</path>
<taskdef name="groovydoc" classpathref="classpath"

0 comments on commit 1dd2f13

Please sign in to comment.