Can't bind maven-remote-resources-plugin to both bundle and process goals

421 Views Asked by At

I use the maven-remote-resources-plugin to get some resources from an artifact and also need to bundle some resources for use in another project.

I bind the maven-remote-resources-plugin to the bundle goal in the default section (not in a profile). And I bind the maven-remote-resources-plugin to the process goal in a profile.

My problem is that I don't get the shared resources when using the profile (I don't get the target\maven-shared-archive-resources folder). If I remove the maven-remote-resources-plugin in the default section (the bundle binding) it works fine.

Any suggestions?

Below is my pom:

<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.mycompany.app</groupId>
    <artifactId>my-app</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>my-app</name>

    <dependencies>
        <dependency>
            <groupId>com.mycompany.app</groupId>
            <artifactId>my-app-common</artifactId>
            <version>1.0-SNAPSHOT</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-remote-resources-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>bundle</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
                    <resourcesDirectory>${basedir}/src/test/resources</resourcesDirectory>
                    <includes>
                        <include>**/*.sql</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>create-test-data</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <testResources>
                    <testResource>
                        <directory>${basedir}/src/test/resources</directory>
                    </testResource>
                    <testResource>
                        <directory>${project.build.directory}/maven-shared-archive-resources</directory>
                    </testResource>
                </testResources>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-remote-resources-plugin</artifactId>
                        <version>1.5</version>
                        <configuration>
                            <resourceBundles>
                                <resourceBundle>com.mycompany.app:my-app-common:1.0-SNAPSHOT:test-jar</resourceBundle>
                            </resourceBundles>
                            <attachToMain>false</attachToMain>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>process</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
1

There are 1 best solutions below

0
On

The problem was that the property outputDirectory is defined for both the process and bundle goals and I redefined it in the bundle goal.