maven - Liferay 的父 Pom 构建问题

标签 maven liferay

我正在尝试设置一个基于 maven 的小型项目结构,如下所示

Maven结构

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

如您所见,Project 下有几个 portlet(在 future 的主题中,hook 等在相同的结构下)。

现在,在单个 portlet 中,我可以运行 liferay 相关的 maven 任务,通过点击 来单独部署它们。 mvn clean 编译包 liferay:deploy
现在我正在寻找使用相同的命令构建和部署所有与 Liferay portlet 相关的 Artifact 。在这种情况下,我收到父项目本身的错误(子 Liferay 模块正在构建良好)。我不确定为什么它也尝试构建父项目,尽管我的意图只是运行 liferay:deploy 相关任务。

子 POM

这是child的pom.xml(这是创建portlet时默认生成的)

<?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。 (我为此手动创建了谷歌搜索并将模块添加到其中)

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

如您所见,对于我想要的子模块,构建是成功的。但它也试图为 parent 执行它。我怎样才能避免发生第三次构建,这是父项目。

最佳答案

您必须添加自定义 pluginGroupsettings.xml像这样:

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

然后,您可以使用 3rd 方插件进行短调用,例如 liferay:deploy .看this更多细节。

关于maven - Liferay 的父 Pom 构建问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10753509/

相关文章:

java - 在本地为 Java 中的新项目安装包

java - 使用JDK 10时找不到javax.annotation.Resource的lookup()方法

java - 如何在主题(Liferay)中默认使 portlet 无边界?

java - 远程访问 Liferay 内容 给出异常 权限检查器未初始化

maven - 有没有办法使用 mvn eclipse :eclipse? 在 .classpath 中添加自定义行

java - 通过命令行使用mvn运行Java程序

java - 在eclipse中添加maven依赖

database - Liferay如何连接Mysql数据库

java - 如何修复 Liferay 中丢失数据的搜索返回结果?

static - Liferay - 提供静态内容