标签: exec-maven-plugin

使用运行thor脚本的Exec Maven插件构建失败

我有一个简单的thor脚本,它将资源从我项目中的子模块复制到目标目录.我已经配置了Exec Maven插件来在编译阶段运行脚本.

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <executable>thor</executable>
                <arguments>
                    <argument>build:task</argument>
                </arguments>
            </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

从使用thor build:task的shell执行时,我的thor脚本运行正常但由于某种原因我的mvn编译失败并出现以下错误:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default) on project imsprocess: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default) on project imsprocess: Command execution failed.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
Run Code Online (Sandbox Code Playgroud)

在错误消息之前,我可以看到我的脚本打印消息,它似乎工作正常.构建在没有exec插件的情况下完成.

maven thor exec-maven-plugin

2
推荐指数
1
解决办法
2384
查看次数

在exec-maven-plugin中设置systemProperty不起作用

这是我的pom.xml文件:

<project>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.test</groupId>
    <artifactId>test</artifactId>
    <version>1.0-SNAPSHOT</version>

    <profiles>
        <profile>
            <id>my_proj</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.4.0</version>
                        <executions>
                            <execution>
                                <phase>install</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>

                            <executable>java</executable>
                            <arguments>
                                <argument>-classpath</argument>
                                <classpath />
                                <argument>com.test.Main</argument>

                            </arguments>
                            <systemProperties>
                                <systemProperty>
                                    <key>someKey</key>
                                    <value>someValue</value>
                                </systemProperty>
                            </systemProperties>
                            <environmentVariables>
                                <someKey>
                                    someValue
                                </someKey>
                            </environmentVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>

        </profile>
    </profiles>

</project>
Run Code Online (Sandbox Code Playgroud)

并在Main.java中

public static void main(String[] args) {

    System.out.println("hello world" + System.getenv("someKey") + " " + System.getProperty("someKey"));
}
Run Code Online (Sandbox Code Playgroud)

我运行时的输出

mvn install -Pmy_proj
Run Code Online (Sandbox Code Playgroud)

hello worldsomeValue null
Run Code Online (Sandbox Code Playgroud)

我似乎无法获得systemProperty值.我做错了什么 ?

java pom.xml maven-3 maven exec-maven-plugin

2
推荐指数
1
解决办法
8192
查看次数

如何在单个pom.xml中使用maven执行多个命令提示符命令

我想使用单个pom.xml在maven中运行多个命令提示符命令.我怎样才能做到这一点?

例如:我有2个命令要执行.我正在使用执行第一个命令exec-maven-plugin.下面是我的pom.xml执行第一个命令的部分:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
            <id>load files</id>
            <phase>install</phase>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
    <configuration>

        <executable>windchill</executable>
        <arguments>
            <argument>wt.load.LoadFileSet</argument>
            <argument>-file</argument>
            <argument>${basedir}/fileSet.xml</argument>
            <argument>-UNATTENDED</argument>
            <argument>-NOSERVERSTOP</argument>
            <argument>-u</argument>
            <argument>wcadmin</argument>
            <argument>-p</argument>
            <argument>wcadmin</argument>
        </arguments>

    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

为此,构建是成功的.是否可以在同一个pom.xml中执行另外一个命令?我无法做到这一点.所以有人请帮助如何在pom.xml中添加它

maven exec-maven-plugin

1
推荐指数
1
解决办法
7997
查看次数

我们可以在 maven-surefire-plugin 之前执行 exec-maven-plugin 吗?

是否可以在 maven-surefire-plugin 之前运行 exec-maven-plugin,我在运行过程中观察到 maven-surefire-plugin 首先执行,即使标记中的序列是第二个。我的场景是执行 JAVA CLASS (使用 exec-maven-plugin ),它生成我的 testng.xml 并可以使用(maven-surefire-plugin)运行它。

maven exec-maven-plugin maven-surefire-plugin

1
推荐指数
1
解决办法
2356
查看次数

使用 Maven 运行多个类

我有一个包含多个类的包(每个类都封装一个可执行程序,即使用 main() 方法),即:

com.myorg.examples.classA
com.myorg.examples.classB
etc.
Run Code Online (Sandbox Code Playgroud)

所有的类都属于同一个包 ( com.myorg.examples)。

我知道我可以使用Maven运行一个这样的类,例如:

mvn exec:java -D"exec.mainClass"="com.myorg.examples.classA"
Run Code Online (Sandbox Code Playgroud)

我也知道我可以配置 exec-maven-plugin 以便使用较短的命令执行相同的操作,例如:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.2.1</version>
  <executions>
    <execution>
      <goals>
        <goal>java</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <mainClass>com.myorg.examples.classA</mainClass>
  </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

然后使用:

mvn exec:java
Run Code Online (Sandbox Code Playgroud)

但是,我想知道是否有可能:

  1. 使用 exec-maven-plugin(或另一个)来配置多个执行并执行类似的操作

    mvn exec:classA       # or,
    mvn exec:java classA 
    
    Run Code Online (Sandbox Code Playgroud)

    因此运行 classA,但使用比普通 exec:java 更短的语法。查看 XML 结构,似乎只能设置一个类,所以我不确定如何实现。

  2. 要按顺序执行所有类,例如:

    mvn exec-all
    
    Run Code Online (Sandbox Code Playgroud)

    为了运行classA,下一个classB,等等。

任何有关这些主题的帮助或链接都将受到高度欢迎。谢谢!

编辑:问题的第二部分已被分拆到另一个帖子

java maven exec-maven-plugin

0
推荐指数
1
解决办法
2419
查看次数