要创建我的应用程序的配置,我需要运行bash脚本.是否有可能在Maven中集成bash脚本的执行,也许有一些插件?谢谢.
Adr*_*ien 19
可以在猛砸Maven插件帮助你吗?(免责声明:我发起了,所以请给我反馈)
<build>
<plugins>
<plugin>
<!-- Run with:
mvn bash:run
mvn install
-->
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>bash-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<id>test</id>
<phase>integration-test</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<script>
# Here you can execute shell commands
echo "Tomcat will start"
/opt/apache-tomcat/bin/startup.sh
</script>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
您需要在自己的Maven仓库中安装此maven插件.
像Konstantin一样:当你执行shell脚本时,你就不再可移植了.
Kon*_*uda 14
你可以这样做,看看答案:
但这不可取,因为这不会产生可移植的构建.为什么你首先需要这个?使用此插件通常表明项目构建中有一些奇怪的必要性
小智 6
看起来更像:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>generateSources</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<exec executable="/bin/bash">
<arg value="myFirst.sh" />
<arg value="inputOne" />
</exec>
<exec executable="/bin/bash">
<arg value="src/mySecond.sh" />
<arg value="inputTwo" />
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
使用myFirst.sh:
echo "call to myFirst.sh, message ${1}"
Run Code Online (Sandbox Code Playgroud)
小智 6
解决了。问题是,可执行文件在 bash 中以不同的方式工作。这段代码正在运行。写在pom.xml中
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution><!-- Run our version calculation script -->
<id>Renaming build artifacts</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>bash</executable>
<commandlineArgs>handleResultJars.sh</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
66054 次 |
| 最近记录: |