Maven没有在构建时将.class文件复制到目标,虽然构建在Unix中运行良好,但在eclipse中同样有效

时间:2014-06-04 05:55:54

标签: java eclipse maven

您好我的父pom.xml中的maven编译器插件有以下pom配置

<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>com.test</groupId>
<artifactId>prj-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Parent</name>
<description>Parent</description>
<modules>
    <module>service</module>
    <module>web</module>
</modules>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.7</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <spring.version>4.0.4.RELEASE</spring.version>
    <spring-social.version>1.0.3.RELEASE</spring-social.version>
    <javax.validation.version>1.0.0.GA</javax.validation.version>
    <org.projectlombok.version>1.12.6</org.projectlombok.version>
    <slf4j-log4j12-version>1.7.5</slf4j-log4j12-version>
    <spring.security.version>3.2.1.RELEASE</spring.security.version>
    <jackson.version>2.2.2</jackson.version>
    <camel-version>2.12.2</camel-version>
    <camel-aws-version>2.13.1</camel-aws-version>
    <dozer-version>5.4.0</dozer-version>
    <junit.version>4.11</junit.version>
    <guava.version>14.0.1</guava.version>
    <force-api-version>28.0.0</force-api-version>
    <commons-lang-version>2.6</commons-lang-version>
    <ojdbc-version>11.2.0.3.0</ojdbc-version>
    <httpclient.version>4.3.1</httpclient.version>
    <mybatis-spring-version>1.2.2</mybatis-spring-version>
    <oracle.ucp.version>11.2.0.3</oracle.ucp.version>
    <org.hamcrest.version>1.3</org.hamcrest.version>
    <atomikos.version>3.9.3</atomikos.version>
    <spring-data-commons.version>1.8.0.RELEASE</spring-data-commons.version>
    <jta.version>1.1</jta.version>
    <rest-assured.version>2.3.1</rest-assured.version>
</properties>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <encoding>${project.build.sourceEncoding}</encoding>
                <showDeprecation>true</showDeprecation>
                <showWarnings>true</showWarnings>
                <useIncrementalCompilation>false</useIncrementalCompilation>
                <verbose>true</verbose>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>install</id>
                    <phase>install</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </configuration>
        </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on 
                the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.apache.maven.plugins
                                    </groupId>
                                    <artifactId>
                                        maven-antrun-plugin
                                    </artifactId>
                                    <versionRange>
                                        [2.4,)
                                    </versionRange>
                                    <goals>
                                        <goal>run</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-dependency-plugin</artifactId>
                                    <versionRange>[2.1,)</versionRange>
                                    <goals>
                                        <goal>copy-dependencies</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<repositories>      
    <repository>
        <id>maven-restlet</id>
        <name>Public online Restlet repository</name>
        <url>http://maven.restlet.org</url>
    </repository>
    <repository>
        <id>spring-milestone</id>
        <name>Spring Portfolio Milestone Repository</name>
        <url>http://maven.springframework.org/milestone </url>
    </repository>
    <repository>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>com.springsource.repository.maven.releases</id>
        <name>Spring Framework Maven General Releases (Maven Central Format)</name>
        <url>http://maven.springframework.org/release</url>
    </repository>
</repositories>

儿童pom

<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>
<parent>
    <groupId>com.test</groupId>
    <artifactId>parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>service</artifactId>
<name>service</name>
<description>service layer concerned with routing ,mapping and persistence</description>
<build>
    <finalName>service</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <tasks>
                            <copy file="src/main/resources/properties/app_${env}.properties" overwrite="true"
                                tofile="${project.build.outputDirectory}/properties/app.properties" />
                            <propertyfile file="${project.build.outputDirectory}/properties/app.properties">
                                <entry key="test.buildnumber" value="${project.version}" />
                            </propertyfile>
                            <!-- copy dozer files <copy todir="${dozer.directory}"> <fileset dir="src/main/resources/dozer/" 
                                /> </copy> -->
                            <!-- <copy file="src/main/resources/properties/dfc_${env}.properties" overwrite="true" tofile="${project.build.outputDirectory}/dfc.properties" 
                                /> -->
                        </tasks>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>ant</groupId>
                    <artifactId>ant-optional</artifactId>
                    <version>1.5.3-1</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on 
                the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.apache.maven.plugins
                                    </groupId>
                                    <artifactId>
                                        maven-antrun-plugin
                                    </artifactId>
                                    <versionRange>
                                        [1.3,)
                                    </versionRange>
                                    <goals>
                                        <goal>run</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<dependencies>
    <!-- Spring dependencies -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.social</groupId>
        <artifactId>spring-social-core</artifactId>
        <version>${spring-social.version}</version>
    </dependency>
    <!-- persistence -->
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ucp</artifactId>
        <version>${oracle.ucp.version}</version>
    </dependency>
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis-spring</artifactId>
        <version>${mybatis-spring-version}</version>
    </dependency>
    <!-- <dependency> <groupId>com.atomikos</groupId> <artifactId>transactions-jta</artifactId> <version>${atomikos.version}</version> 
        </dependency> <dependency> <groupId>com.atomikos</groupId> <artifactId>transactions-jdbc</artifactId> 
        <version>${atomikos.version}</version> </dependency> <dependency> <groupId>javax.transaction</groupId> 
        <artifactId>jta</artifactId> <version>${jta.version}</version> </dependency> -->
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-commons</artifactId>
        <version>${spring-data-commons.version}</version>
    </dependency>
    <!-- sforce apis -->
    <dependency>
        <groupId>com.force.api</groupId>
        <artifactId>force-partner-api</artifactId>
        <version>${force-api-version}</version>
    </dependency>
    <!-- integration apis -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>${camel-version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring</artifactId>
        <version>${camel-version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-aws</artifactId>
        <version>${camel-aws-version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-test</artifactId>
        <version>${camel-version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-test-spring</artifactId>
        <version>${camel-version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-mybatis</artifactId>
        <version>${camel-version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring-javaconfig</artifactId>
        <version>${camel-version}</version>
    </dependency>
    <!-- convertor apis -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${jackson.version}</version>
    </dependency>
    <!-- other dependencies -->
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>${httpclient.version}</version>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>${ojdbc-version}</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>${commons-lang-version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>${guava.version}</version>
    </dependency>
    <dependency>
        <groupId>net.sf.dozer</groupId>
        <artifactId>dozer</artifactId>
        <version>${dozer-version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${slf4j-log4j12-version}</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${org.projectlombok.version}</version>
    </dependency>
    <!-- Test -->
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <version>${org.hamcrest.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-library</artifactId>
        <version>${org.hamcrest.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
    </dependency>
</dependencies>

这个在我的父模块中,我有两个子模块。虽然在eclipse上构建一切正常但我在目标文件夹中看到我的类和资源但是在构建unix时构建不复制我的类文件虽然它在下面的行中说明,虽然资源被复制。我的java版本是1.7

unix中使用的命令

mvn -X clean install package -Dmaven.test.skip = true -Denv = test -Dversion = 0.1

Maven版本Apache Maven 3.0.3

[INFO] Compiling 82 source files to /build/project/xyz/build/0.1/xyz-service/target/classes

任何人都可以帮我解决一个非常奇怪的问题!!

1 个答案:

答案 0 :(得分:0)

嗨我终于在详细模式下进行编译时想出来了。像我的一个类似的没有被编译,因为一些奇怪的问题导致了lombok注释。但奇怪的是javac和maven都没有刷新任何错误并发出构建信号要成功..

所以我通过删除注释来修正类,现在一切看起来都很好.. :)

  

不确定问题是maven还是javac,但要么应该看看这样的场景,因为它们在我看来可能是错误

帮助

的链接

http://mail-archives.apache.org/mod_mbox/maven-users/201307.mbox/%3CCABN1Dbpn3vCxPiFS6SqUZsk0zkUZ9kZ=h8LHuC2qR2MoG7Azow@mail.gmail.com%3E

javac issue