【问题标题】:How to include a maven launch config in a maven archetype?如何在 Maven 原型中包含 Maven 启动配置?
【发布时间】:2012-11-01 11:48:04
【问题描述】:

我有一个 liferay-portlet-project,其中包含一个我想成为原型的示例应用程序/portlet。项目内部有一个文件夹,其中包含两个 *.launch 文件,用于重新部署 webapp。两者都有以下我遇到问题的行:

<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:/rawportlet}"/>

其中“rawportlet”是项目的名称。如果我手动将其更改为${artifactId},则在使用原型创建项目时不会解析此变量。在项目生成期间解决这个变量会很好。

有没有办法做到这一点?还是解决方法?提前感谢您的帮助。

【问题讨论】:

    标签: variables maven launch archetypes


    【解决方案1】:

    解决方法:编写一个用户可以在使用原型后运行的 maven 目标。所以步骤将是(例如):

    1. 从原型生成项目

      mvn archetype:generate -DarchetypeCatalog=local

    2. 进行一些生成后清理(在项目的基本目录中执行)

      mvn antrun:run

    所以我的代码在原型的“pom.xml”中:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
            <execution>
                <id>default-cli</id>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <tasks>
                    <replace token= "rawportlet" value="${artifactId}" dir="runConfigs">                                 
                      <include name="**/*.launch"/>
                    </replace>
                  </tasks>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

    “runConfigs”目录是存储*.launch 文件的位置。

    归功于:

    Full search and replace of strings in source files when copying resources

    Maven, configure specific goal

    【讨论】:

      【解决方案2】:

      我也有同样的问题,我使用了另一种可行的解决方案(但也不完美)。

      在您的启动配置中使用value="${workspace_loc}/${artifactId}"

      只要人们在工作区根目录执行 archetype:gen,这将起作用。这对我来说比选择的答案更好,因为运行该后期处理需要另一个启动配置(这在某种程度上违背了整个目的)。

      【讨论】:

        猜你喜欢
        • 2011-01-06
        • 1970-01-01
        • 1970-01-01
        • 2016-01-30
        • 1970-01-01
        • 2020-01-19
        • 1970-01-01
        • 2012-01-31
        • 2012-09-12
        相关资源
        最近更新 更多