[gant-scm] [10432] gant/trunk: Sort out getting Gradle to play well with Gant, Eclipse and IntelliJ IDEA over the Gant Ant task test which has to use files in specific locations.

View: New views
1 Messages — Rating Filter:   Alert me  

[gant-scm] [10432] gant/trunk: Sort out getting Gradle to play well with Gant, Eclipse and IntelliJ IDEA over the Gant Ant task test which has to use files in specific locations.

by russel-9 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
[10432] gant/trunk: Sort out getting Gradle to play well with Gant, Eclipse and IntelliJ IDEA over the Gant Ant task test which has to use files in specific locations.
Revision
10432
Author
russel
Date
2009-10-18 14:12:48 -0500 (Sun, 18 Oct 2009)

Log Message

Sort out getting Gradle to play well with Gant, Eclipse and IntelliJ IDEA over the Gant Ant task test which has to use files in specific locations.

Modified Paths

Diff

Modified: gant/trunk/build.gant (10431 => 10432)

--- gant/trunk/build.gant	2009-10-18 19:12:39 UTC (rev 10431)
+++ gant/trunk/build.gant	2009-10-18 19:12:48 UTC (rev 10432)
@@ -270,7 +270,16 @@
       fileset ( dir : jarfilesDirectory , includes : mavenAntTaskJarName ) 
       path ( refid : classpathId )
     }
+    //
+    //  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
+    //  needs to know whether this is a Gradle build or not.  Use a property.  Obviously this being Gant, we
+    //  don't actually care, but set the property anyway in case.
+    //
     // Forkmode should be once for speed but perTest for safety.
+    //
     if ( ( testCase == null ) || ! ( testCase ==~ 'org.codehaus.gant.ant.tests.*_Test' ) ) {                        
       junit ( printsummary : 'yes' , failureproperty : 'testsFailed' , fork : 'true' , forkmode : 'once' , includeantruntime : 'false' ) {
         // jvmarg ( line : '-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005' )
@@ -285,6 +294,7 @@
           path ( refid : testClasspathId )
           pathelement ( location : currentGantJarPath )
         }
+        sysproperty ( key : 'buildFrameworkIdentifier' , value : 'Gant' )
       }
     }
     if ( ( testCase == null ) || ( testCase ==~ 'org.codehaus.gant.ant.tests.*_Test' ) ) {                        
@@ -293,6 +303,7 @@
         formatter ( type : 'xml' ) // Must have XML output for the continuous integration builds.
         batchtest ( todir : buildTestReportsDirectory ) { fileset ( dir : buildTestClassesDirectory , includes : '**/ant/tests/*_Test.class' ) }
         classpath { path ( refid : testClasspathId ) }
+        sysproperty ( key : 'buildFrameworkIdentifier' , value : 'Gant' )
       }
     }
     junitreport ( todir : buildTestReportsDirectory ) {

Modified: gant/trunk/build.gradle (10431 => 10432)

--- gant/trunk/build.gradle	2009-10-18 19:12:39 UTC (rev 10431)
+++ gant/trunk/build.gradle	2009-10-18 19:12:48 UTC (rev 10432)
@@ -93,7 +93,19 @@
     testRuntime ( 'org.apache.ivy:ivy:' + ivyVersion )
   }
   compileGroovy.options.compilerArgs = ['-Xlint']
-  test.doLast { groovyAntTaskTestVersionPropertyFile.delete ( ) }
+  test {
+    //
+    //  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
+    //  needs to know whether this is a Gradle build or not.  Use a property.
+    //
+    //  This seems like an ugly way of setting properties in the forked test JVM.
+    //
+    options.fork ( jvmArgs: [ "-DbuildFrameworkIdentifier=Gradle" ]  )
+    doLast { groovyAntTaskTestVersionPropertyFile.delete ( ) }
+  }
   clean.doLast {
     ant.delete { fileset ( dir : '.' , includes : '**/*~, texput.log' ) }
     ant.delete ( dir :  'target_forMavenTest' )
@@ -132,7 +144,7 @@
   task documentation ( dependsOn: [ 'javadoc' , 'groovydoc' ] , description : 'Create the API documentation.' )
   uploadArchives {
     repositories.mavenDeployer {
-      uniqueVersion = false
+      //uniqueVersion = false
       //configuration = configurations.deployerJars
       repository ( url : 'https://dav.codehaus.org/repository/gant' )
       snapshotRepository ( url : 'https://dav.codehaus.org/snapshots.repository/gant' )

Modified: gant/trunk/src/test/groovy/org/codehaus/gant/ant/tests/Gant_Test.java (10431 => 10432)

--- gant/trunk/src/test/groovy/org/codehaus/gant/ant/tests/Gant_Test.java	2009-10-18 19:12:39 UTC (rev 10431)
+++ gant/trunk/src/test/groovy/org/codehaus/gant/ant/tests/Gant_Test.java	2009-10-18 19:12:48 UTC (rev 10432)
@@ -40,7 +40,7 @@
   private final String endOfTargetMarker = "------ " ;
   private final String separator = System.getProperty ( "file.separator" ) ;
   private final boolean isWindows = System.getProperty ( "os.name" ).startsWith ( "Windows" ) ;
-  private final String locationPrefix = ( true ? ".." + separator : "" ) ;
+  private final String locationPrefix = ( "Gradle".equals ( System.getProperty ( "buildFrameworkIdentifier" ) ) ? ".." + separator : "" ) ;
   private final String path ; {
     final StringBuilder sb = new StringBuilder ( ) ;
     sb.append ( "src" ) ;
@@ -65,10 +65,8 @@
     try { absolutePath =  ( new File ( locationPrefix + path ) ).getCanonicalPath ( ) ; }
     catch ( final IOException ioe ) { throw new RuntimeException ( "Canonical path calculation failure." , ioe ) ; }
     antFile =  new File ( absolutePath , "gantTest.xml" ) ;
-  }  
-
+  }
   private Project project ;
-
   //  This variable is assigned in the Gant script hence the public static.
   public static String returnValue ;
 
@@ -287,6 +285,7 @@
     //  TODO : Should this be sb.append ( absolutePath ) ?  cf. GANT-50.
     //
     sb.append ( System.getProperty ( "user.dir" ) ) ;
+    //sb.append ( absolutePath ) ;
     sb.append ( "\n   [groovy] " + endOfTargetMarker + "default\n   [groovy] \n\nBUILD SUCCESSFUL\n\n" ) ;
     final List<String> result = runAnt ( basedirAntFilePath , target , 0 , true ) ;
     assert result.size ( ) == 2 ;


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email