我正在轉換maven中一個最初依賴eclipse和ant構建的舊項目。 指出我不能冠以那個項目的目錄佈局,我想產生一些類似於用這個ant腳本構建的工件。原始項目使用eclipse在一個目錄中使用子項目構建所有類,然後在子包中(與子項目不同)將生成的類與ant打包。Maven無法創建一個包含多個源目錄的項目
爲了應對這種要求,我已經做了以下結構:(因爲現在只有分包之一)
warp-parent
|
|- pom.xml
|- warp-client
| |
| | - pom.xml
父POM如下:
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>it.sinesy.warp</groupId>
<artifactId>warp-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>warp-parent</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>../../src</source>
<source>../../srcj2ee</source>
<source>../../srcjsf</source>
<source>../../srcrest</source>
<source>../../srcswing</source>
<source>../../srctest</source>
<source>../../srcweb</source>
<source>../../srcws</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
</dependencies>
<modules>
<module>warp-client</module>
</modules>
</project>
和孩子一:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>it.sinesy.warp</groupId>
<artifactId>warp-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>it.sinesy.warp</groupId>
<artifactId>warp-client</artifactId>
<version>1.0-SNAPSHOT</version>
<name>warp-client</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<includes>
<include>**</include>
<!--
<include>**/it/tinet/warp/swing/**/java/*</include>
<include>**/it/tinet/warp/common/**/java/*</include>
<include>**/it/tinet/warp/swing/**/client/*</include> -->
</includes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
</dependencies>
</project>
當我試圖編譯編譯父pom我得到了以下輸出,沒有sou rce編譯:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] warp-parent
[INFO] warp-client
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building warp-parent 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) @ warp-parent ---
[INFO] Source directory: /home/elettronik/test/warp/warp_src/src added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srcj2ee added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srcjsf added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srcrest added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srcswing added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srctest added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srcweb added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srcws added.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building warp-client 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) @ warp-client ---
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/src added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srcj2ee added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srcjsf added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srcrest added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srcswing added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srctest added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srcweb added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srcws added.
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ warp-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/elettronik/test/warp/warp_src/mvn/warp-parent/warp-client/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ warp-client ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] warp-parent ....................................... SUCCESS [0.762s]
[INFO] warp-client ....................................... SUCCESS [1.389s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.389s
[INFO] Finished at: Fri Aug 16 14:03:32 CEST 2013
[INFO] Final Memory: 6M/109M
[INFO] ------------------------------------------------------------------------
有人可以給一些建議,使這項工作?謝謝大家。
難道你不能只將這些源代碼作爲warp-parent下的獨立模塊進行編譯,並將它作爲依賴項添加到warp-client中嗎? –