2017-12-26 14 views
1

これはgroovyスクリプトファイルMavenInit.groovyで、次のようにpom.xmlで実行します。var 'SCRIPTS_GROOVY'は別のpom.xmlで定義されています。 「DIR_TARGET」の定義は、どのようにant = new AntBuilder()どのように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") 

ずに直接アリを使用できる場所のpom.xmlは、私が定義された「DIR_TARGET」が初期見つけることができますどのように

<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> 

に従うようMavenInit.groovyをexcute値を変更する

について、そのスクリプトに210

答えて

0

GMavenplusプラグインset an ant property

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

またprojectような他の特性等、log、ある


、私はそれが正規のパスセパレータproject.build.directoryの値だと思いますunixのように、path(location: project.build.directory)から。

(私はアリ専門家ではないが、私は自分のコンピュータ上でテストし、これらの2つが同じ値を持っている。 ちょうど

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

を見るために、ログの行を追加し、私はアリドキュメントを検索し、見つけます$ {DIR_TARGETは} I nはローカルのグローバル検索を使用することができますが?定義された初期もどこ私の推測を検証https://ant.apache.org/manual/Tasks/pathconvert.htmlからの例、。

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

本当にありがとうございました、とあなたは推測してください可能性がありotどこ$ {DIR_TARGET}は –

+0

@ TJSeasonを定義した私の答えを更新しました。 – aristotll

関連する問題