Forums de discussion

Theme merge using maven not ant + confused

David Roberts, modifié il y a 9 années.

Theme merge using maven not ant + confused

New Member Publications: 7 Date d'inscription: 21/10/14 Publications récentes
Hi,

Just trying out liferay and have the project all set up with maven and using intellij.

All was going well and I had a few portlets all deploying to my tomcat bundle.

When I came to playing with a theme I started getting confused. I create a new theme using the maven:archetype which generated:



The tweaked the pom file that was generated remove some duplicate dependencies which were in the parent pom:


<!--?xml version="1.0"?-->
<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>

	<parent>
        <artifactid>sample</artifactid>
        <groupid>com.sample</groupid>
        <version>develop-SNAPSHOT</version>
    </parent>

	<artifactid>sample-theme</artifactid>
	<packaging>war</packaging>
	<name>sample-theme</name>
	<version>develop-SNAPSHOT</version>

    <build>
		<plugins>
			<plugin>
				<groupid>com.liferay.maven.plugins</groupid>
				<artifactid>liferay-maven-plugin</artifactid>
				<version>${liferay.maven.plugin.version}</version>

                <executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>theme-merge</goal>
							<goal>build-css</goal>
							<goal>build-thumbnail</goal>
						</goals>
					</execution>
				</executions>

				<configuration>
					<parenttheme>${liferay.theme.parent}</parenttheme>
					<plugintype>theme</plugintype>
					<themetype>${liferay.theme.type}</themetype>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<dependencies>
		<dependency>
			<groupid>javax.portlet</groupid>
			<artifactid>portlet-api</artifactid>
			<version>2.0</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupid>javax.servlet</groupid>
			<artifactid>servlet-api</artifactid>
			<version>2.4</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupid>javax.servlet.jsp</groupid>
			<artifactid>jsp-api</artifactid>
			<version>2.0</version>
			<scope>provided</scope>
		</dependency>
	</dependencies>

	<properties>
		<liferay.theme.parent>_styled</liferay.theme.parent>
		<liferay.theme.type>vm</liferay.theme.type>
	</properties>
</project>



So I then wanted to test it could be deployed and would then be selectable in liferay so I ran the following:

- mvn clean install
- mvn liferay:deploy -Plocalhost

This then successfully built the war file and moved it to tomcat which liferay then deployed. I could then select the theme to use on my pages so all good.

Just to confirm when I look in the war file it has pulled in the css, images, js and templates from the parent style that I was inheriting from.

I then wanted to test changing something in the theme so I created a webapp/_diffs/templates folder

I then created portal_normal.vm and simply add the word test to the title.

I then re run:

- mvn clean install or mvn package
- mvn liferay:deploy -Plocalhost

Watched the liferay log to confirm it deployed my theme, then went to the site but could not see my changes.

I then played for a while and thought I may have the folder name wrong so I tried _diff instead, didnt work.
I tried running mvn package as the command to build the way, didnt work.

I eventually just created the folder webapp/templates/ and put the portal_normal.vm with my change in there:



I then re run:

- mvn clean install or mvn package
- mvn liferay:deploy -Plocalhost

And voila it deployed to liferay with my change visible in the template. It had pulled in all the parent theme files and maintained my changed portal_normal.vm

So my question is, do I need the _diffs folder as it seems to do nothing in my maven step? Am I missing something?

Thanks in advance.
David Roberts, modifié il y a 9 années.

RE: Theme merge using maven not ant + confused

New Member Publications: 7 Date d'inscription: 21/10/14 Publications récentes
I have actually just noticed the same question being asked at the bottom of this page as well - https://www.liferay.com/en_GB/documentation/liferay-portal/6.1/development/-/ai/anatomy-of-a-the-4

So glad to see it was not just me.
thumbnail
Ahmed bouchriha, modifié il y a 9 années.

RE: Theme merge using maven not ant + confused

Junior Member Publications: 55 Date d'inscription: 04/05/12 Publications récentes
Hi David

When creating themes with maven you don't need the diffs folder since the webapp folder is merged
with the parent theme.

Best Regards