Right now, when you use the service builder archetype, you'll have this project structure :
- myproject
... - myproject-service
... - myproject-portlet
Portlet has a reference to the service, so that the service is built before portlet.
The "liferay-maven-plugin" to build the service is defined into portlet, so that, the src generation is made from portlet. The src generation generates code into portlet, which need to be install before being used into portlet.
The idea is to bind the "liferay-maven-plugin" goal to the "generate-source" phase. If you do so and do a "mvn deploy" on the root module, you'll end with that order :
- myproject-service (which deploy old version of service)
- myproject-portlet (which install new version of service into service module and deploy new version of portlet)
That is not correct if you want to deploy into a hosted repository. you need to deploy the new service at fiirst, then deploy the new portlet. So, you need to generate src while building the service.
The idea is to move src generation from portlet to service by removing the plugin definition into portlet and create a plugin entry into service's pom.xml :
<properties>
<project.portlet>${basedir}/../myfoobar-portlet</project.portlet>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>${liferay.version}</version>
<configuration>
<apiDir>${basedir}/src/main/java</apiDir>
<hbmFileName>${project.portlet}/src/main/resources/META-INF/portlet-hbm.xml</hbmFileName>
<implDir>${project.portlet}/src/main/java</implDir>
<jsonFileName>${project.portlet}/src/main/webapp/html/js/liferay/service.js</jsonFileName>
<modelHintsFileName>${project.portlet}/src/main/resources/META-INF/portlet-model-hints.xml</modelHintsFileName>
<ormFileName>${project.portlet}/src/main/resources/META-INF/portlet-orm.xml</ormFileName>
<resourcesDir>${project.portlet}/src/main/resources</resourcesDir>
<serviceFileName>${project.portlet}/src/main/webapp/WEB-INF/service.xml</serviceFileName>
<springBaseFileName>${project.portlet}/src/main/resources/META-INF/base-spring.xml</springBaseFileName>
<springDynamicDataSourceFileName>${project.portlet}/src/main/resources/META-INF/dynamic-data-source-spring.xml</springDynamicDataSourceFileName>
<springFileName>${project.portlet}/src/main/resources/META-INF/portlet-spring.xml</springFileName>
<springHibernateFileName>${project.portlet}/src/main/resources/META-INF/hibernate-spring.xml</springHibernateFileName>
<springInfrastructureFileName>${project.portlet}/src/main/resources/META-INF/infrastructure-spring.xml</springInfrastructureFileName>
<springShardDataSourceFileName>${project.portlet}/src/main/resources/META-INF/shard-data-source-spring.xml</springShardDataSourceFileName>
<sqlDir>${project.portlet}/src/main/webapp/WEB-INF/sql</sqlDir>
</configuration>
<executions>
<execution>
<goals>
<goal>build-service</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
That way, on the root module, if you do "mvn deploy", you'll end up with :
- service building (with service and portlet src generation from the plugin) and service deploy
- portlet building and portlet deploy
In that order, you can remove the invoker in the plugin (which call mvn install for the service part).
By removing the invoker, you'll remove plugin dependency on maven-invoker, and then you can have a working plugin with maven 3 =)