Mavenのpom.xmlからシェルコマンドを実行したい 質問する

Mavenのpom.xmlからシェルコマンドを実行したい 質問する

Maven で Linux シェル コマンドを実行したいです。試したことは次のとおりです。

<plugin>  
  <groupId>org.codehaus.mojo</groupId> 
  <artifactId>exec-maven-plugin</artifactId> 
  <version>1.1.1</version> 
  <executions>
    <execution>
      <goals>
        <goal>exec</goal> 
      </goals>
    </execution>
  </executions>
  <configuration>
    <executable>hostname</executable> 
  </configuration>
</plugin>

ベストアンサー1

私にとって効果的だったのは次の通りです:

<plugin>
  <artifactId>exec-maven-plugin</artifactId>
  <groupId>org.codehaus.mojo</groupId>
  <executions>
    <execution><!-- Run our version calculation script -->
      <id>Version Calculation</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>exec</goal>
      </goals>
      <configuration>
        <executable>${basedir}/scripts/calculate-version.sh</executable>
      </configuration>
    </execution>
  </executions>
</plugin>

おすすめ記事