2017-12-26 13 views
1

ist dies eine groovy Skriptdatei MavenInit.groovy, führen Sie in einer pom.xml wie folgt, die var 'SCRIPTS_GROOVY' ist in einer anderen pom.xml definiert, was mich verwirren kann ich nicht finden wo die "DIR_TARGET" Definition und wie ohne direkte ant können ant = new AntBuilder()Wie verwendet die Ameise in groovy

SCRIPTS_GROOVY=project.properties['SCRIPTS_GROOVY'] 
ant.pathconvert(targetos:"unix", property:"DIR_TARGET") { 
    path(location:project.build.directory) 
} 
DIR_TARGET=ant.project.properties['DIR_TARGET'] 
project.properties.setProperty('DIR_TARGET', "${DIR_TARGET}") 
project.properties.setProperty('DIR_LOGS', "${DIR_TARGET}/logs") 
ant.mkdir(dir:"${DIR_TARGET}/logs") 

die pom.xml die MavenInit.groovy excute als

<plugin> 
    <groupId>org.codehaus.gmavenplus</groupId> 
    <artifactId>gmavenplus-plugin</artifactId> 
    <executions> 
     <execution> 
     <id>set-maven-property</id> 
     <phase>initialize</phase> 
     <goals> 
      <goal>execute</goal> 
     </goals> 
     <configuration> 
      <scripts> 
      <script>file:///${SCRIPTS_GROOVY}/MavenInit.groovy</script> 
      </scripts> 
     </configuration> 
     </execution> 
     <execution> 
     <id>Windows-package</id> 
     <phase>compile</phase> 
     <goals> 
      <goal>execute</goal> 
     </goals> 
     <configuration> 
      <scripts> 
      <script>file:///${SCRIPTS_GROOVY}/PackageWindows.groovy</script> 
      </scripts> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

folgen, wie kann ich die 'DIR_TARGET anfänglichen finden definiert und ändern Sie den Wert

Antwort

0

GMavenplus Plugin set an ant property in sein Skript

if (!properties.containsKey("ant")) { 
      try { 
       Object antBuilder = invokeConstructor(findConstructor(classWrangler.getClass("groovy.util.AntBuilder"))); 
       properties.put("ant", antBuilder); 
      } 

Auch gibt es andere Eigenschaften wie project, log usw.


Über DIR_TARGET, ich denke, es wird der Wert von project.build.directory mit Pfadseparator normiert als unix like, von path(location: project.build.directory).

(Ich bin nicht eine Ameise Experte, aber ich teste auf meinem Computer und diese zwei gleichen Wert haben. Sie die Log-Zeilen hinzufügen

log.info(project.build.directory) 
DIR_TARGET = ant.project.properties['DIR_TARGET'] 
log.info(DIR_TARGET) 

ich die Ameise doc gesucht, um zu sehen und finden ein Beispiel aus https://ant.apache.org/manual/Tasks/pathconvert.html, die meine Vermutung bestätigt.

<pathconvert property="prop" dirsep="|"> 
     <map from="${basedir}/abc/" to=''/> 
     <path location="abc/def/ghi"/> 
    </pathconvert> 
+0

Vielen Dank, und könnten Sie bitte erraten, wo die $ {DIR_TARGET} definierte Ausgangs kann? ich lokale globale Suche verwenden, kann aber n ot finden wo die $ {DIR_TARGET} definiert –

+0

@TJSeason Ich habe meine Antwort aktualisiert. – aristotll