Search code examples
eclipsemavenjsf-2glassfish-3

Avoid publish of EJBs and ManagedBeans when saving xhtml file in Maven project


I have setup a two eclipse projects (jsf2 web projects) and deployed them via eclipse to glassfish

eclipse juno ee 4.2.1 sr1 (fresh install and new workspace)
maven wtp
m2e
glassfish plugin for eclipse
glassfish 3.1.2.2

One project is a simple dynamic web project created from scratch that only has an ejb and a .xhtml file.

When saving the .xhtml file in the dynamic web project, it will be silently copied to the right place in glassfish/domains/domain1/eclipseApps allowing to quickly test changes.

However in my other project which I created by using the import-maven-project-wizard (select a .pom file), saving a .xhtml file will trigger a rebuild and republish, something which takes considerably more time. In both cases the application runs perfectly fine.

(The maven project is also more complex using primefaces, some glassfish-web.xml persistence.xml etc... But i believe this is not causing the different behaviour)

Q: What setting do I need to change to have my maven project behave as the dynamic web-project?

Edit: problem summary: Saving a .xhtml file in the maven project also trigers re-deploy of all EJBs and ManagedBeans

Edit (after balus C's tip):

Investigation indicates that m2e wtp plugin generates new timestamp in the following files, every time a file in the workspace is saved.

target\m2e-wtp\web-resources\META-INF\maven\<groupId>\<artifactId>\pom.properties
target\m2e-wtp\web-resources\META-INF\maven\<groupId>\<artifactId>\pom.xml

If I understand the discussion here correctly, someone has done a fix that will prevent these files from being updated if not required due to other maven stuff. Sadly if I understand the git-hub correctly, this fix for this issue is not yet released.

Maven archiver has support for a configuration option <addMavenDescriptor/> to disable the generation of pom.properties, but it seems m2e-wtp plugin has decided to not honor this option link

Edit (20130114) I Tried uninstalling m2e wtp just to see if geting rid of the generation of pom.properties would fix the problem. Also I checked that the .xhtml file I edit is the only file under domains/domain1/eclipseApps/ with new timestamp.

So now im out of ideas again.


Solution

  • Finally managed to solve this. This was the minimum amount of required steps i needed to do for a freshly created Maven project (which also had a dependency to another project in the workspace)

    In eclipse Project properties > Maven uncheck "Resolve dependencies from workspace projects"

    In The pom file set runOnIncremental for the goal: war for maven-war-plugin to false

    <build>
        ...
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-war-plugin</artifactId>
                                        <versionRange>[1.0.0,)</versionRange>
                                        <goals>
                                            <goal>war</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute>
                                            <runOnIncremental>false</runOnIncremental>
                                        </execute>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>