Fórum

Hints in portlet-model-hints.xml are overriten when I run mvn service-build

Olga S, modificado 6 Anos atrás.

Hints in portlet-model-hints.xml are overriten when I run mvn service-build

Junior Member Postagens: 26 Data de Entrada: 17/04/17 Postagens Recentes
Hello everyone!
I am posting it here just to share the issue I was facing and solution to it.
Everyone knows that there is portlet-model-hints.xml file in src/main/resources/META-INF folder which provides a single place in an application where one can specify entity data restrictions.
Hints can look like this:

<field name="title" type="String">
	<hint name="max-length">255</hint>
</field>
 <field name="description" type="String">
            <hint-collection name="TEXTAREA" />
</field>


However, if you use Maven to build your app, you might encounter the issue that every time "mvn service-build" command is run, this file is overrwiten and all hints are lost (and not implemented in tables.sql file). So, solution would be to add:
<modelhintsconfigs>classpath*:META-INF/portal-model-hints.xml,META-INF/portal-model-hints.xml,classpath*:META-INF/ext-model-hints.xml,classpath*:META-INF/portlet-model-hints.xml
,src/main/resources/META-INF/portlet-model-hints.xml</modelhintsconfigs>

into com.liferay.portal.tools.service.builder plugin configurations:
<plugins>
			<plugin>
				<groupid>com.liferay</groupid>
				<artifactid>com.liferay.portal.tools.service.builder</artifactid>
				<version>1.0.160</version>
				<configuration>
					<apidirname>../*****/src/main/java</apidirname>
					<autonamespacetables>true</autonamespacetables>
					<buildnumberincrement>true</buildnumberincrement>
					<hbmfilename>src/main/resources/META-INF/module-hbm.xml</hbmfilename>
					<impldirname>src/main/java</impldirname>
					[b]<modelhintsconfigs>classpath*:META-INF/portal-model-hints.xml,META-INF/portal-model-hints.xml,classpath*:META-INF/ext-model-hints.xml,classpath*:META-INF/portlet-model-hints.xml,src/main/resources/META-INF/portlet-model-hints.xml</modelhintsconfigs>[/b]
					<modelhintsfilename>src/main/resources/META-INF/portlet-model-hints.xml</modelhintsfilename>
					<osgimodule>true</osgimodule>
					<propsutil>****</propsutil>
					<resourcesdirname>src/main/resources</resourcesdirname>
					<springfilename>src/main/resources/META-INF/spring/module-spring.xml</springfilename>
					<sqldirname>src/main/resources/META-INF/sql</sqldirname>
					<sqlfilename>tables.sql</sqlfilename>
				</configuration>
			</plugin>
*******</plugins>


However, remember, it's just temporary workaround and Liferay engineering team is currently working to change the default value for this argument.
I hope it helps someone.

Thanks!
thumbnail
Orin Fink, modificado 4 Anos atrás.

RE: Hints in portlet-model-hints.xml are overriten when I run mvn service-b

Junior Member Postagens: 65 Data de Entrada: 25/03/10 Postagens Recentes
Thanks for the post in this issue Olga. 
It looks like there was also further clarification on the merge configuration made by the team in the default project model hints https://github.com/liferay/liferay-blade-samples/pull/127/commits/479b9c20ac5c7c97744b32a95f5a900d7c2bd9a3  and also more clarity in the Case https://issues.liferay.com/browse/LPS-70749HOWEVER, I found that I would need to be more explicit about the path to the model hint file that I wanted to merge when trying to run the service builder from the root of a maven workspace instead of from within the service builder module itself.
So, in order to resolve this fully I used the following setting that included an explicit path the the project base directory from Maven's point of view.  This lets us also then run the service builder for multiple service builder projects from the root of the workspace. 

<impldirname>src/main/java</impldirname>
<modelhintsfilename>src/main/resources/META-INF/portlet-model-hints.xml</modelhintsfilename>
<mergemodelhintsconfigs>${project.basedir}/src/main/resources/META-INF/portlet-model-hints.xml</mergemodelhintsconfigs>
<osgimodule>true</osgimodule>