2016-07-14 10 views
1

すぐに言うでしょう:私はMaven/Groovyを使ったことはありませんでしたが、最近は.propertiesファイルから列挙型を自動的に作成するスクリプトを書く仕事をしています。このようなプロパティはありません:class1のpom:Script1

私はこれにGMavenPlusプラグインを使用します。私はすでにthis質問への答えの後にモデル化されたスクリプトを書いた。答えと同じpomを使用できない理由は、GMavenを使用しているためです。これは中止されました。

  <plugin> 
      <groupId>org.codehaus.gmavenplus</groupId> 
      <artifactId>gmavenplus-plugin</artifactId> 
      <version>1.5</version> 

      <executions> 
       <execution> 
        <id>create-enum</id> 
        <phase>generate-sources</phase> 
        <goals> 
         <goal>execute</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <scripts> 
        <script><![CDATA[ 
        import java.io.File 
        import com.cclsd.gdg.client.EnumGenerator 

        File dir = new File(pom.basedir, 
         "src/main/resources/com/cclsd/gdg/client") 

        new EnumGenerator(
         new File(pom.build.directory, 
          "generated-sources/enums"), 
         new File(dir, 
         "properties/config.properties"), 
         new File(dir, 
          "EnumTemplate.txt"), 
         "com.cclsd.gdg.client.data", 
         "PropertyEnum" 
         ) 
       ]]></script> 
       </scripts> 
      </configuration> 

      <dependencies> 
       <dependency> 
        <groupId>org.codehaus.groovy</groupId> 
        <artifactId>groovy-all</artifactId> 
        <!-- any version of Groovy \>= 1.5.0 should work here --> 
        <version>2.4.7</version> 
        <scope>runtime</scope> 
       </dependency> 
      </dependencies> 
     </plugin> 
    </plugins> 
    <pluginManagement> 
     <plugins> 
      <!--This plugin's configuration is used to store Eclipse m2e settings 
       only. It has no influence on the Maven build itself. --> 
      <plugin> 
       <groupId>org.eclipse.m2e</groupId> 
       <artifactId>lifecycle-mapping</artifactId> 
       <version>1.0.0</version> 
       <configuration> 
        <lifecycleMappingMetadata> 
         <pluginExecutions> 
          <pluginExecution> 
           <pluginExecutionFilter> 
            <groupId> 
             org.codehaus.gmavenplus 
            </groupId> 
            <artifactId> 
             gmavenplus-plugin 
            </artifactId> 
            <versionRange> 
             [1.0.0,) 
            </versionRange> 
            <goals> 
             <goal>execute</goal> 
            </goals> 
           </pluginExecutionFilter> 
           <action> 
            <execute> 
             <runOnIncremental>false</runOnIncremental> 
            </execute> 
           </action> 
          </pluginExecution> 
         </pluginExecutions> 
        </lifecycleMappingMetadata> 
       </configuration> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
</build> 

注:

私はCMDの上にそれを実行しようとしていたときに今、私はエラー

Failed to execute goal org.codehaus.gmavenplus:gmavenplus-plugin:1.5:execute <create-enum> on project gui: Error occurred while calling a method on a Groovy class 
from classpath. InvocationTargetException: No such property: pom for class: Script1 -> [Help 1] 

そして、ここを得るには、私のpom.xmlの重要な部分です:pluginmanagementタグの下にあるすべて私はthe official m2e siteから取得し、スクリプトをgenerate-sourcesフェーズで実行させる必要があります

私は本当にここで私を助ける人が必要です、私は文字通り、このエラーについてGoogleで一つの事を見つけることができませんでした。また、Maven上でスクリプトを実行することに関する包括的なチュートリアルはすばらしいでしょう。

は素敵な一日〜クロウリー

編集を持っている:それはまたのためのPOMを警告することは無効で表示し、推移傾向は(もしあれば)利用できません、あなたがしている詳細

答えて

1

のデバッグログを有効にしますgmavenプラグインで提供されていないpomプロパティにアクセスします。この種のスクリプトでは、projectプロパティを使用できます。このプロパティは、MavenProjectのインスタンスです。例えば

File dir = new File(project.basedir, "src/main/resources/com/cclsd/gdg/client") 
+0

まあ、これは屈辱的です。いずれにせよ、速い応答のために感謝:) –

関連する問題