English 中文(简体)
父母用救生衣制造问题
原标题:Parent Pom build problems with Liferay

我正试图建立一个以小maven为主的项目结构如下:

Maven Structure

Project
pom.xml
Hello world portlet
  pom.xml
Second Portlet
  pom.xml

如您所见,在项目下有几条端口(在未来主题下,hook,etc在相同的结构下)。

Now within individual portlets I am able to run liferay related maven tasks to deploy them individually by hitting mvn clean compile package liferay:deploy Now I am looking to build and deploy all the Liferay portlet related artifacts using the same command. In that case I am getting an error for the parent project itself(the child liferay modules are building fine). I am not sure why its trying to build the parent project too, though my intention is just run the liferay:deploy related tasks in child.

Child POM

s 在这里孩子的 pom. xml (这是创建端口时产生的默认值)

<?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>

Parent POM

这里为父体的 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>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>

Error

这是我要犯的错误

[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 Settingssandeep.nair.m2
epository), centr
al (http://repo.maven.apache.org/maven2)] -> [Help 1]

正如您所看到的, 构建对于我所想要的子模块来说是成功的。 但是它也试图为父体执行它。 我怎样才能避免第三构建, 也就是父体项目。

最佳回答

您需要将自定义 plugin Group 添加到 sections. xml 上 :

<pluginGroups>
  <pluginGroup>com.liferay.maven.plugins</pluginGroup>
</pluginGroups>

然后您可以使用名为 liferray:depploy 的第三个政党插件。请查看,了解更多细节。

问题回答

当Maven执行带有子模块的项目时,Maven首先装载母体POM, 并定位所有子模块POMs。 Maven然后将所有这些项目POMs置于一个名为 Maven 堆中, 分析模块之间的依赖关系。 反应堆负责订购组件, 以确保独立模块的编译和安装符合正确的顺序。 最后, 它以相同的命令执行母体项目 。

当儿童项目试图对失败的父母执行相同的命令时, 儿童项目可以成功建立, 正如您在儿童垃圾堆中宣布的生命射线插件一样 。

<强度 > 解决方案:

选择 1 : < em% 强 > 将生命线插件声明移到父 pum 上 。

@Michal Kalinowski 方法 : @michal Kalinowski 方法

To solve this problem I followed below approach, and it works. My project structure:

--liferay-core
|
-- portlet-one
|
-- portlet-two
|
-- theme-one
|
-- hook-one

这里,生命射线核心模块被定义为所有其他插件的母体,此外,所有其他插件被定义为生命射线-核心/pom.xml中的。此外,生命射线-核心/pom.xml有生命射线-成像-插件的插件定义。同样,每个插件也有生命射线-成像-插件的插件定义。请参见下面的生命射线-核心/pom.xml的 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>

<artifactId>liferay-core</artifactId>
    <groupId>xxxx</groupId>
<packaging>pom</packaging>
    <version>0.0.1-SNAPSHOT</version>
<name>liferay-plugins</name>

<modules>       
    <module>./../portlet-clientsearch</module>
    <module>./../portlet-permission</module>
    <module>./../qpt-theme</module>
    <module>./../hook-post-login</module>
    <module>./../hook-quote-portal-autologin</module>
    <module>./../hook-post-logout</module>
</modules>

<properties>
    <liferay.auto.deploy.dir>C:/liferay-portal-6.1.20-ee-ga2/deploy</liferay.auto.deploy.dir>
    <liferay.version>6.1.20</liferay.version>
</properties>

<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>
                <appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
                <appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
                <appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
                <liferayVersion>${liferay.version}</liferayVersion>
                <pluginType>portlet</pluginType>
            </configuration>
        </plugin>
    </plugins>
</build>    





相关问题
JavaFX with Maven [closed]

I recently started a JavaFX project, and I d like to use Maven as my compiler/deployment tool. Is there a good tutorial or plugin to integrate JavaFX and Maven?

How to upload jar to respository?

I have jar files that cannot be found on Maven Central repository. I would like to add the jar so I can just include extra tag in my pom.xml file and other developer can use the jar. What are the ...

Debug Maven project in Eclipse with third party sources

I am currently developing a maven project in eclipse. The m2eclipse plugin works beautifully. It even works out of the box with debugging. But when I am debugging open source third party libarries. ...

Could Free Pascal benefit of something like Apache Maven?

Apache Maven is a very popular build and dependency management tool in the Java open source ecosphere. I did some tests to find out if it can handle compiled Free Pascal / Delphi units and found it ...

Run a single test method with maven

I know you can run all the tests in a certain class using: mvn test -Dtest=classname But I want to run an individual method and -Dtest=classname.methodname doesn t seem to work.

Uploading a directory using sftp with Maven

How can I upload a directory - Eclipse update site - using sftp with public key authentication in Maven? For background information: I m using tycho to build an Eclipse plugin and want to get the ...

What are solid NMaven or build servers for .NET alternatives?

Maven had a long history and is well supported in the Java world. NMaven has received a less successful start and has never become as popular in the C#/.NET world as its larger cousin was in the Java ...

热门标签