我想建立一個小型Maven的基於項目的結構如下父POM建設問題的Liferay
Maven的結構
Project
\pom.xml
\Hello world portlet
\pom.xml
\Second Portlet
\pom.xml
正如你可以看到有幾個portlet的(在未來的主題,鉤,在相同的結構下)等。
現在內各個portlet我能夠運行Liferay的相關行家任務擊中MVN清潔編譯包的Liferay單獨進行部署:部署 我現在正在使用相同的構建和部署所有的Liferay Portlet相關文物命令。在這種情況下,我得到了父項目本身的錯誤(孩子liferay模塊正在建設中)。我不知道爲什麼它試圖構建父項目,儘管我的意圖是運行liferay:在孩子中部署相關任務。
<?xml version="1.0"?>
<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.test</groupId>
<artifactId>helloworld</artifactId>
<packaging>war</packaging>
<name>hello-world-portlet Portlet</name>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>${liferay.version}</version>
<configuration>
<autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
<liferayVersion>${liferay.version}</liferayVersion>
<apiDir>${service.api.dir}</apiDir>
<warFileName>${war.file.name}</warFileName>
<pluginType>portlet</pluginType>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${service.api.dir}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-bridges</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-taglib</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-java</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<liferay.auto.deploy.dir>D:/Projects/Bosch/Liferay Developer Studio/liferay-portal-6.1.10-ee-ga1/deploy</liferay.auto.deploy.dir>
<liferay.version>6.1.10</liferay.version>
<liferay.maven.version>6.1.0</liferay.maven.version>
<war.file.name>hellow-world-portlet.war</war.file.name>
<service.api.dir>src/main/java-service-api</service.api.dir>
</properties>
</project>
父POM
這裏的父pom.xml中
兒童POM
這裏是孩子的pom.xml(創建門戶時,這是默認生成) 。 (這個我手動創建google搜索相同的,添加模塊到它)
<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>MvnProject</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<!-- 3. List all children projects names (name is directory name as well). -->
<modules>
<module>ipc-portlet</module>
<module>helloworld</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
錯誤
下面是我得到
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] ipc-portlet Portlet ............................... SUCCESS [5.361s]
[INFO] hello-world-portlet Portlet ....................... SUCCESS [1.047s]
[INFO] MvnProject ........................................ FAILURE [2.500s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.236s
[INFO] Finished at: Fri May 25 16:49:12 IST 2012
[INFO] Final Memory: 7M/14M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'liferay' in the current project and in the p
lugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the re
positories [local (C:\Documents and Settings\sandeep.nair\.m2\repository), centr
al (http://repo.maven.apache.org/maven2)] -> [Help 1]
正如你可以看到生成的錯誤是成功的我想要的子模塊。但它也試圖爲父母執行它。我如何避免第三個構建發生,這是父項目。
看得很goog答案http://stackoverflow.com/questions/1501294/maven-skip-parent-project-build – Mark