coderplus / m2e-connector-for-maven-remote-resources-plugin

m2e connector for the maven-remote-resources-plugin
3 stars 2 forks source link

Workspace resolution of resource bundles #1

Closed sewe closed 9 years ago

sewe commented 9 years ago

Even though both the resource bundle and the project doing the maven-remote-resources-plugin:processing are part of the same workspace, workspace resolution doesn't work.

In other words, a workspace project org.example:processor:1.0.0-SNAPSHOT containing the following configuration

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-remote-resources-plugin</artifactId>
    <executions>
        <execution>
            <id>process-repository-resources</id>
            <goals>
                <goal>process</goal>
            </goals>
            <configuration>
                <resourceBundles>
                    <resourceBundle>org.example:bundle:1.0.0-SNAPSHOT</resourceBundle>
                </resourceBundles>
            </configuration>
        </execution>
    </executions>
</plugin>

does not have the current contents of org.example:bundle:1.0.0-SNAPSHOT ending up in its target/maven-shared-archive-resources folder upon a full IDE build; it’s still the old org.example:bundle:1.0.0-SNAPSHOT that a manual mvn clean install has previously deployed to the local repository.

aneesh-joseph commented 9 years ago

I had tried this with the below projects in workspace

<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.coderplus.remote</groupId>
<artifactId>bundle</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-remote-resources-plugin</artifactId>
            <version>1.5</version>
            <executions>
                <execution>
                    <goals>
                        <goal>bundle</goal>
                    </goals>
                    <configuration>
                        <includes>
                            <include>**/**</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
</project>`

and

<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.coderplus.remote</groupId>
<artifactId>process</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-remote-resources-plugin</artifactId>
            <version>1.5</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <resourceBundles>
                            <resourceBundle>${project.groupId}:bundle:${project.version}</resourceBundle>
                        </resourceBundles>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
</project>

and it seems to be working as expected on IDE full builds. Can you please send me the one with which you are trying?

sewe commented 9 years ago

Thank you for the quick reply.

I am afraid Eclipse Code Recommenders is not a minimal example, but it’s the one that’s failing for me:

git clone https://git.eclipse.org/r/recommenders/org.eclipse.recommenders
cd org.eclipse.recommenders
git fetch https://git.eclipse.org/r/recommenders/org.eclipse.recommenders refs/changes/67/34467/1 && git checkout FETCH_HEAD

You will probably see many compile errors upon an Import/Exisiting Maven Project, as we use Eclipse Tycho for much of our build, but after you have installed the m2e Tycho connectors at least the following two projects should be free of errors: repository-resources and head. The former is the resource bundle (with a single resource file in resources/index.php.vm), whereas the latter (along with its siblings milestones, stable, and simrel) is the one processing it.

Now, change the index.php.vm resource in some way and do a clean workspace build. This change does not carry over to head’s target/maven-shared-archive-resources or target/repository (FYI, the latter for now has to be the ${project.build.outputDirectory}, due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=442471).

Can you reproduce my problem?

aneesh-joseph commented 9 years ago

Yes,I was able to reproduce it but the error is due to the fact that the parent pom has got lifecycle mapping meta data which ignores the bundle goal. http://git.eclipse.org/c/recommenders/org.eclipse.recommenders.git/tree/pom.xml#n418

and hence the connector is not getting invoked during the bundle goal.

If you remove this lifecycle mapping, it should work.

Right click on the project > Properties > Maven > Lifecycle Mapping. This will give you an idea about how goals are being handled.

sewe commented 9 years ago

Are you sure you did the git fetch from Gerrit? As far as I can tell, https://git.eclipse.org/r/#/c/34467/1/pom.xml removes the lifecycle mapping in question.

Anyway, your reply pointed me in the right direction: After doing a Preferences > Maven > Lifecycle Mappings > Reload workspace lifecycle mappings metadata things seem to work as expected. Closing this for now, but will do some further experiments.

It’s just odd that I had to do a reload as m2e seemed to have picked up the metadata change; at least the error marker in the POM warning about a missing mapping vanished after installing the connector.

aneesh-joseph commented 9 years ago

yea, you are right, I didn't do a git fetch . Thank you for testing this :+1: