0

resources/components在 Maven WAR 项目的目录中有许多复合组件。我希望使我的复合组件可重用,而是将它们单独打包在一个 JAR 中(它们可能具有关联ManagedBeans的 .

许多现有问题,例如这个问题,解决了相同或相似的任务。但是,没有人指定如何使用 Maven 来自动化该过程。

我宁愿使用 Ant。

4

2 回答 2

2

我建议使用 maven-antrun-pluin。以下是经过验证的示例:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>prepare-deploy-package</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <copy todir="${project.build.directory}/${project.build.finalName}/META-INF/resources" overwrite="true">
                                    <fileset dir="src/main/resources">
                                    </fileset>
                                </copy>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
于 2013-01-24T09:17:14.897 回答
1

这对我有用:

<resources>          
    <resource>
        <directory>src/main/webapp/resources</directory>
        <targetPath>META-INF/resources</targetPath>
  </resource>
  <resource>
        <directory>src/main/webapp/WEB-INF/</directory>
        <targetPath>META-INF</targetPath>
    </resource>          
</resources>

确保拥有:

<packaging>war</packaging>

A 还启用了 maven 插件以允许 Netbeans 将项目识别为 Web 项目:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1.1</version>
        <configuration>
            <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
    </plugin>
于 2013-01-27T03:28:32.843 回答