You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/09/23 01:57:13 UTC

svn commit: r1174458 - in /tapestry/tapestry5/trunk/tapestry-core: ./ src/main/filtered-resources/ src/main/filtered-resources/META-INF/ src/main/filtered-resources/META-INF/gradle/ src/main/filtered-resources/META-INF/gradle/org.apache.tapestry/ src/m...

Author: hlship
Date: Thu Sep 22 23:57:11 2011
New Revision: 1174458

URL: http://svn.apache.org/viewvc?rev=1174458&view=rev
Log:
Create a more efficient way of including a project property (with version number) in the output JAR

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/filtered-resources/
    tapestry/tapestry5/trunk/tapestry-core/src/main/filtered-resources/META-INF/
    tapestry/tapestry5/trunk/tapestry-core/src/main/filtered-resources/META-INF/gradle/
    tapestry/tapestry5/trunk/tapestry-core/src/main/filtered-resources/META-INF/gradle/org.apache.tapestry/
    tapestry/tapestry5/trunk/tapestry-core/src/main/filtered-resources/META-INF/gradle/org.apache.tapestry/tapestry-core/
    tapestry/tapestry5/trunk/tapestry-core/src/main/filtered-resources/META-INF/gradle/org.apache.tapestry/tapestry-core/project.properties
Modified:
    tapestry/tapestry5/trunk/tapestry-core/build.gradle

Modified: tapestry/tapestry5/trunk/tapestry-core/build.gradle
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/build.gradle?rev=1174458&r1=1174457&r2=1174458&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/build.gradle (original)
+++ tapestry/tapestry5/trunk/tapestry-core/build.gradle Thu Sep 22 23:57:11 2011
@@ -1,73 +1,61 @@
-description="Central module for Tapestry, containing all core services and components"
+import org.apache.tools.ant.filters.*
+
+description = "Central module for Tapestry, containing all core services and components"
 
 antlrSource = "src/main/antlr"
 antlrOutput = "$buildDir/generated-sources/antlr"
 
 configurations {
-  antlr3
+    antlr3
 }
 
 sourceSets.main.java.srcDir antlrOutput
 
 dependencies {
-  compile project(':tapestry-ioc')
-  compile project(':tapestry-json')
+    compile project(':tapestry-ioc')
+    compile project(':tapestry-json')
 
-  provided project(":tapestry-test")
-  provided "javax.servlet:servlet-api:$servletAPIVersion"
+    provided project(":tapestry-test")
+    provided "javax.servlet:servlet-api:$servletAPIVersion"
 
-  compile "commons-codec:commons-codec:1.3"
+    compile "commons-codec:commons-codec:1.3"
 
-  // Transitive will bring in the unwanted string template library as well
-  compile "org.antlr:antlr-runtime:3.3", { transitive = false }
+    // Transitive will bring in the unwanted string template library as well
+    compile "org.antlr:antlr-runtime:3.3", { transitive = false }
 
-  // Antlr3 tool path used with the antlr3 task
-  antlr3 "org.antlr:antlr:3.3"
+    // Antlr3 tool path used with the antlr3 task
+    antlr3 "org.antlr:antlr:3.3"
 
-  testRuntime "org.hsqldb:hsqldb:1.8.0.10"
+    testRuntime "org.hsqldb:hsqldb:1.8.0.10"
 }
 
 // This may spin out as a plugin once we've got the details down pat
 
 task generateGrammarSource {
-  description = "Generates Java sources from Antlr3 grammars."
-  inputs.dir file(antlrSource)
-  outputs.dir file(antlrOutput)
+    description = "Generates Java sources from Antlr3 grammars."
+    inputs.dir file(antlrSource)
+    outputs.dir file(antlrOutput)
 } << {
-  mkdir(antlrOutput)
-
-  // Might have a problem here if the current directory has a space in its name
+    mkdir(antlrOutput)
 
-  def grammars = fileTree(antlrSource).include("**/*.g")
+    // Might have a problem here if the current directory has a space in its name
 
-  ant.java(classname: 'org.antlr.Tool', fork: true, classpath: "${configurations.antlr3.asPath}") {
-     arg(line: "-o ${antlrOutput}/org/apache/tapestry5/internal/antlr")
-     arg(line: grammars.files.join(" "))
-  }
-}
+    def grammars = fileTree(antlrSource).include("**/*.g")
 
-task generateProjectProperties(dependsOn: compileJava) {
-  description = "Generates META-INF/gradle/org.apache.tapestry/tapestry-core/project.properties similar to Maven's pom.properties."
-  def outputDir = new File("$processResources.destinationDir/META-INF/gradle/org.apache.tapestry/tapestry-core")
-  def outputFile = new File(outputDir, 'project.properties')
-
-  outputs.dir outputDir
-
-  doLast {
-    outputDir.mkdirs()
-    outputFile << "version=${project.version}";
-    println "Generating $outputFile"
-  }
+    ant.java(classname: 'org.antlr.Tool', fork: true, classpath: "${configurations.antlr3.asPath}") {
+        arg(line: "-o ${antlrOutput}/org/apache/tapestry5/internal/antlr")
+        arg(line: grammars.files.join(" "))
+    }
 }
 
 ideaModule.doFirst {
-  excludeDirs -= buildDir
+    excludeDirs -= buildDir
 
-  def generatedDir = file("$buildDir/generated-sources")
+    def generatedDir = file("$buildDir/generated-sources")
 
-  def buildMinusGeneratedDir = (buildDir.listFiles() - generatedDir) as Set<File>
+    def buildMinusGeneratedDir = (buildDir.listFiles() - generatedDir) as Set<File>
 
-  excludeDirs += buildMinusGeneratedDir
+    excludeDirs += buildMinusGeneratedDir
 }
 
 compileJava.options.fork(memoryMaximumSize: '512m')
@@ -76,4 +64,8 @@ compileJava.dependsOn generateGrammarSou
 // Not sure why this is necessary:
 compileTestGroovy.dependsOn compileTestJava
 
-jar.dependsOn generateProjectProperties
+jar {
+    from("src/main/filtered-resources") {
+        filter(ReplaceTokens, tokens: [version: project.version])
+    }
+}

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/filtered-resources/META-INF/gradle/org.apache.tapestry/tapestry-core/project.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/filtered-resources/META-INF/gradle/org.apache.tapestry/tapestry-core/project.properties?rev=1174458&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/filtered-resources/META-INF/gradle/org.apache.tapestry/tapestry-core/project.properties (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/filtered-resources/META-INF/gradle/org.apache.tapestry/tapestry-core/project.properties Thu Sep 22 23:57:11 2011
@@ -0,0 +1 @@
+version=@version@