0

这是我们目前拥有的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.atlantis.amc</groupId>
    <name>amc-gui</name>
    <artifactId>gui</artifactId>

    <properties>
        <jettyVersion>8.1.9.v20130131</jettyVersion>
    </properties>

    <parent>
        <groupId>com.atlantis</groupId>
        <artifactId>amc</artifactId>
        <version>5.0.0.47</version>
        <relativePath>..</relativePath>
    </parent>

    <dependencies>
        <!-- Servlet API -->
        <!--dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> 
            </dependency -->

        <!-- Jetty -->
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <version>${jettyVersion}</version>
        </dependency>

        <!-- For the ProxyServlet -->
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlets</artifactId>
            <version>${jettyVersion}</version>
        </dependency>

        <!-- JSP Support -->
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-jsp-2.1</artifactId>
            <version>7.2.2.v20101205</version>
        </dependency>
        <dependency>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jsp-2.1-glassfish</artifactId>
            <version>2.1.v20100127</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <finalName>amc-gui</finalName>
                    <archiveClasses>true</archiveClasses>
                    <archive>
                        <manifest>
                            <mainClass>com.atlantis.amc.AmcWebApp</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <finalName>amc-server</finalName>
                    <createDependencyReducedPom>true</createDependencyReducedPom>
                    <!-- <minimizeJar>true</minimizeJar> -->
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>junit:junit</exclude>
                                <exclude>jmock:*</exclude>
                                <exclude>org.apache.maven:lib:tests</exclude>
                                <exclude>log4j:log4j:jar:</exclude>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                    </filters>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                        <finalName>amc-gui</finalName>
                            <!-- <minimizeJar>true</minimizeJar> -->
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.atlantis.amc.AmcWebApp</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2</version>
                <configuration>
                    <mainClass>com.atlantis.amc.AmcWebApp</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

这是我认为我们需要的 pom.xml(它添加了 sencha cmd 工具的执行):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.atlantis.amc</groupId>
    <name>amc-gui</name>
    <artifactId>gui</artifactId>

    <properties>
        <jettyVersion>8.1.9.v20130131</jettyVersion>
    </properties>

    <parent>
        <groupId>com.atlantis</groupId>
        <artifactId>amc</artifactId>
        <version>5.0.0.47</version>
        <relativePath>..</relativePath>
    </parent>

    <dependencies>
        <!-- Servlet API -->
        <!--dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> 
            </dependency -->

        <!-- Jetty -->
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <version>${jettyVersion}</version>
        </dependency>

        <!-- For the ProxyServlet -->
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlets</artifactId>
            <version>${jettyVersion}</version>
        </dependency>

        <!-- JSP Support -->
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-jsp-2.1</artifactId>
            <version>7.2.2.v20101205</version>
        </dependency>
        <dependency>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jsp-2.1-glassfish</artifactId>
            <version>2.1.v20100127</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <finalName>amc-gui</finalName>
                    <archiveClasses>true</archiveClasses>
                    <archive>
                        <manifest>
                            <mainClass>com.atlantis.amc.AmcWebApp</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <finalName>amc-server</finalName>
                    <createDependencyReducedPom>true</createDependencyReducedPom>
                    <!-- <minimizeJar>true</minimizeJar> -->
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>junit:junit</exclude>
                                <exclude>jmock:*</exclude>
                                <exclude>org.apache.maven:lib:tests</exclude>
                                <exclude>log4j:log4j:jar:</exclude>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                    </filters>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                        <finalName>amc-gui</finalName>
                            <!-- <minimizeJar>true</minimizeJar> -->
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.atlantis.amc.AmcWebApp</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2</version>
                <configuration>
                    <mainClass>com.atlantis.amc.AmcWebApp</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <id>sencha-compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>sencha</executable>
                            <workingDirectory>src/main/extApps/usx</workingDirectory>
                            <arguments>
                                <argument>app</argument>
                                <argument>build</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

但是由于某种原因,sencha cmd 工具会执行,但 Java org.codehaus.mojo 的预先存在的执行不再发生。我错过了什么?

4

1 回答 1

0

通过将执行描述添加到 maven 插件,您已经覆盖了 maven maven 插件的默认行为。插件不再执行插件中的 ExecJavaMojo.class。您的目标似乎是运行插件的 ExecJavaMojo 和 ExecMojo。(http://svn.codehaus.org/mojo/tags/exec-maven-plugin-1.2.1/src/main/java/org/codehaus/mojo/exec/

要解决此问题,您需要两个部分来触发具有不同目标的 exec-maven-plugin。

      `<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2</version>
            <executions>               <!-- trigger plugin with goal exec -->
                <execution>
                    <id>sencha-compile</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <executable>sencha</executable>
                        <workingDirectory>src/main/extApps/usx</workingDirectory>
                        <arguments>
                            <argument>app</argument>
                            <argument>build</argument>
                        </arguments>
                    </configuration>
                </execution>
                <execution> <!-- trigger plugin with goal java .... id,phase and goals should be optional cause you use default settings as in your first pom.xml -->
                    <id>stackoverflow</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>java</goal>
                    </goals>
                  <configuration>
                    <mainClass>com.atlantis.amc.AmcWebApp</mainClass>
                  </configuration>
                </execution>
            </executions>
        </plugin>
于 2014-03-02T15:51:07.713 回答