Skip to content
Browse files

Impose a more traditional formatting to the source code. Update the I…

…ntelliJ IDEA project.
  • Loading branch information...
1 parent 38fd8a9 commit 277b6374b8371499a20394e6cce34e01d6f333cb @russel russel committed Jan 6, 2013
Showing with 3,546 additions and 3,558 deletions.
  1. +5 −37 Gant.ipr
  2. +206 −206 build.gradle
  3. +10 −10 examples/ivy/build.gant
  4. +7 −7 examples/ivy/source/example/Hello.java
  5. +15 −15 examples/testScripts/explicitClean.gant
  6. +12 −12 examples/testScripts/gantClean.gant
  7. +44 −44 packaging/AntDebTask/build.gant
  8. +1 −1 packaging/AntDebTask/gant
  9. +1 −1 scripts/bash_completion.d/gant
  10. +5 −5 scripts/bin_requiresGroovy/gant
  11. +5 −5 scripts/bin_standalone/gant
  12. +4 −4 scripts/conf/gant-starter.conf
  13. +3 −3 settings.gradle
  14. +252 −246 src/main/groovy/gant/Gant.groovy
  15. +9 −9 src/main/groovy/gant/GantException.java
  16. +7 −7 src/main/groovy/gant/MissingTargetException.java
  17. +8 −8 src/main/groovy/gant/TargetExecutionException.java
  18. +9 −9 src/main/groovy/gant/TargetMissingPropertyException.java
  19. +23 −23 src/main/groovy/gant/targets/Clean.groovy
  20. +231 −231 src/main/groovy/gant/targets/Maven.groovy
  21. +16 −16 src/main/groovy/gant/tools/AntFile.groovy
  22. +32 −32 src/main/groovy/gant/tools/Execute.groovy
  23. +10 −10 src/main/groovy/gant/tools/Ivy.groovy
  24. +68 −68 src/main/groovy/gant/tools/LaTeX.groovy
  25. +15 −15 src/main/groovy/gant/tools/Subdirectories.groovy
  26. +32 −32 src/main/groovy/org/codehaus/gant/AbstractInclude.groovy
  27. +149 −149 src/main/groovy/org/codehaus/gant/GantBinding.groovy
  28. +38 −38 src/main/groovy/org/codehaus/gant/GantBuilder.java
  29. +8 −8 src/main/groovy/org/codehaus/gant/GantEvent.groovy
  30. +63 −63 src/main/groovy/org/codehaus/gant/GantMetaClass.java
  31. +13 −13 src/main/groovy/org/codehaus/gant/GantState.java
  32. +22 −22 src/main/groovy/org/codehaus/gant/IncludeTargets.groovy
  33. +32 −32 src/main/groovy/org/codehaus/gant/IncludeTool.groovy
  34. +77 −77 src/main/groovy/org/codehaus/gant/ant/Gant.java
  35. +53 −53 src/test/groovy/gant/targets/tests/Clean_Test.groovy
  36. +73 −73 src/test/groovy/gant/targets/tests/Maven_Test.groovy
  37. +37 −37 src/test/groovy/gant/tools/tests/AntFile_Test.groovy
  38. +38 −38 src/test/groovy/gant/tools/tests/Execute_Test.groovy
  39. +81 −81 src/test/groovy/gant/tools/tests/LaTeX_Test.groovy
  40. +73 −73 src/test/groovy/org/codehaus/gant/ant/tests/Gant_Test.java
  41. +23 −23 src/test/groovy/org/codehaus/gant/ant/tests/build.gant
  42. +27 −27 src/test/groovy/org/codehaus/gant/tests/BuildListener_Test.groovy
  43. +16 −16 src/test/groovy/org/codehaus/gant/tests/CallPrint_Test.groovy
  44. +7 −7 src/test/groovy/org/codehaus/gant/tests/CommentAccess_Test.groovy
  45. +12 −12 src/test/groovy/org/codehaus/gant/tests/CustomClassLoader_Test.groovy
  46. +189 −189 src/test/groovy/org/codehaus/gant/tests/Depends_Test.groovy
  47. +21 −21 src/test/groovy/org/codehaus/gant/tests/DryRun_Test.groovy
  48. +61 −61 src/test/groovy/org/codehaus/gant/tests/ExecutingTargets_Test.groovy
  49. +160 −160 src/test/groovy/org/codehaus/gant/tests/GantBinding_Test.groovy
  50. +12 −12 src/test/groovy/org/codehaus/gant/tests/GantBuilder_Test.groovy
  51. +89 −89 src/test/groovy/org/codehaus/gant/tests/GantTestCase.java
  52. +107 −107 src/test/groovy/org/codehaus/gant/tests/Hooks_Test.groovy
  53. +330 −330 src/test/groovy/org/codehaus/gant/tests/Include_Test.groovy
  54. +117 −117 src/test/groovy/org/codehaus/gant/tests/ListingTargets_Test.groovy
  55. +54 −54 src/test/groovy/org/codehaus/gant/tests/NoAntObject_Test.groovy
  56. +16 −16 src/test/groovy/org/codehaus/gant/tests/Options_Test.groovy
  57. +23 −23 src/test/groovy/org/codehaus/gant/tests/ReturnValue_Test.groovy
  58. +35 −35 src/test/groovy/org/codehaus/gant/tests/SubGant_Test.groovy
  59. +23 −23 src/test/groovy/org/codehaus/gant/tests/TargetMetaClassLookup_Test.groovy
  60. +135 −135 src/test/groovy/org/codehaus/gant/tests/Targets_Test.groovy
  61. +25 −25 src/test/groovy/org/codehaus/gant/tests/ToolMetaClassLookup_Test.groovy
  62. +1 −1 src/test/groovy/org/codehaus/gant/tests/XMLProcessing_Test.groovy
  63. +84 −84 src/test/groovy/org/codehaus/gant/tests/bugs/Assorted_Test.groovy
  64. +60 −60 src/test/groovy/org/codehaus/gant/tests/bugs/GANT_108_Test.groovy
  65. +47 −47 src/test/groovy/org/codehaus/gant/tests/bugs/GANT_33_Test.groovy
  66. +38 −38 src/test/groovy/org/codehaus/gant/tests/bugs/GANT_4_Test.groovy
  67. +29 −29 src/test/groovy/org/codehaus/gant/tests/bugs/Regression_1_9_4_Test.groovy
  68. +18 −4 src/test/groovy/org/codehaus/gant/tests/bugs/subPackage/GANT_29_SampleTool.groovy
View
42 Gant.ipr
@@ -558,7 +558,6 @@
<inspection_tool class="DoubleCheckedLocking" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreOnVolatileVariables" value="false" />
</inspection_tool>
- <inspection_tool class="DoubleNegation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="DriverManagerGetConnection" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="DuplicateBooleanBranch" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="DuplicateCondition" enabled="true" level="WARNING" enabled_by_default="true">
@@ -835,11 +834,7 @@
<inspection_tool class="LoopWithImplicitTerminationCondition" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="LossyEncoding" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MagicCharacter" enabled="true" level="WARNING" enabled_by_default="true" />
- <inspection_tool class="MagicNumber" enabled="true" level="WARNING" enabled_by_default="true">
- <option name="ignoreInHashCode" value="true" />
- <option name="ignoreInTestCode" value="false" />
- <option name="ignoreInAnnotations" value="true" />
- </inspection_tool>
+ <inspection_tool class="MagicNumber" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MapReplaceableByEnumMap" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MarkerInterface" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MethodCount" enabled="true" level="WARNING" enabled_by_default="true">
@@ -978,6 +973,7 @@
<inspection_tool class="PackageVisibleField" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PackageVisibleInnerClass" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreEnums" value="false" />
+ <option name="ignoreInterfaces" value="false" />
</inspection_tool>
<inspection_tool class="PackageWithTooFewClasses" enabled="true" level="WARNING" enabled_by_default="true">
<option name="limit" value="3" />
@@ -1011,6 +1007,7 @@
<inspection_tool class="PointlessIndexOfComparison" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ProtectedInnerClass" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreEnums" value="false" />
+ <option name="ignoreInterfaces" value="false" />
</inspection_tool>
<inspection_tool class="ProtectedMemberInFinalClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PublicField" enabled="true" level="WARNING" enabled_by_default="true">
@@ -1039,11 +1036,7 @@
<option name="SAFARI" value="true" />
</inspection_tool>
<inspection_tool class="RandomDoubleForRandomInteger" enabled="true" level="WARNING" enabled_by_default="true" />
- <inspection_tool class="RawUseOfParameterizedType" enabled="true" level="WARNING" enabled_by_default="true">
- <option name="ignoreObjectConstruction" value="true" />
- <option name="ignoreTypeCasts" value="false" />
- <option name="ignoreUncompilable" value="false" />
- </inspection_tool>
+ <inspection_tool class="RawUseOfParameterizedType" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ReadObjectAndWriteObjectPrivate" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ReadObjectInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ReadResolveAndWriteReplaceProtected" enabled="true" level="WARNING" enabled_by_default="true" />
@@ -1220,10 +1213,7 @@
<inspection_tool class="TimeToString" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ToArrayCallWithZeroLengthArrayArgument" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="TodoComment" enabled="true" level="WARNING" enabled_by_default="true" />
- <inspection_tool class="TooBroadCatch" enabled="true" level="WARNING" enabled_by_default="true">
- <option name="onlyWarnOnRootExceptions" value="false" />
- <option name="ignoreInTestCode" value="false" />
- </inspection_tool>
+ <inspection_tool class="TooBroadCatch" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="TooBroadScope" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_allowConstructorAsInitializer" value="false" />
<option name="m_onlyLookAtBlocks" value="false" />
@@ -1360,28 +1350,6 @@
</list>
</option>
</component>
- <component name="NullableNotNullManager">
- <option name="myDefaultNullable" value="org.jetbrains.annotations.Nullable" />
- <option name="myDefaultNotNull" value="org.jetbrains.annotations.NotNull" />
- <option name="myNullables">
- <value>
- <list size="3">
- <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
- <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
- <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
- </list>
- </value>
- </option>
- <option name="myNotNulls">
- <value>
- <list size="3">
- <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
- <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
- <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
- </list>
- </value>
- </option>
- </component>
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
View
412 build.gradle
@@ -2,7 +2,7 @@
// Gant -- A Groovy way of scripting Ant tasks.
//
-// Copyright © 2008–2012 Russel Winder
+// Copyright © 2008–2013 Russel Winder
//
// 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
@@ -14,7 +14,7 @@
// implied. See the License for the specific language governing permissions and limitations under the
// License.
//
-// Author : Russel Winder <russel@winder.org.uk>
+// Author: Russel Winder <russel@winder.org.uk>
import org.apache.tools.ant.filters.ReplaceTokens
@@ -26,13 +26,13 @@ ext.mavenNameExtension = '_groovy'
* OSGi bundle numbers is fixed and slightly different to the expected grammar for version numbers and Maven
* artefacts:
*
- * version ::= major('.'minor('.'micro('.'qualifier)?)?)?
- * major ::= digit+
- * minor ::= digit+
- * micro ::= digit+
- * qualifier ::= (alpha|digit|'_'|'-')+
- * digit ::= [0..9]
- * alpha ::= [a..zA..Z]
+ * version::= major('.'minor('.'micro('.'qualifier)?)?)?
+ * major::= digit+
+ * minor::= digit+
+ * micro::= digit+
+ * qualifier::= (alpha|digit|'_'|'-')+
+ * digit::= [0..9]
+ * alpha::= [a..zA..Z]
*
* The core difference is that for OSGi bundle numbers the qualifier is separated by a full stop where in
* other situations a minus is used.
@@ -41,7 +41,7 @@ final gantVersionBase = '1.9.9'
final isPrereleaseSnapshot = true
final createVersionString = { isForOSGi ->
- return gantVersionBase + ( isPrereleaseSnapshot ? ( isForOSGi ? '.' : '-' ) + 'SNAPSHOT' : '' )
+ return gantVersionBase + (isPrereleaseSnapshot ? (isForOSGi ? '.': '-') + 'SNAPSHOT': '')
}
final debPackagingNumber = '1'
@@ -55,8 +55,8 @@ final gantBundleVersion = createVersionString true
final groovyArtefactName = 'groovy-all'
ext.groovyVersions = [
- '1.8' : '1.8.8' ,
- '2.0' : '2.0.6' ,
+ '1.8': '1.8.8',
+ '2.0': '2.0.6',
]
// One series of Groovy needs using for the standalone distribution. This version of Groovy will be packaged with
@@ -71,30 +71,30 @@ final groovyStandaloneSeries = '2.0'
// subproject has its own source, etc. This build slightly perverts the general approach by using exactly
// the same source for each subproject, the only difference is the version of Groovy used for compilation.
-def forEachDistributionVersion ( Closure c ) {
- for ( String s : groovyVersions.keySet ( ) ) { c ( artifact + mavenNameExtension + s ) }
+def forEachDistributionVersion(Closure c) {
+ for (String s: groovyVersions.keySet()) { c(artifact + mavenNameExtension + s) }
}
-def forEachProject ( Closure c ) {
+def forEachProject(Closure c) {
c artifact
forEachDistributionVersion c
}
-forEachProject { item -> if ( ! ( new File ( item ) ).isDirectory ( ) ) { mkdir item } }
+forEachProject { item -> if (!(new File(item)).isDirectory()) { mkdir item } }
ext.distributionTasks = [ ]
ext.debTasks = [ ]
// Using the JackRabbit wagon gets round some problems associated with uploading the distributions that
// occurs with the standard wagon. However, it does not solve the problem of not creating missing
// directories that gives difficulties with new artefact uploads. Have to cadaver in and create the
-// hierarchy first :-(
+// hierarchy first:-(
//webdavWagonName = 'org.apache.maven.wagon:wagon-webdav-jackrabbit:2.2'
//webdavWagonName = 'org.apache.maven.wagon:wagon-webdav:1.0-beta-2'
// Try the lightweight HTTP wagon. Still requires creating the directory structure with cadaver or
-// equivalent :-(
+// equivalent:-(
final webdavWagonName = 'org.apache.maven.wagon:wagon-http-lightweight:2.2'
@@ -117,13 +117,13 @@ allprojects {
}
final signingPropertiesAreSet = {
- project.hasProperty ( 'signing.keyId' ) && project.hasProperty ( 'signing.password' ) && project.hasProperty ( 'signing.secretKeyRingFile' )
+ project.hasProperty('signing.keyId') && project.hasProperty('signing.password') && project.hasProperty('signing.secretKeyRingFile')
}
subprojects {
- apply plugin : 'groovy'
- apply plugin : 'osgi'
- if ( signingPropertiesAreSet ( ) ) { apply plugin : 'signing' }
+ apply plugin: 'groovy'
+ apply plugin: 'osgi'
+ if (signingPropertiesAreSet()) { apply plugin: 'signing' }
sourceCompatibility = 6
targetCompatibility = 6
configurations { deployJars }
@@ -134,49 +134,49 @@ subprojects {
test { groovy { srcDir '../src/test/groovy' } }
integTest { groovy { srcDir '../src/integTest/groovy' } }
}
- metaInf << fileTree ( dir : '..' ).matching { include 'LICENCE.txt' }
+ metaInf << fileTree(dir: '..').matching { include 'LICENCE.txt' }
final theVendor = 'The Codehaus'
final theTitle = 'Gant: Scripting Ant tasks with Groovy.'
jar {
manifest {
name = 'Gant'
version = gantBundleVersion
symbolicName = 'gant'
- instruction 'Bundle-Vendor' , theVendor
- instruction 'Bundle-Description' , group
- instruction 'Bundle-DocURL' , 'http://gant.codehaus.org'
- instruction 'Built-By' , System.properties.'user.name'
- instruction 'Extension-Name' , artifact
- instruction 'Specification-Title' , theTitle
- instruction 'Specification-Version' , gantBundleVersion
- instruction 'Specification-Vendor' , theVendor
- instruction 'Implementation-Title' , theTitle
- instruction 'Implementation-Version' , gantBundleVersion
- instruction 'Implementation-Vendor' , theVendor
- instruction 'provider' , theVendor
- instruction 'Export-Package' , "*;version=${gantVersion}"
+ instruction 'Bundle-Vendor', theVendor
+ instruction 'Bundle-Description', group
+ instruction 'Bundle-DocURL', 'http://gant.codehaus.org'
+ instruction 'Built-By', System.properties.'user.name'
+ instruction 'Extension-Name', artifact
+ instruction 'Specification-Title', theTitle
+ instruction 'Specification-Version', gantBundleVersion
+ instruction 'Specification-Vendor', theVendor
+ instruction 'Implementation-Title', theTitle
+ instruction 'Implementation-Version', gantBundleVersion
+ instruction 'Implementation-Vendor', theVendor
+ instruction 'provider', theVendor
+ instruction 'Export-Package', "*;version=${gantVersion}"
instruction 'Import-Package', '*;resolution:=optional'
}
}
repositories {
- if ( project.hasProperty ( 'gant_useMavenLocal' ) && gant_useMavenLocal ) { mavenLocal ( ) }
- mavenCentral ( )
+ if (project.hasProperty('gant_useMavenLocal') && gant_useMavenLocal) { mavenLocal() }
+ mavenCentral()
maven { url 'http://repository.codehaus.org/' }
}
dependencies {
compile (
- 'commons-cli:commons-cli:1.2' ,
+ 'commons-cli:commons-cli:1.2',
'org.apache.ant:ant:1.8.4'
- )
+ )
testCompile 'junit:junit:4.10'
testRuntime 'org.apache.ivy:ivy:2.2.0'
deployJars webdavWagonName
}
compileGroovy.options.compilerArgs = [ '-Xlint' ]
- [ compileGroovy , compileTestGroovy ]*.options*.encoding = 'UTF-8'
+ [ compileGroovy, compileTestGroovy ]*.options*.encoding = 'UTF-8'
test {
//
- // The Gant Ant task integration test (which is still a unit test :-( has to know the absolute
+ // The Gant Ant task integration test (which is still a unit test:-(has to know the absolute
// locations of certain files. Because Gradle uses a multi-project build there is an extra level
// complexity in paths compared to Eclipse, IntelliJ IDEA or Gant builds because the multi-project
// builds happen in subdirectories. org.codehaus.gant.ant.tests.Gant_Test has a decision to make, it
@@ -185,22 +185,22 @@ subprojects {
systemProperties['buildFrameworkIdentifier'] = 'Gradle'
}
clean.doLast {
- delete 'texput.log' , 'target_forMavenTest'
+ delete 'texput.log', 'target_forMavenTest'
}
- task integTest ( type : Test , dependsOn : /* 'assemble' */ 'classes' ) {
- include file ( 'src/integTest/groovy' ).absolutePath + '/org/codehaus/gant/ant/tests/*_Test.*'
+ task integTest(type: Test, dependsOn: /* 'assemble' */ 'classes') {
+ include file('src/integTest/groovy').absolutePath + '/org/codehaus/gant/ant/tests/*_Test.*'
}
- if ( signingPropertiesAreSet ( ) ) {
+ if (signingPropertiesAreSet()) {
signing {
sign configurations.archives
}
}
final packageTitle = 'Gant ' + gantVersion
- final copyrightString = 'Copyright &#169; 2006&#8211;12 The Codehaus. All Rights Reserved.'
+ final copyrightString = 'Copyright &#169; 2006&#8211;2013 The Codehaus. All Rights Reserved.'
javadoc {
options {
overview 'overview.html'
- showAll ( )
+ showAll()
encoding 'UTF-8'
setUse true
author true
@@ -223,24 +223,24 @@ subprojects {
header = packageTitle
footer = copyrightString
}
- task documentation ( dependsOn: [ 'javadoc' , 'groovydoc' ] , description : 'Create the API documentation.' )
- final docsJarsDir = new File ( buildDir , docsJarsDirName )
- task javadocArtifact ( type : Jar , dependsOn : 'javadoc' ) {
+ task documentation(dependsOn: [ 'javadoc', 'groovydoc' ], description: 'Create the API documentation.')
+ final docsJarsDir = new File(buildDir, docsJarsDirName)
+ task javadocArtifact(type: Jar, dependsOn: 'javadoc') {
classifier = 'javadoc'
from docsDir
}
javadocArtifact.destinationDir = docsJarsDir
- task groovydocArtifact ( type : Jar , dependsOn : 'groovydoc' ) {
+ task groovydocArtifact(type: Jar, dependsOn: 'groovydoc') {
classifier = 'groovydoc'
from docsDir
}
groovydocArtifact.destinationDir = docsJarsDir
- task sourceArtifact ( type : Jar ) {
+ task sourceArtifact(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
sourceArtifact.destinationDir = docsJarsDir
- task allArtifacts ( dependsOn : [ jar , javadocArtifact , groovydocArtifact , sourceArtifact ] )
+ task allArtifacts(dependsOn: [ jar, javadocArtifact, groovydocArtifact, sourceArtifact ])
artifacts {
archives javadocArtifact
archives groovydocArtifact
@@ -254,64 +254,64 @@ subprojects {
// Use the locally installed Groovy or the standalone version from the Maven repository. This subproject
// is used for local installation and also for generating the documentation.
-project ( ':gant' ) {
+project(':gant') {
// If the user has GROOVY_HOME set then use that Groovy rather than the one specified in the properties
// files. However we have to fiddle to find the version number.
- final groovyHome = System.getenv ( ).'GROOVY_HOME'
+ final groovyHome = System.getenv().'GROOVY_HOME'
final groovyLib = null
def groovyVersion
def versionMessage
- if ( groovyHome ) {
- groovyLib = new File ( groovyHome , 'lib' )
+ if (groovyHome) {
+ groovyLib = new File(groovyHome, 'lib')
final groovyVersionPatternString = /^groovy-(all-)?([0-9].*)\.jar/
- final items = groovyLib.listFiles ( [ accept : { File dir , String name -> return ( name =~ groovyVersionPatternString ).find ( ) } ] as FilenameFilter )
+ final items = groovyLib.listFiles([ accept: { File dir, String name -> return (name =~ groovyVersionPatternString).find() } ] as FilenameFilter)
assert items
- groovyVersion = ( items[0].name =~ groovyVersionPatternString )[0][2]
+ groovyVersion = (items[0].name =~ groovyVersionPatternString)[0][2]
assert groovyVersion
- repositories { flatDir ( name : 'groovyInstallation' , dirs : [ new File ( groovyHome , 'embeddable' ) , groovyLib ] ) }
+ repositories { flatDir(name: 'groovyInstallation', dirs: [ new File(groovyHome, 'embeddable'), groovyLib ]) }
versionMessage = 'Using Groovy version ' + groovyVersion + ' from ' + groovyHome
}
else {
groovyVersion = groovyVersions[groovyStandaloneSeries]
versionMessage = 'Using Groovy version ' + groovyVersion
}
- dependencies { groovy ( group : 'org.codehaus.groovy' , name : groovyArtefactName , version : groovyVersion ) }
- compileGroovy.doFirst { println ( '\n\t' + versionMessage +'\n' ) }
- final buildPath = [ System.properties.'user.dir' , 'gant' , 'build' , 'classes' ]
+ dependencies { groovy(group: 'org.codehaus.groovy', name: groovyArtefactName, version: groovyVersion) }
+ compileGroovy.doFirst { println('\n\t' + versionMessage +'\n') }
+ final buildPath = [ System.properties.'user.dir', 'gant', 'build', 'classes' ]
final classPath = [ ]
- classPath << ( buildPath + [ 'main' ] ).join ( File.separator )
- classPath << ( buildPath + [ 'test' ] ).join ( File.separator )
+ classPath << (buildPath + [ 'main' ]).join(File.separator)
+ classPath << (buildPath + [ 'test' ]).join(File.separator)
configurations.testRuntime.files.each { file -> classPath << file.parent }
- test.environment ( [
- GROOVY_ANT_TASK_TEST_VERSION : groovyVersion ,
- gradleClasspathString : classPath.join ( System.properties.'path.separator' )
- ] )
+ test.environment([
+ GROOVY_ANT_TASK_TEST_VERSION: groovyVersion,
+ gradleClasspathString: classPath.join(System.properties.'path.separator')
+ ])
final installDirectory = '/usr/share/gant'
- try { installDirectory = evaluate ( '"' + gant_installPath + '"' ) }
- catch ( MissingPropertyException mpe ) { /* Intentionally left blank. */ }
- task install ( dependsOn : 'assemble' , description : "Install Gant (compiled against Groovy ${groovyVersion}) to ${installDirectory}." ) << {
+ try { installDirectory = evaluate('"' + gant_installPath + '"') }
+ catch (MissingPropertyException mpe) { /* Intentionally left blank. */ }
+ task install(dependsOn: 'assemble', description: "Install Gant (compiled against Groovy ${groovyVersion}) to ${installDirectory}.") << {
delete installDirectory
final installBinDirectory = installDirectory + '/bin'
final scriptsDirectory = '../scripts'
copy {
into installBinDirectory
- from ( [ scriptsDirectory + '/bin' , scriptsDirectory + '/bin_requiresGroovy' ] )
- filter ReplaceTokens , tokens : [
- GROOVYPATH : 'embeddable' ,
- GROOVYJAR : groovyArtefactName + '-' + groovyVersion + '.jar'
+ from([ scriptsDirectory + '/bin', scriptsDirectory + '/bin_requiresGroovy' ])
+ filter ReplaceTokens, tokens: [
+ GROOVYPATH: 'embeddable',
+ GROOVYJAR: groovyArtefactName + '-' + groovyVersion + '.jar'
]
}
- ant.chmod ( perm : 'a+x' ) { fileset ( dir : installBinDirectory , includes : 'gant*' ) }
+ ant.chmod(perm: 'a+x') { fileset(dir: installBinDirectory, includes: 'gant*') }
copy {
into installDirectory + '/conf'
from scriptsDirectory + '/conf/gant-starter.conf'
}
copy {
into installDirectory + '/lib'
- from new File ( buildDir , 'libs' )
+ from new File(buildDir, 'libs')
}
}
- task uninstall ( type: Delete , description : "Delete ${installDirectory} so as to remove the Gant installation." ) { delete installDirectory }
+ task uninstall(type: Delete, description: "Delete ${installDirectory} so as to remove the Gant installation.") { delete installDirectory }
}
// =====================================================================
@@ -345,45 +345,45 @@ final pomSpecification = {
}
forEachDistributionVersion { projectName->
- final groovyVersion = groovyVersions[ projectName.replace ( artifact + mavenNameExtension , '' ) ]
- project ( projectName ) {
- apply plugin : 'maven'
- dependencies { groovy ( group : 'org.codehaus.groovy' , name : groovyArtefactName , version : groovyVersion ) }
- compileGroovy.doFirst { println ( '\n\tUsing Groovy version ' + groovyVersion + '\n' ) }
- final buildPath = [ System.properties.'user.dir' , projectName , 'build' , 'classes' ]
+ final groovyVersion = groovyVersions[ projectName.replace(artifact + mavenNameExtension, '') ]
+ project(projectName) {
+ apply plugin: 'maven'
+ dependencies { groovy(group: 'org.codehaus.groovy', name: groovyArtefactName, version: groovyVersion) }
+ compileGroovy.doFirst { println('\n\tUsing Groovy version ' + groovyVersion + '\n') }
+ final buildPath = [ System.properties.'user.dir', projectName, 'build', 'classes' ]
final classPath = [ ]
- classPath << ( buildPath + [ 'main' ] ).join ( File.separator )
- classPath << ( buildPath + [ 'test' ] ).join ( File.separator )
+ classPath << (buildPath + [ 'main' ]).join(File.separator)
+ classPath << (buildPath + [ 'test' ]).join(File.separator)
configurations.testRuntime.files.each { file -> classPath << file.parent }
- test.environment ( [
- GROOVY_ANT_TASK_TEST_VERSION : groovyVersion ,
- gradleClasspathString : classPath.join ( System.properties.'path.separator' )
- ] )
+ test.environment([
+ GROOVY_ANT_TASK_TEST_VERSION: groovyVersion,
+ gradleClasspathString: classPath.join(System.properties.'path.separator')
+ ])
install.repositories.mavenInstaller { pom pomSpecification }
gradle.taskGraph.whenReady { taskGraph ->
- if ( taskGraph.hasTask ( uploadArchives ) ) {
- if ( ! project.hasProperty ( 'gant_experimentalMavenRepository' ) && ! ( project.hasProperty ( 'codehausUsername') && project.hasProperty ( 'codehausPassword' ) ) ) {
- throw new RuntimeException ( 'Must define both codehausUsername and codehausPassword to upload archives.')
+ if (taskGraph.hasTask(uploadArchives)) {
+ if (! project.hasProperty('gant_experimentalMavenRepository') && !(project.hasProperty('codehausUsername') && project.hasProperty('codehausPassword'))) {
+ throw new RuntimeException('Must define both codehausUsername and codehausPassword to upload archives.')
}
- if ( ! signingPropertiesAreSet ( ) ) {
- throw new RuntimeException ( 'Must define signing.keyId, signing.password, and signing.secretKeyRingFile' )
+ if (! signingPropertiesAreSet()) {
+ throw new RuntimeException('Must define signing.keyId, signing.password, and signing.secretKeyRingFile')
}
uploadArchives.repositories.mavenDeployer {
uniqueVersion = false
configuration = configurations.deployJars
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
- if ( project.hasProperty ( 'gant_experimentalMavenRepository' ) ) {
- if ( ! gant_experimentalMavenRepository ) { throw new RuntimeException ( 'gant_experimentalMavenRepository value not reasonable.' ) }
- repository url : "file://${rootProject.buildDir}/${gant_experimentalMavenRepository}"
+ if (project.hasProperty('gant_experimentalMavenRepository')) {
+ if (! gant_experimentalMavenRepository) { throw new RuntimeException('gant_experimentalMavenRepository value not reasonable.') }
+ repository url: "file://${rootProject.buildDir}/${gant_experimentalMavenRepository}"
} else {
- //repository ( url : 'dav:https://dav.codehaus.org/repository/gant/' ) {
- repository ( url : 'https://dav.codehaus.org/repository/gant/' ) {
- authentication userName : codehausUsername , password : codehausPassword
+ //repository(url: 'dav:https://dav.codehaus.org/repository/gant/') {
+ repository(url: 'https://dav.codehaus.org/repository/gant/') {
+ authentication userName: codehausUsername, password: codehausPassword
}
- //snapshotRepository ( url : 'dav:https://dav.codehaus.org/snapshots.repository/gant/' ) {
- snapshotRepository ( url : 'https://dav.codehaus.org/snapshots.repository/gant/' ) {
- authentication userName: codehausUsername , password : codehausPassword
+ //snapshotRepository(url: 'dav:https://dav.codehaus.org/snapshots.repository/gant/') {
+ snapshotRepository(url: 'https://dav.codehaus.org/snapshots.repository/gant/') {
+ authentication userName: codehausUsername, password: codehausPassword
}
}
pom pomSpecification
@@ -392,37 +392,37 @@ forEachDistributionVersion { projectName->
}
final binCopySpec = copySpec {
final scriptsDirectory = '../scripts'
- from ( '..' ) { include 'README*' }
- into ( 'conf' ) { from ( scriptsDirectory + '/conf' ) { include '*.conf' } }
- into ( 'lib' ) {
+ from('..') { include 'README*' }
+ into('conf') { from(scriptsDirectory + '/conf') { include '*.conf' } }
+ into('lib') {
from libsDir
- rename projectName + '-' + version , artifact + '-' + version + mavenNameExtension + '-' + groovyVersion
+ rename projectName + '-' + version, artifact + '-' + version + mavenNameExtension + '-' + groovyVersion
}
- into ( 'bin' ) {
+ into('bin') {
fileMode = 0755
- from ( [ scriptsDirectory + '/bin' , scriptsDirectory + '/bin_requiresGroovy' ] )
- filter ReplaceTokens , tokens : [
- GROOVYPATH : 'embeddable' ,
- GROOVYJAR : groovyArtefactName + '-' + groovyVersion + '.jar'
+ from([ scriptsDirectory + '/bin', scriptsDirectory + '/bin_requiresGroovy' ])
+ filter ReplaceTokens, tokens: [
+ GROOVYPATH: 'embeddable',
+ GROOVYJAR: groovyArtefactName + '-' + groovyVersion + '.jar'
]
}
}
- task binTgz ( type : Tar , dependsOn : 'jar' , description : 'Build the distribution tarball.' ) {
+ task binTgz(type: Tar, dependsOn: 'jar', description: 'Build the distribution tarball.') {
baseName = artifact
classifier = mavenNameExtension + '-' + groovyVersion
compression = Compression.GZIP
- into ( gantPrefix ) { with binCopySpec }
+ into(gantPrefix) { with binCopySpec }
}
- task binZip ( type : Zip , dependsOn : 'jar' , description : 'Build the distribution zip file.' ) {
+ task binZip(type: Zip, dependsOn: 'jar', description: 'Build the distribution zip file.') {
baseName = artifact
classifier = mavenNameExtension + '-' + groovyVersion
- into ( gantPrefix ) { with binCopySpec }
+ into(gantPrefix) { with binCopySpec }
}
- distributionTasks += [ binTgz , binZip ]
+ distributionTasks += [ binTgz, binZip ]
}
// Due to weird effective scoping of projects -- caused by cloning of bindings for projects? -- need to
// do the following to get the above tasks into the list defined by the main script.
- distributionTasks += project ( projectName ).distributionTasks
+ distributionTasks += project(projectName).distributionTasks
ciBuildTasks << projectName + ':build'
}
@@ -435,57 +435,57 @@ final projectNameForStandalone = 'gant_groovy' + groovyStandaloneSeries
final standaloneCopySpec = copySpec {
final scriptsDirectory = 'scripts'
final projectBase = project projectNameForStandalone
- from ( '.' ) { include 'README*' }
- into ( 'conf' ) { from ( scriptsDirectory + '/conf' ) { include '*.conf' } }
- into ( 'lib' ) {
+ from('.') { include 'README*' }
+ into('conf') { from(scriptsDirectory + '/conf') { include '*.conf' } }
+ into('lib') {
from projectBase.libsDir
from projectBase.configurations.runtime
}
- into ( 'bin' ) {
+ into('bin') {
fileMode = 0755
- from ( [ scriptsDirectory + '/bin' , scriptsDirectory + '/bin_standalone' ] )
- filter ReplaceTokens , tokens : [
- GROOVYPATH : 'lib' ,
- GROOVYJAR : groovyArtefactName + '-' + groovyVersions[groovyStandaloneSeries] + '.jar'
+ from([ scriptsDirectory + '/bin', scriptsDirectory + '/bin_standalone' ])
+ filter ReplaceTokens, tokens: [
+ GROOVYPATH: 'lib',
+ GROOVYJAR: groovyArtefactName + '-' + groovyVersions[groovyStandaloneSeries] + '.jar'
]
}
}
-task standaloneBinTgz ( type : Tar , dependsOn : projectNameForStandalone + ':jar' , description : 'Create a tarball of the standalone distribution.' ) {
+task standaloneBinTgz(type: Tar, dependsOn: projectNameForStandalone + ':jar', description: 'Create a tarball of the standalone distribution.') {
baseName = artifact
version = gantVersion
compression = Compression.GZIP
destinationDir = buildDir
- into ( gantPrefix ) { with standaloneCopySpec }
+ into(gantPrefix) { with standaloneCopySpec }
}
-task standaloneBinZip ( type : Zip , dependsOn : projectNameForStandalone + ':jar' , description : 'Create a zip file of the standalone distribution.' ) {
+task standaloneBinZip(type: Zip, dependsOn: projectNameForStandalone + ':jar', description: 'Create a zip file of the standalone distribution.') {
baseName = artifact
version = gantVersion
destinationDir = buildDir
- into ( gantPrefix ) { with standaloneCopySpec }
+ into(gantPrefix) { with standaloneCopySpec }
}
-distributionTasks += [ standaloneBinTgz , standaloneBinZip ]
+distributionTasks += [ standaloneBinTgz, standaloneBinZip ]
// =====================================================================
//
// Create the deb file of the standalone distribution.
-final debsDirectory = new File ( buildDir , 'debs' )
-final distDirectory = new File ( buildDir , 'dist' )
+final debsDirectory = new File(buildDir, 'debs')
+final distDirectory = new File(buildDir, 'dist')
-task clean ( type: Delete ) {
+task clean(type: Delete) {
delete debsDirectory
delete distDirectory
}
-task standaloneDeb ( dependsOn : standaloneBinTgz , description : 'Create a deb for use with Debian and Ubuntu.' ) << {
+task standaloneDeb(dependsOn: standaloneBinTgz, description: 'Create a deb for use with Debian and Ubuntu.') << {
final packageName = 'gant-standalone'
final architecture = 'all'
final createdDebFileName = packageName + '_' + gantVersion + '-' + debPackagingNumber + '_' + architecture + '.deb'
final installPrefixBase = 'usr/share/gant'
- final expandDirectory = ( new File ( distDirectory , 'gant-' + gantVersion ) ).path
+ final expandDirectory = (new File(distDirectory, 'gant-' + gantVersion)).path
final packagingDirectory = 'packaging/AntDebTask'
inputs.file packagingDirectory + '/gant'
inputs.file expandDirectory + '/bin/startGroovy'
@@ -495,21 +495,21 @@ task standaloneDeb ( dependsOn : standaloneBinTgz , description : 'Create a deb
// Using doLast here causes a concurrent modification exception.
//doLast {
delete distDirectory
- distDirectory.mkdirs ( )
- ant.taskdef resource : 'ant_deb_task.properties' , classpath : [ System.properties.'user.home' , '.groovy' , 'lib' , 'ant-deb.jar' ].join ( System.properties.'file.separator' )
+ distDirectory.mkdirs()
+ ant.taskdef resource: 'ant_deb_task.properties', classpath: [ System.properties.'user.home', '.groovy', 'lib', 'ant-deb.jar' ].join(System.properties.'file.separator')
logger.info "==> Untaring ${buildDir}/gant-${gantVersion}.tgz to ${distDirectory}"
- final process = [ 'sh' , '-x' , '-c' , "cd ${distDirectory} && tar xvf ${buildDir}/gant-${gantVersion}.tgz" ].execute ( )
- process.consumeProcessOutput ( )
- process.waitFor ( )
- debsDirectory.mkdirs ( )
- final result = ant.deb ( todir : debsDirectory , 'package' : packageName , section : 'devel' , priority : 'optional' , architecture : architecture ,
- depends : 'java2-runtime', postinst : packagingDirectory+ '/postinst' , prerm : packagingDirectory + '/prerm' ,
- conflicts : 'gant' ) {
+ final process = [ 'sh', '-x', '-c', "cd ${distDirectory} && tar xvf ${buildDir}/gant-${gantVersion}.tgz" ].execute()
+ process.consumeProcessOutput()
+ process.waitFor()
+ debsDirectory.mkdirs()
+ final result = ant.deb(todir: debsDirectory, 'package': packageName, section: 'devel', priority: 'optional', architecture: architecture,
+ depends: 'java2-runtime', postinst: packagingDirectory+ '/postinst', prerm: packagingDirectory + '/prerm',
+ conflicts: 'gant') {
// Hack required to make Gradle get things right.
- //version upstream : gantVersion , debian : debPackagingNumber
- delegate.version upstream : gantVersion , debian : debPackagingNumber
- maintainer name : 'Russel Winder' , email : 'russel@winder.org.uk'
- description synopsis : 'Gant -- Groovy scripting of Ant tasks.' , '''
+ //version upstream: gantVersion, debian: debPackagingNumber
+ delegate.version upstream: gantVersion, debian: debPackagingNumber
+ maintainer name: 'Russel Winder', email: 'russel@winder.org.uk'
+ description synopsis: 'Gant -- Groovy scripting of Ant tasks.', '''
Gant is a tool for scripting Ant tasks using Groovy instead of XML to specify
the logic. A Gant specification is just a Groovy script and so can bring all
the power of Groovy to bear directly, something not possible with Ant scripts.
@@ -524,13 +524,13 @@ run are included in the package.
.
Homepage: http://gant.codehaus.org/
'''
- tarfileset file : packagingDirectory + '/gant' , prefix : installPrefixBase + '/bin' , filemode : '755'
- tarfileset file : expandDirectory + '/bin/startGroovy' , prefix : installPrefixBase + '/bin' , filemode : '644'
- tarfileset file : expandDirectory + '/conf/gant-starter.conf' , prefix : installPrefixBase + '/conf' , filemode : '644'
- tarfileset dir : expandDirectory + '/lib' , includes : '*.jar' , prefix : installPrefixBase + '/lib' , filemode : '644'
+ tarfileset file: packagingDirectory + '/gant', prefix: installPrefixBase + '/bin', filemode: '755'
+ tarfileset file: expandDirectory + '/bin/startGroovy', prefix: installPrefixBase + '/bin', filemode: '644'
+ tarfileset file: expandDirectory + '/conf/gant-starter.conf', prefix: installPrefixBase + '/conf', filemode: '644'
+ tarfileset dir: expandDirectory + '/lib', includes: '*.jar', prefix: installPrefixBase + '/lib', filemode: '644'
}
// The deb Ant task appears not to record the name of the resultant deb file so we have to construct it
- // by replicating the algorithm :-((
+ // by replicating the algorithm:-((
assert createdDebFileName == result._package + '_' + result._version + '_' + result._architecture + '.deb'
//}
}
@@ -541,135 +541,135 @@ debTasks << standaloneDeb
//
// Create the documentation distribution.
-task docTgz ( type : Tar , dependsOn : [ ':gant:javadoc' , ':gant:groovydoc' ] , description : 'Create a tarball of the documentation' ) {
+task docTgz(type: Tar, dependsOn: [':gant:javadoc', ':gant:groovydoc'], description: 'Create a tarball of the documentation') {
baseName = artifact + '_doc'
version = gantVersion
compression = Compression.GZIP
destinationDir = buildDir
- into ( gantPrefix + '/docs' ) { from project ( ':gant' ).docsDir }
+ into(gantPrefix + '/docs') { from project(':gant').docsDir }
}
-task docZip ( type : Zip , dependsOn : [ ':gant:javadoc' , ':gant:groovydoc' ] , description : 'Create a zip file of the documentation' ) {
+task docZip(type: Zip, dependsOn: [':gant:javadoc', ':gant:groovydoc'], description: 'Create a zip file of the documentation') {
baseName = artifact + '_doc'
version = gantVersion
destinationDir = buildDir
- into ( gantPrefix + '/docs' ) { from project ( ':gant' ).docsDir }
+ into(gantPrefix + '/docs') { from project(':gant').docsDir }
}
-distributionTasks += [ docTgz , docZip ]
+distributionTasks += [ docTgz, docZip ]
// =====================================================================
//
// Create the source distribution.
final srcContent = [
- 'artwork/' , 'documentation/' , 'examples/' , 'packaging' , 'scripts/' , 'src/' ,
- 'build.gradle' , 'settings.gradle' , 'gradlew' ,'gradlew.bat' , 'wrapper/' ,
- 'ciBuild' ,
- 'Gant.ipr' , 'Gant.iws' ,
- '.classpath' , '.project' , '.settings/' ,
- 'LICENCE.txt' ,
- 'README_Install.txt' ,
- 'releaseNotes.txt' ,
- 'overview.html' ,
+ 'artwork/', 'documentation/', 'examples/', 'packaging', 'scripts/', 'src/',
+ 'build.gradle', 'settings.gradle', 'gradlew','gradlew.bat', 'wrapper/',
+ 'ciBuild',
+ 'Gant.ipr', 'Gant.iws',
+ '.classpath', '.project', '.settings/',
+ 'LICENCE.txt',
+ 'README_Install.txt',
+ 'releaseNotes.txt',
+ 'overview.html',
]
-task srcTgz ( type : Tar , description : 'Create a tarball of the source.' ) {
+task srcTgz(type: Tar, description: 'Create a tarball of the source.') {
baseName = artifact + '_src'
version = gantVersion
compression = Compression.GZIP
destinationDir = buildDir
- into ( gantPrefix ) { from ( projectDir ) { srcContent.each { include it } } }
+ into(gantPrefix) { from(projectDir) { srcContent.each { include it } } }
}
-task srcZip ( type : Zip , description : 'Create a zip file of the source.' ) {
+task srcZip(type: Zip, description: 'Create a zip file of the source.') {
baseName = artifact + '_src'
version = gantVersion
destinationDir = buildDir
- into ( gantPrefix ) { from ( projectDir ) { srcContent.each { include it } } }
+ into(gantPrefix) { from(projectDir) { srcContent.each { include it } } }
}
-distributionTasks += [ srcTgz , srcZip ]
+distributionTasks += [ srcTgz, srcZip ]
// =====================================================================
//
// Tasks for getting all the distribution materials uploaded to Codehaus.
final checkAuthority = { ->
- if ( ! project.hasProperty ( 'gant_experimentalDistributionLocation' ) && ! ( project.hasProperty ( 'codehausUsername' ) && project.hasProperty ( 'codehausPassword' ) ) ) {
- throw new RuntimeException ( 'Must define both codehausUsername and codehausPassword to upload distributions.')
+ if (! project.hasProperty('gant_experimentalDistributionLocation') && !(project.hasProperty('codehausUsername') && project.hasProperty('codehausPassword'))) {
+ throw new RuntimeException('Must define both codehausUsername and codehausPassword to upload distributions.')
}
}
-final undertakeUpload = { copySpec , uploadSpec ->
- if ( project.hasProperty ( 'gant_experimentalDistributionLocation' ) ) {
- if ( ! gant_experimentalDistributionLocation ) { throw new RuntimeException ( 'gant_experimentalDistributionLocation value not reasonable.' ) }
+final undertakeUpload = { copySpec, uploadSpec ->
+ if (project.hasProperty('gant_experimentalDistributionLocation')) {
+ if (! gant_experimentalDistributionLocation) { throw new RuntimeException('gant_experimentalDistributionLocation value not reasonable.') }
copy copySpec
}
else {
configurations { upload }
repositories {
- if ( project.hasProperty ( 'gant_useMavenLocal' ) && gant_useMavenLocal ) { mavenLocal ( ) }
- mavenCentral ( )
+ if (project.hasProperty('gant_useMavenLocal') && gant_useMavenLocal) { mavenLocal() }
+ mavenCentral()
}
dependencies { upload 'com.googlecode.sardine:sardine:146' }
- assert uploadSpec.size ( ) == 2
- final targetDirectoryUrl = 'https://dav.codehaus.org/' + ( gantVersion.contains ( 'SNAPSHOT' ) ? 'snapshots.' : '' ) + 'dist/gant/' + uploadSpec[0]
+ assert uploadSpec.size() == 2
+ final targetDirectoryUrl = 'https://dav.codehaus.org/' + (gantVersion.contains('SNAPSHOT') ? 'snapshots.' : '') + 'dist/gant/' + uploadSpec[0]
/*
- com.googlecode.sardine.Sardine sardine = com.googlecode.sardine.SardineFactory.begin ( codehausUsername , codehausPassword )
+ com.googlecode.sardine.Sardine sardine = com.googlecode.sardine.SardineFactory.begin(codehausUsername, codehausPassword)
*/
}
}
-task buildDistribution ( dependsOn : distributionTasks , description : 'Build all the uploadable distribution archives.' )
+task buildDistribution(dependsOn: distributionTasks, description: 'Build all the uploadable distribution archives.')
-task uploadDistribution ( dependsOn : buildDistribution , description : 'Upload all the distribution archives.' ) << {
- checkAuthority ( )
+task uploadDistribution(dependsOn: buildDistribution, description: 'Upload all the distribution archives.') << {
+ checkAuthority()
undertakeUpload (
{
distributionTasks.each { task -> from task }
into rootProject.buildDir.absolutePath + '/' + gant_experimentalDistributionLocation + '/distributions'
- } ,
- [ 'distributions' , distributionTasks ] )
+ },
+ ['distributions', distributionTasks])
}
// =====================================================================
//
// Tasks for getting all the debs uploaded to Codehaus.
-task buildDebs ( dependsOn : debTasks , description : 'Build all the uploadable debs.' )
+task buildDebs(dependsOn: debTasks, description: 'Build all the uploadable debs.')
-task uploadDebs ( dependsOn : buildDebs , description : 'Upload all the debs.' ) << {
- checkAuthority ( )
- undertakeUpload (
+task uploadDebs(dependsOn: buildDebs, description: 'Upload all the debs.') << {
+ checkAuthority()
+ undertakeUpload(
{
- debTasks.each { task -> from task }
+ debTasks.each{task -> from task}
into rootProject.buildDir.absolutePath + '/' + gant_experimentalDistributionLocation + '/debs'
- } ,
- [ 'debs' , debTasks ] )
+ },
+ ['debs', debTasks])
}
// =====================================================================
//
// Do a complete release.
-final archivesUploadTasks = [ ]
-forEachDistributionVersion { archivesUploadTasks << ':' + it + ':uploadArchives'}
+final archivesUploadTasks = []
+forEachDistributionVersion{archivesUploadTasks << ':' + it + ':uploadArchives'}
-task uploadRelease ( dependsOn: archivesUploadTasks + [ uploadDistribution , uploadDebs ] , description : 'Upload all elements of a release.' )
+task uploadRelease(dependsOn: archivesUploadTasks + [uploadDistribution, uploadDebs], description: 'Upload all elements of a release.')
// =====================================================================
//
// Odds and sods.
-task ciBuild ( description : 'Run just the builds that use Groovy from the Maven repository. Used mainly on CI servers.' , dependsOn : ciBuildTasks )
+task ciBuild(description: 'Run just the builds that use Groovy from the Maven repository. Used mainly on CI servers.', dependsOn: ciBuildTasks)
-task wrapper ( type : Wrapper ) {
+task wrapper(type: Wrapper) {
gradleVersion = '1.3'
}
-task clobber ( description : 'Do a really detailed clean.' ) << {
- forEachProject { item -> delete item }
- delete buildDir , 'texput.log'
+task clobber(description: 'Do a really detailed clean.') << {
+ forEachProject{item -> delete item}
+ delete buildDir, 'texput.log'
}
View
20 examples/ivy/build.gant
@@ -1,6 +1,6 @@
// Gant -- A Groovy way of scripting Ant tasks.
//
-// Copyright © 2006-8,2010 Russel Winder
+// Copyright © 2006–2008, 2010, 2013 Russel Winder
//
// 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
@@ -23,24 +23,24 @@ sourceDirectory = 'source'
includeTargets << gant.targets.Clean
cleanDirectory << buildDirectory
-cleanPattern << [ '**/*~' , '**/*.bak' ]
+cleanPattern << ['**/*~' , '**/*.bak']
// We are testing the Ivy tool so we need to include it.
includeTool << gant.tools.Ivy
// Cannot have a target called run as it creates an infinite mutual recursion. :-(
-target ( runTest : 'Run the Ivy "Hello" test.' ) {
+target(runTest: 'Run the Ivy "Hello" test.') {
def classpathId = 'libraryClasspath'
- ivy.cachepath ( organisation : 'commons-lang' , module : 'commons-lang' , revision : '2.5' , pathid : classpathId , inline : 'true' )
- mkdir ( dir : buildDirectory )
- javac ( srcdir : sourceDirectory , destdir : buildDirectory , debug : 'true' , classpathref : classpathId )
- java ( classname : 'example.Hello' , classpathref : classpathId ) {
- classpath { pathelement ( location : buildDirectory ) }
+ ivy.cachepath(organisation: 'commons-lang', module: 'commons-lang', revision: '2.5', pathid: classpathId, inline: 'true')
+ mkdir(dir: buildDirectory)
+ javac(srcdir: sourceDirectory, destdir: buildDirectory, debug: 'true', classpathref: classpathId)
+ java(classname: 'example.Hello', classpathref: classpathId) {
+ classpath { pathelement(location: buildDirectory) }
}
}
-target ( cleanCache : 'Clean the Ivy cache.' ) { ivy.cleancache ( ) }
+target(cleanCache: 'Clean the Ivy cache.') { ivy.cleancache() }
-setDefaultTarget ( runTest )
+setDefaultTarget(runTest)
View
14 examples/ivy/source/example/Hello.java
@@ -1,6 +1,6 @@
// Gant -- A Groovy way of scripting Ant tasks.
//
-// Copyright © 2006-8,2010 Russel Winder
+// Copyright © 2006–2008, 2010, 2013 Russel Winder
//
// 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
@@ -14,14 +14,14 @@
//
// Author: Russel Winder <russel@winder.org.uk>
-package example ;
+package example;
-import org.apache.commons.lang.WordUtils ;
+import org.apache.commons.lang.WordUtils;
public class Hello {
- public static void main ( final String[] args ) {
- String message = "hello ivy !" ;
- System.out.println ( "Standard message : " + message ) ;
- System.out.println ( "Capitalized by " + WordUtils.class.getName ( ) + " : " + WordUtils.capitalizeFully ( message ) ) ;
+ public static void main(final String[] args) {
+ String message = "hello ivy !";
+ System.out.println("Standard message : " + message);
+ System.out.println("Capitalized by " + WordUtils.class.getName() + " : " + WordUtils.capitalizeFully(message));
}
}
View
30 examples/testScripts/explicitClean.gant
@@ -1,6 +1,6 @@
// Gant -- A Groovy way of scripting Ant tasks.
//
-// Copyright © 2006-8,2010 Russel Winder
+// Copyright © 2006–2008, 2010, 2013 Russel Winder
//
// 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
@@ -12,23 +12,23 @@
// implied. See the License for the specific language governing permissions and limitations under the
// License.
//
-// Author : Russel Winder <russel@winder.org.uk>
+// Author: Russel Winder <russel@winder.org.uk>
-target ( 'default' : 'The default target.' ) {
- println ( 'Default' )
- clean ( )
- Ant.echo ( message : 'A default message from Ant.' )
- otherStuff ( )
+target('default': 'The default target.') {
+ println('Default')
+ clean()
+ Ant.echo(message: 'A default message from Ant.')
+ otherStuff()
}
-target ( otherStuff : 'Other stuff.' ) {
- println ( 'OtherStuff' )
- Ant.echo ( message : 'Another message from Ant.' )
- clean ( )
+target(otherStuff: 'Other stuff.') {
+ println('OtherStuff')
+ Ant.echo(message: 'Another message from Ant.')
+ clean()
}
-target ( clean : 'Clean the directory and subdirectories.' ) {
- println ( 'Clean' )
- Ant.delete ( dir : 'build' , quiet : 'true' )
- Ant.delete ( quiet : 'true' ) { fileset ( dir : '.' , includes : '**/*~,**/*.bak' , defaultexcludes : 'false' ) }
+target(clean: 'Clean the directory and subdirectories.') {
+ println('Clean')
+ Ant.delete(dir: 'build', quiet: 'true')
+ Ant.delete(quiet: 'true') { fileset(dir: '.', includes: '**/*~,**/*.bak', defaultexcludes: 'false') }
}
View
24 examples/testScripts/gantClean.gant
@@ -1,6 +1,6 @@
// Gant -- A Groovy way of scripting Ant tasks.
//
-// Copyright © 2006-8,2010 Russel Winder
+// Copyright © 2006–2008, 2010, 2013 Russel Winder
//
// 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
@@ -12,21 +12,21 @@
// implied. See the License for the specific language governing permissions and limitations under the
// License.
//
-// Author : Russel Winder <russel@winder.org.uk>
+// Author: Russel Winder <russel@winder.org.uk>
includeTargets << gant.targets.Clean
-cleanPattern << [ '**/*~' , '**/*.bak' ]
+cleanPattern << ['**/*~', '**/*.bak']
cleanDirectory << 'build'
-target ( 'default' : 'The default target.' ) {
- println ( 'Default' )
- clean ( )
- echo ( message : 'A default message from Ant.' )
- otherStuff ( )
+target('default': 'The default target.') {
+ println('Default')
+ clean()
+ echo(message: 'A default message from Ant.')
+ otherStuff()
}
-target ( otherStuff : 'Other stuff' ) {
- println ( 'OtherStuff' )
- echo ( message : 'Another message from Ant.' )
- clean ( )
+target(otherStuff: 'Other stuff') {
+ println('OtherStuff')
+ echo(message: 'Another message from Ant.')
+ clean()
}
View
88 packaging/AntDebTask/build.gant
@@ -1,6 +1,6 @@
// Gant -- A Groovy way of scripting Ant tasks.
//
-// Copyright © 2007-10 Russel Winder
+// Copyright © 2007–2010, 2013 Russel Winder
//
// 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
@@ -12,7 +12,7 @@
// implied. See the License for the specific language governing permissions and limitations under the
// License.
//
-// Author : Russel Winder <russel@winder.org.uk>
+// Author: Russel Winder <russel@winder.org.uk>
// The overal algorithm here is to take a standalone distribution (could use either a tarball or a
// zipfile, prefer to use a tarball if it exists) expand it and then repackage into a deb file. Do not
@@ -26,10 +26,10 @@
// expression below should result in a single match resulting in a list of two items, the full match and
// the capture group. The capture group should be the version number.
-final matcher = ( new File ( '../../build.gradle' ) ).text =~ "gantVersionBase\\s*=\\s*'(.*)'"
+final matcher = new File('../../build.gradle').text =~ "gantVersionBase\\s*=\\s*'(.*)'"
assert matcher != null
assert matcher[0] != null
-assert matcher[0].size ( ) == 2
+assert matcher[0].size() == 2
final gantVersion = matcher[0][1]
@@ -39,11 +39,11 @@ final packageName = 'gant-standalone'
final section = 'devel'
final priority = 'optional'
final architecture = 'all'
-final homepage = 'http://gant.codehaus.org/'
+final homepage = 'http://gant.codehaus.org/'
final installPrefixBase = 'usr/share/gant'
-final theSynopsis = 'Gant -- Groovy scripting of Ant tasks.'
+final theSynopsis = 'Gant -- Groovy scripting of Ant tasks.'
final theWords = """
Gant is a tool for scripting Ant tasks using Groovy instead of XML to specify
the logic. A Gant specification is just a Groovy script and so can bring all
@@ -59,16 +59,16 @@ run are included in the package.
.
Homepage: ${homepage}
"""
-
+
// Where to put the deb when uploading. We need the slide-webdav jar which we get fromt he Maven
// repository, so we need to make use of the Maven Ant task to be able to get it.
final antlibXMLns = 'antlib:org.apache.maven.artifact.ant'
-final distributionURL = 'https://dav.codehaus.org/' + ( gantVersion.contains ( 'SNAPSHOT' ) ? 'snapshots.' : '' ) + 'dist/gant/'
+final distributionURL = 'https://dav.codehaus.org/' +(gantVersion.contains('SNAPSHOT') ? 'snapshots.': '') + 'dist/gant/'
// Load up the Ant Deb task.
-ant.taskdef ( resource : 'ant_deb_task.properties' , classpath : [ System.properties.'user.home' , '.groovy' , 'lib' , 'ant-deb.jar' ].join ( System.properties.'file.separator' ) )
+ant.taskdef(resource: 'ant_deb_task.properties', classpath: [ System.properties.'user.home', '.groovy', 'lib', 'ant-deb.jar' ].join(System.properties.'file.separator'))
// Local details of where to expand the standalone distribution and where to make the debs.
@@ -80,59 +80,59 @@ final expandDirectory = distDirectory + '/gant-' + gantVersion
includeTargets << gant.targets.Clean
cleanPattern << '**/*~'
-cleanDirectory << [ debsDirectory , distDirectory ]
+cleanDirectory << [ debsDirectory, distDirectory ]
includeTool << gant.tools.Execute
// The targets: create the debs and upload the debs, set the default to build.
-target ( debFiles : 'Create the deb file of the distribution.' ) {
- execute.shell ( "cd ../.. && gradle standaloneBinTgz" )
- mkdir ( dir : distDirectory )
- delete { fileset ( dir : distDirectory , includes : '**/*' ) }
- execute.shell ( "cd ${distDirectory} && tar xvf ../../../build/gant-${gantVersion}.tgz")
- mkdir ( dir : debsDirectory )
+target(debFiles: 'Create the deb file of the distribution.') {
+ execute.shell("cd ../.. && gradle standaloneBinTgz")
+ mkdir(dir: distDirectory)
+ delete { fileset(dir: distDirectory, includes: '**/*') }
+ execute.shell("cd ${distDirectory} && tar xvf ../../../build/gant-${gantVersion}.tgz")
+ mkdir(dir: debsDirectory)
//// Why is the ant. needed here ??????
- ant.deb ( todir : debsDirectory , 'package' : packageName , section : section , priority : priority , architecture : architecture ,
- depends : 'java2-runtime', postinst : 'postinst' , prerm : 'prerm' ) {
- version ( upstream : gantVersion )
- maintainer ( name : 'Russel Winder' , email : 'russel@russel.org.uk' )
- //homepage ( homepage )
- description ( synopsis : theSynopsis , theWords )
- tarfileset ( file : 'gant' , prefix : installPrefixBase + '/bin' , filemode : '755' )
- tarfileset ( file : expandDirectory + '/bin/startGroovy' , prefix : installPrefixBase + '/bin' , filemode : '644' )
- tarfileset ( file : expandDirectory + '/conf/gant-starter.conf' , prefix : installPrefixBase + '/conf' , filemode : '644' )
- tarfileset ( dir : expandDirectory + '/lib' , includes : '*.jar' , prefix : installPrefixBase + '/lib' , filemode : '644' )
+ ant.deb(todir: debsDirectory, 'package': packageName, section: section, priority: priority, architecture: architecture,
+ depends: 'java2-runtime', postinst: 'postinst', prerm: 'prerm') {
+ version(upstream: gantVersion)
+ maintainer(name: 'Russel Winder', email: 'russel@russel.org.uk')
+ //homepage(homepage)
+ description(synopsis: theSynopsis, theWords)
+ tarfileset(file: 'gant', prefix: installPrefixBase + '/bin', filemode: '755')
+ tarfileset(file: expandDirectory + '/bin/startGroovy', prefix: installPrefixBase + '/bin', filemode: '644')
+ tarfileset(file: expandDirectory + '/conf/gant-starter.conf', prefix: installPrefixBase + '/conf', filemode: '644')
+ tarfileset(dir: expandDirectory + '/lib', includes: '*.jar', prefix: installPrefixBase + '/lib', filemode: '644')
}
}
-target ( uploadDistribution : 'Upload the deb files to Codehaus.' ) {
- depends ( debFiles )
- "${antlibXMLns}:dependencies" ( pathId : 'slidePathId' ) {
- dependency ( groupId : 'slide' , artifactId : 'slide-webdavlib' , version : '2.1' )
+target(uploadDistribution: 'Upload the deb files to Codehaus.') {
+ depends(debFiles)
+ "${antlibXMLns}:dependencies"(pathId: 'slidePathId') {
+ dependency(groupId: 'slide', artifactId: 'slide-webdavlib', version: '2.1')
}
- def loader = getClass ( ).getClassLoader ( )
- def path = path ( refid : 'slidePathId' )
- ( path.list ( ) as List ).each { location -> loader.addURL ( new URL ( 'file://' + location ) ) }
- def settings = ( new XmlSlurper ( ) ).parse ( System.properties.'user.home' + '/.m2/settings.xml' ).servers.server.find { item -> item.id == 'codehaus.org' }
- def credentials = loader.loadClass ( 'org.apache.commons.httpclient.UsernamePasswordCredentials' ).getConstructor ( String , String ).newInstance ( settings.username.toString ( ) , settings.password.toString ( ) )
+ def loader = getClass().getClassLoader()
+ def path = path(refid: 'slidePathId')
+ (path.list() as List).each { location -> loader.addURL(new URL('file://' + location)) }
+ def settings = (new XmlSlurper()).parse(System.properties.'user.home' + '/.m2/settings.xml').servers.server.find { item -> item.id == 'codehaus.org' }
+ def credentials = loader.loadClass('org.apache.commons.httpclient.UsernamePasswordCredentials').getConstructor(String, String).newInstance(settings.username.toString(), settings.password.toString())
// Have to put resource in the binding so that the Closures can access it.
- resource = loader.loadClass ( 'org.apache.webdav.lib.WebdavResource' ).getConstructor ( String , loader.loadClass ( 'org.apache.commons.httpclient.Credentials' ) , boolean ).newInstance ( distributionURL , credentials , true )
- if ( resource.statusCode != 200 ) { println ( 'Failed to open ' + distributionURL ) }
+ resource = loader.loadClass('org.apache.webdav.lib.WebdavResource').getConstructor(String, loader.loadClass('org.apache.commons.httpclient.Credentials'), boolean).newInstance(distributionURL, credentials, true)
+ if (resource.statusCode != 200) { println('Failed to open ' + distributionURL) }
else {
final serverUploadProducts = [:]
final serverDistributionsDirectory = 'debs'
- ( new File ( debsDirectory ) ).eachFile { file -> serverUploadProducts[ file.path ] = serverDistributionsDirectory + '/' + file.name
+ new File(debsDirectory).eachFile { file -> serverUploadProducts[ file.path ] = serverDistributionsDirectory + '/' + file.name
}
- serverUploadProducts.each { source , destination ->
+ serverUploadProducts.each { source, destination ->
def serverPath = resource.path + '/' + destination
- print ( 'Uploading ' + source + ' -> ' + destination + ' : ' )
+ print('Uploading ' + source + ' -> ' + destination + ': ')
def result = 'Failed.'
- if ( resource.putMethod ( serverPath , new File ( source ) ) ) { result = 'OK.' }
- println ( result + ' Status : ' + resource.statusMessage )
+ if (resource.putMethod(serverPath, new File(source))) { result = 'OK.' }
+ println(result + ' Status: ' + resource.statusMessage)
}
}
- if ( resource != null ) { resource.close ( ) }
+ if (resource != null) { resource.close() }
}
-setDefaultTarget ( debFiles )
+setDefaultTarget(debFiles)
View
2 packaging/AntDebTask/gant
@@ -2,7 +2,7 @@
# Gant -- A Groovy way of scripting Ant tasks.
#
-# Copyright © 2008,2010 Russel Winder
+# Copyright © 2008, 2010, 2013 Russel Winder
#
# 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
View
2 scripts/bash_completion.d/gant
@@ -2,7 +2,7 @@
# Gant -- A Groovy way of scripting Ant tasks.
-# Copyright © 2006-8,2010 Russel Winder
+# Copyright © 2006–2008, 2010, 2013 Russel Winder
# 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
View
10 scripts/bin_requiresGroovy/gant
@@ -2,7 +2,7 @@
# Gant -- A Groovy way of scripting Ant tasks.
#
-# Copyright © 2006-10 Russel Winder
+# Copyright © 2006–2010, 2013 Russel Winder
#
# 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
@@ -24,9 +24,9 @@
#
# This function attempts to just do the right thing.
-doReadLink ( ) {
+doReadLink() {
case `uname` in
- Darwin )
+ Darwin)
gantLocation=`dirname $1`
gantPath=`readlink "$1"`
if [ "$gantPath" = "" ]
@@ -43,7 +43,7 @@ doReadLink ( ) {
cd $currentDirectory
fi
;;
- SunOS )
+ SunOS)
readlinkPath=`which readlink`
if [ `expr "$readlinkPath" : '\([^ ]*\)'` = "no" ]
then
@@ -53,7 +53,7 @@ doReadLink ( ) {
readlinkValue=`readlink -f $1`
fi
;;
- * )
+ *)
readlinkValue=`readlink -f $1`
;;
esac
View
10 scripts/bin_standalone/gant
@@ -2,7 +2,7 @@
# Gant -- A Groovy way of scripting Ant tasks.
#
-# Copyright © 2006-10 Russel Winder
+# Copyright © 2006–2010, 2013 Russel Winder
#
# 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
@@ -27,9 +27,9 @@
#
# This function attempts to just do the right thing.
-doReadLink ( ) {
+doReadLink() {
case `uname` in
- Darwin )
+ Darwin)
gantLocation=`dirname $1`
gantPath=`readlink "$1"`
if [ "$gantPath" = "" ]
@@ -46,7 +46,7 @@ doReadLink ( ) {
cd $currentDirectory
fi
;;
- SunOS )
+ SunOS)
readlinkPath=`which readlink`
if [ `expr "$readlinkPath" : '\([^ ]*\)'` = "no" ]
then
@@ -56,7 +56,7 @@ doReadLink ( ) {
readlinkValue=`readlink -f $1`
fi
;;
- * )
+ *)
readlinkValue=`readlink -f $1`
;;
esac
View
8 scripts/conf/gant-starter.conf
@@ -1,6 +1,6 @@
# Gant -- A Groovy way of scripting Ant tasks.
#
-# Copyright © 2008,2010 Russel Winder
+# Copyright © 2008, 2010, 2013 Russel Winder
#
# 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
@@ -16,13 +16,13 @@
# Load user specific libraries that are Gant specific.
load !{user.home}/.gant/lib/*.jar
-
+
# Load user specific libraries that are Ant specific.
load !{user.home}/.ant/lib/*.jar
-
+
# Load user specific libraries that are for Groovy.
load !{user.home}/.groovy/lib/*.jar
-
+
# Load required libraries
load !{gant.home}/lib/*.jar
View
6 settings.gradle
@@ -1,6 +1,6 @@
// Gant -- A Groovy way of scripting Ant tasks.
//
-// Copyright © 2009--2011 Russel Winder
+// Copyright © 2009--2011, 2013 Russel Winder
//
// 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
@@ -12,6 +12,6 @@
// implied. See the License for the specific language governing permissions and limitations under the
// License.
//
-// Author : Russel Winder <russel@winder.org.uk>
+// Author: Russel Winder <russel@winder.org.uk>
-include 'gant' , 'gant_groovy1.8' , 'gant_groovy2.0'
+include 'gant', 'gant_groovy1.8', 'gant_groovy2.0'
View
498 src/main/groovy/gant/Gant.groovy
@@ -1,6 +1,6 @@
// Gant -- A Groovy way of scripting Ant tasks.
//
-// Copyright © 2006--2011 Russel Winder
+// Copyright © 20062011, 2013 Russel Winder
//
// 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
@@ -55,34 +55,34 @@ import org.codehaus.groovy.runtime.InvokerInvocationException
* <p>A trivial example build specification is:</p>
*
* <pre>
- * target ( stuff : 'A target to do some stuff.' ) {
- * clean ( )
- * otherStuff ( )
+ * target(stuff: 'A target to do some stuff.') {
+ * clean()
+ * otherStuff()
* }
- * target ( otherStuff : 'A target to do some other stuff' ) {
- * depends ( clean )
+ * target(otherStuff: 'A target to do some other stuff') {
+ * depends(clean)
* }
- * target ( clean : 'Clean the directory and subdirectories' ) {
- * delete ( dir : 'build' , quiet : 'true' )
- * delete ( quiet : 'true' ) { fileset ( dir : '.' , includes : '** /*~,** /*.bak' , defaultexcludes : 'false' ) }
+ * target(clean: 'Clean the directory and subdirectories') {
+ * delete(dir: 'build', quiet: 'true')
+ * delete(quiet: 'true') { fileset(dir: '.', includes: '** /*~,** /*.bak' , defaultexcludes: 'false') }
* }
- * setDefaultTarget ( stuff )
+ * setDefaultTarget(stuff)
* </pre>
*
* <p>or, using some a ready made targets class:</p>
*
* <pre>
* includeTargets << gant.targets.Clean
- * cleanPattern << [ '** / *~' , '** / *.bak' ]
+ * cleanPattern << [ '** / *~', '** / *.bak' ]
* cleanDirectory << 'build'
- * target ( stuff : 'A target to do some stuff.' ) {
- * clean ( )
- * otherStuff ( )
+ * target(stuff: 'A target to do some stuff.') {
+ * clean()
+ * otherStuff()
* }
- * target ( otherStuff : 'A target to do some other stuff' ) {
- * depends ( clean )
+ * target(otherStuff: 'A target to do some other stuff') {
+ * depends(clean)
* }
- * setDefaultTarget ( stuff )
+ * setDefaultTarget(stuff)
* </pre>
*
* <p><em>Note that there is an space between the two asterisks and the solidus in the fileset line that
@@ -114,20 +114,20 @@ final class Gant {
* @param url The URL of the cache
* @return instance of the class.
*/
- private final loadClassFromCache = { className , lastModified , url ->
+ private final loadClassFromCache = {className, lastModified, url ->
try {
- def classUrl = binding.classLoader.getResource ( "${className}.class" )
- if ( classUrl ) {
- if ( lastModified > classUrl.openConnection ( ).lastModified ) {
- compileScript ( cacheDirectory , url.text , className )
+ final classUrl = binding.classLoader.getResource("${className}.class")
+ if (classUrl) {
+ if (lastModified > classUrl.openConnection().lastModified) {
+ compileScript(cacheDirectory, url.text, className)
}
}
- return binding.classLoader.loadClass ( className ).newInstance ( )
+ return binding.classLoader.loadClass(className).newInstance()
}
- catch ( Exception e ) {
- def fileText = url.text
- compileScript ( cacheDirectory , fileText , className )
- return binding.groovyShell.parse ( fileText , buildClassName )
+ catch (Exception e) {
+ final fileText = url.text
+ compileScript(cacheDirectory, fileText, className)
+ return binding.groovyShell.parse(fileText, buildClassName)
}
}
/**
@@ -145,13 +145,13 @@ final class Gant {
/**
* The location where the compiled scripts are cached. Defaults to "$USER_HOME/.gant/cache".
*/
- File cacheDirectory = new File ( "${System.properties.'user.home'}/.gant/cache" )
+ File cacheDirectory = new File("${System.properties.'user.home'}/.gant/cache")
/**
* A list of strings containing the locations of Gant modules.
*/
- List<String> gantLib = [ ]
+ List<String> gantLib = []
/**
- * The script that will be run when { @link #processTargets ( ) } is called. It is initialised when a
+ * The script that will be run when { @link #processTargets() } is called. It is initialised when a
* script is loaded. Note that it has a dynamic type because the script may be loaded from a different
* class loader than the one used to load the Gant class. If we declared it as Script, there would likely
* be ClassCastExceptions.
@@ -170,55 +170,55 @@ final class Gant {
* Default constructor -- creates a new instance of <code>GantBinding</code> for the script binding,
* and the default class loader.
*/
- public Gant ( ) { this ( (GantBinding) null ) }
+ public Gant() { this((GantBinding)null) }
/**
* Constructor that uses the passed <code>GantBinding</code> for the script binding, and the default
* class loader.
*
* @param b the <code>GantBinding</code> to use.
*/
- public Gant ( GantBinding b ) { this ( b , null ) }
+ public Gant(GantBinding b) { this(b, null) }
/**
* Constructor that uses the passed <code>GantBinding</code> for the script binding, and the passed
* <code>ClassLoader</code> as the class loader.
*
* @param b the <code>GantBinding</code> to use.
* @param cl the <code>ClassLoader</code> to use.
*/
- public Gant ( GantBinding b , ClassLoader cl ) {
- binding = b ?: new GantBinding ( )
- binding.classLoader = cl ?: getClass ( ).classLoader
- binding.groovyShell = new GroovyShell ( (ClassLoader) binding.classLoader , binding )
- final gantPackage = binding.classLoader.getPackage ( 'gant' )
+ public Gant(GantBinding b, ClassLoader cl) {
+ binding = b ?: new GantBinding()
+ binding.classLoader = cl ?: getClass().classLoader
+ binding.groovyShell = new GroovyShell((ClassLoader) binding.classLoader, binding)
+ final gantPackage = binding.classLoader.getPackage('gant')
binding.'gant.version' = gantPackage?.implementationVersion
}
/**
* Constructor intended for use in code to be called from the Groovy Ant Task.
*
* @param p the <code>org.apache.tools.ant.Project</code> to use.
*/
- public Gant ( org.apache.tools.ant.Project p ) { this ( new GantBinding ( p ) ) }
+ public Gant(org.apache.tools.ant.Project p) { this(new GantBinding(p)) }
/**
* Add a <code>BuildListener</code> instance to this <code>Gant</code> instance.
*/
- public void addBuildListener ( final BuildListener buildListener ) {
- binding.addBuildListener ( buildListener )
+ public void addBuildListener(final BuildListener buildListener) {
+ binding.addBuildListener(buildListener)
}
/**
* Remove a <code>BuildListener</code> instance from this <code>Gant</code> instance
*/
- public void removeBuildListener ( final BuildListener buildListener ) {
- binding.removeBuildListener ( buildListener )
+ public void removeBuildListener(final BuildListener buildListener) {
+ binding.removeBuildListener(buildListener)
}
/**
* Treat the given text as a Gant script and load it.
*
* @params text The text of the Gant script to load.
* @return The <code>Gant</code> instance (to allow chaining).
*/
- public Gant loadScript ( String text ) {
- if ( ! buildClassName ) { buildClassName = textInputClassName }
- script = binding.groovyShell.parse ( text , buildClassName )
+ public Gant loadScript(String text) {
+ if (! buildClassName) { buildClassName = textInputClassName }
+ script = binding.groovyShell.parse(text, buildClassName)
binding.'gant.file' = '<text>'
return this
}
@@ -230,9 +230,9 @@ final class Gant {
* compiled class.
* @return The <code>Gant</code> instance (to allow chaining).
*/
- public Gant loadScript ( InputStream scriptSource ) {
- if ( ! buildClassName ) { buildClassName = streamInputClassName }
- script = binding.groovyShell.parse ( new InputStreamReader ( scriptSource ) , buildClassName )
+ public Gant loadScript(InputStream scriptSource) {
+ if (! buildClassName) { buildClassName = streamInputClassName }
+ script = binding.groovyShell.parse(new InputStreamReader(scriptSource), buildClassName)
binding.'gant.file' = '<stream>'
return this
}
@@ -244,8 +244,8 @@ final class Gant {
* compiled class.
* @return The <code>Gant</code> instance (to allow chaining).
*/
- public Gant loadScript ( File scriptFile ) {
- return loadScript ( scriptFile.toURI ( ).toURL ( ) )
+ public Gant loadScript(File scriptFile) {
+ return loadScript(scriptFile.toURI().toURL())
}
/**
* Load a Gant script from the given URL, using the default Groovy encoding to convert the bytes
@@ -254,19 +254,19 @@ final class Gant {
* @params scriptUrl The URL where the the Gant script source is located.
* @return The <code>Gant</code> instance (to allow chaining).
*/
- public Gant loadScript ( URL scriptUrl ) {
- if ( ! buildClassName ) {
- def filename = scriptUrl.path.substring ( scriptUrl.path.lastIndexOf ( "/" ) + 1 )
- buildClassName = classNameFromFileName ( filename )
+ public Gant loadScript(URL scriptUrl) {
+ if (! buildClassName) {
+ def filename = scriptUrl.path.substring(scriptUrl.path.lastIndexOf("/") + 1)
+ buildClassName = classNameFromFileName(filename)
}
- if ( useCache ) {
- if ( binding.classLoader instanceof URLClassLoader ) { binding.classLoader.addURL ( cacheDirectory.toURI ( ).toURL ( ) ) }
- else { binding.classLoader.rootLoader?.addURL ( cacheDirectory.toURI ( ).toURL ( ) ) }
+ if (useCache) {
+ if (binding.classLoader instanceof URLClassLoader) { binding.classLoader.addURL(cacheDirectory.toURI().toURL()) }
+ else { binding.classLoader.rootLoader?.addURL(cacheDirectory.toURI().toURL()) }
binding.loadClassFromCache = loadClassFromCache
- script = loadClassFromCache ( buildClassName , scriptUrl.openConnection ( ).lastModified , scriptUrl )
+ script = loadClassFromCache(buildClassName, scriptUrl.openConnection().lastModified, scriptUrl)
}
- else { loadScript ( scriptUrl.openStream ( ) ) }
- binding.'gant.file' = scriptUrl.toString ( )
+ else { loadScript(scriptUrl.openStream()) }
+ binding.'gant.file' = scriptUrl.toString()
return this
}
/**
@@ -275,8 +275,8 @@ final class Gant {
* @params className The fully qualified name of the class to load.
* @return The <code>Gant</code> instance (to allow chaining).
*/
- public Gant loadScriptClass ( String className ) {
- script = binding.classLoader.loadClass ( className ).newInstance ( )
+ public Gant loadScriptClass(String className) {
+ script = binding.classLoader.loadClass(className).newInstance()
binding.'gant.file' = '<class>'
return this
}
@@ -293,10 +293,10 @@ final class Gant {
* @param fileName The name of the file.
* @return The transformed name.
*/
- private String classNameFromFileName ( fileName ) {
- def index = fileName.lastIndexOf ( '.' )
- if ( fileName[index..-1] in [ '.groovy' , '.gant' ] ) { fileName = fileName[0..<index] }
- return fileName.replaceAll ( '\\.' , '_' )
+ private String classNameFromFileName(fileName) {
+ def index = fileName.lastIndexOf('.')
+ if (fileName[index..-1] in [ '.groovy', '.gant' ]) { fileName = fileName[0..<index] }
+ return fileName.replaceAll('\\.', '_')
}
/**
* Filter the stacktrace of the exception so as to create a printable message with the line number of the
@@ -305,45 +305,45 @@ final class Gant {
* @param exception The exception whose stack trace is to be filtered.
* @return The filteres stacktrace information.
*/
- private String constructMessageFrom ( exception ) {
- final buffer = new StringBuilder ( )
- if ( exception instanceof GantException ) { exception = exception.cause }
- for ( stackEntry in exception.stackTrace ) {
- if ( ( stackEntry.fileName == buildClassName ) && ( stackEntry.lineNumber != -1 ) ) {
- def sourceName = ( buildClassName == standardInputClassName ) ? 'Standard input' : buildClassName
- buffer.append ( sourceName + ', line ' + stackEntry.lineNumber + ' -- ' )
+ private String constructMessageFrom(exception) {
+ final buffer = new StringBuilder()
+ if (exception instanceof GantException) { exception = exception.cause }
+ for (stackEntry in exception.stackTrace) {
+ if ((stackEntry.fileName == buildClassName) && (stackEntry.lineNumber != -1)) {
+ def sourceName = (buildClassName == standardInputClassName) ? 'Standard input' : buildClassName
+ buffer.append(sourceName + ', line ' + stackEntry.lineNumber + ' -- ')
}
}
- if ( exception instanceof InvocationTargetException ) { exception = exception.cause }
- if ( exception instanceof InvokerInvocationException ) { exception = exception.cause }
- buffer.append ( 'Error evaluating Gantfile: ' + ( ( exception instanceof RuntimeException ) ? exception.message : exception.toString ( ) ) )
- buffer.toString ( )
+ if (exception instanceof InvocationTargetException) { exception = exception.cause }
+ if (exception instanceof InvokerInvocationException) { exception = exception.cause }
+ buffer.append('Error evaluating Gantfile: ' +((exception instanceof RuntimeException) ? exception.message : exception.toString()))
+ buffer.toString()
}
/**
* Print of the list of targets for the -p and -T options.
*
* @param targets The <code>List</code> (of <code>String</code>s) that is the list of targets to achieve.
* @return The return code.
*/
- private Integer targetList ( targets ) {
+ private Integer targetList(targets) {
def max = 0
- binding.targetDescriptions.entrySet ( ).each { item ->
- def size = item.key.size ( )
- if ( size > max ) { max = size }
+ binding.targetDescriptions.entrySet().each{item ->
+ final size = item.key.size()
+ if (size > max) { max = size }
}
- println ( )
- binding.targetDescriptions.entrySet ( ).each { item ->
- println ( ' ' + item.key + ' ' * ( max - item.key.size ( ) ) + ' ' + item.value )
+ println()
+ binding.targetDescriptions.entrySet().each{item ->
+ println(' ' + item.key + ' ' * (max - item.key.size()) + ' ' + item.value)
}
- println ( )
+ println()
String defaultTargetName = null
try {
final defaultTarget = binding.defaultTarget
assert defaultTarget.class == String
- if ( binding.getVariable ( defaultTarget ) ) { defaultTargetName = defaultTarget }
- if ( defaultTargetName ) { println ( 'Default target is ' + defaultTargetName + '.' ) ; println ( ) }
+ if (binding.getVariable(defaultTarget)) { defaultTargetName = defaultTarget }
+ if (defaultTargetName) { println('Default target is ' + defaultTargetName + '.') ; println() }
}
- catch ( MissingPropertyException mpe ) { /* Intentionally blank. */ }
+ catch (MissingPropertyException mpe) { /* Intentionally blank. */ }
0
}
/**
@@ -355,94 +355,94 @@ final class Gant {
* @param targets The <code>List</code> (of <code>String</code>s) that is the list of targets to achieve.
* @return The return code.
*/
- private Integer dispatch ( List<String> targets ) {
+ private Integer dispatch(List<String> targets) {
Integer returnCode = 0
- final attemptFinalize = { ->
- final finalizeTarget = owner.binding.getVariable ( 'finalizeTarget' )
+ final attemptFinalize = {->
+ final finalizeTarget = owner.binding.getVariable('finalizeTarget')
try {
- switch ( finalizeTarget.class ) {
- case Closure :
- finalizeTarget.call ( )
+ switch (finalizeTarget.class) {
+ case Closure:
+ finalizeTarget.call()
break
- case String :
- owner.binding.getVariable ( finalizeTarget ).call ( )
+ case String:
+ owner.binding.getVariable(finalizeTarget).call()
+ break
+ default:
+ throw new RuntimeException('Gant finalizer is neither a closure nor a name.')
break
- default :
- throw new RuntimeException ( 'Gant finalizer is neither a closure nor a name.' )
- break
}
}
- catch ( MissingPropertyException mme ) { /* Intentionally blank. */ }
- catch ( Exception e ) { throw new TargetExecutionException ( e.toString ( ) , e ) }
+ catch (MissingPropertyException mme) { /* Intentionally blank. */ }
+ catch (Exception e) { throw new TargetExecutionException(e.toString(), e) }
}
- final processDispatch = { target ->
+ final processDispatch = {target ->
try {
- owner.binding.forcedSettingOfVariable ( 'initiatingTarget' , target )
- def returnValue = owner.binding.getVariable ( target ).call ( )
- returnCode = ( returnValue instanceof Number ) ? returnValue.intValue ( ) : 0
+ owner.binding.forcedSettingOfVariable('initiatingTarget', target)
+ def returnValue = owner.binding.getVariable(target).call()
+ returnCode = (returnValue instanceof Number) ? returnValue.intValue() : 0
}
- catch ( MissingPropertyException mme ) {
- attemptFinalize ( )
- if ( target == mme.property ) { throw new MissingTargetException ( "Target ${target} does not exist." , mme ) }
- else { throw new TargetMissingPropertyException ( mme.message , mme ) }
+ catch (MissingPropertyException mme) {
+ attemptFinalize()
+ if (target == mme.property) { throw new MissingTargetException("Target ${target} does not exist.", mme) }
+ else { throw new TargetMissingPropertyException(mme.message, mme) }
}
- catch ( Exception e ) {
- attemptFinalize ( )
- throw new TargetExecutionException ( e.toString ( ) , e )
+ catch (Exception e) {
+ attemptFinalize()
+ throw new TargetExecutionException(e.toString(), e)
}
}
// As part of GANT-77 output information about the buildfile.
- ////binding.ant.project.log ( 'Buildfile: ' + binding.'gant.file' + '\n\n' )
+ ////binding.ant.project.log('Buildfile: ' + binding.'gant.file' + '\n\n')
// To support GANT-44 the script must have access to the targets and be able to edit it, this means
// iterating over the list of targets but knowing that if might change during execution. So replace
// the original code:
//
- // if ( targets.size ( ) > 0 ) { withBuildListeners { targets.each { target -> processDispatch ( target ) } } }
+ // if (targets.size() > 0) { withBuildListeners { targets.each { target -> processDispatch(target) } } }
//
// with something a little more amenable to alteration of the list mid loop.
- binding.forcedSettingOfVariable ( 'targets' , targets )
- if ( targets.size ( ) > 0 ) {
+ binding.forcedSettingOfVariable('targets', targets)