7

我有一个带有 maven pom.xml 的项目

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>Minimal-J</groupId>
    <artifactId>Minimal-J</artifactId>
    <version>0.1-SNAPSHOT</version>
    <name>Minimal-J</name>
    <dependencies>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <version>10.8.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derbyclient</artifactId>
            <version>10.8.2.2</version>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin</artifactId>
            <version>6.7.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-core</artifactId>
            <version>3.4.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.miglayout</groupId>
            <artifactId>miglayout</artifactId>
            <version>3.7.4</version>
        </dependency>
        <dependency>
            <groupId>commons-dbutils</groupId>
            <artifactId>commons-dbutils</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20090211</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <version>2.3.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <packaging>pom</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

如果我执行

mvn 编译器:编译

我的所有 189 个 Java 类都已编译

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Minimal-J 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-compiler-plugin:2.4:compile (default-cli) @ Minimal-J ---
[INFO] Compiling 189 source files to C:\projects\open-ech\workspace\minimal-j\MinimalJ\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.386s
[INFO] Finished at: Fri May 11 11:50:54 CEST 2012
[INFO] Final Memory: 13M/37M
[INFO] ------------------------------------------------------------------------

如果我只是输入

mvn 编译

似乎什么都没做:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Minimal-J 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.120s
[INFO] Finished at: Fri May 11 11:53:36 CEST 2012
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------

在另一个项目中,一切正常。

我可能在哪里配置了错误的东西来触发这种行为?

4

1 回答 1

9

是因为pom包装。通过调用mvn compiler:compile您在 Maven 的默认生命周期之外运行compile目标,并且基本上将源代码编译为src/main/java. 并且通过mvn compile您将生命周期运行到compile各个阶段,并且在每个阶段执行的实际目标取决于项目的包装类型。pom-type 项目在阶段中什么都不做compile,因为 - 事实上 - 没有什么可以用 POM 编译。

我想您的意图是进行jar包装和更改,这应该会有所帮助。

于 2012-05-11T10:59:17.243 回答