You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by "Mansour Al Akeel (JIRA)" <je...@portals.apache.org> on 2014/07/23 03:47:39 UTC

[jira] [Commented] (JS2-1291) Improve Build to Take Advantage of Maven 3 Features

    [ https://issues.apache.org/jira/browse/JS2-1291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14071248#comment-14071248 ] 

Mansour Al Akeel commented on JS2-1291:
---------------------------------------

The build can be simplified, if we start with the custom maven plugins. We can start cleaning them, and replace them with out-of-the-box maven plugins.
For example, looking at the generated war archetype, we have: 

      <plugin>
        <groupId>org.apache.portals.jetspeed-2</groupId>
        <artifactId>jetspeed-unpack-maven-plugin</artifactId>
        <version>${org.apache.portals.jetspeed.version}</version>
        <executions>
          <execution>
            <id>unpack-jetspeed-properties</id>
            <goals>
              <goal>unpack</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <unpack>
                <artifact>org.apache.portals.jetspeed-2:jetspeed-portal-resources:jar</artifact>
                <targetDirectory>${project.build.directory}/${project.build.finalName}</targetDirectory>
                <resources>
                  <resource>
                    <path>conf/jetspeed</path>
                    <include>jetspeed.properties</include>
                    <destination>WEB-INF/conf</destination>
                  </resource>
                </resources>
              </unpack>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.apache.portals.jetspeed-2</groupId>
            <artifactId>jetspeed-portal-resources</artifactId>
            <version>${org.apache.portals.jetspeed.version}</version>
          </dependency>
        </dependencies>
      </plugin>

This snippet  AFAIK, extracts the configuration for JS2 into the WAR. I have replaced this with a call to antrun:
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.7</version>
				<executions>
					<execution>
						<id>extract-config</id>
						<phase>process-resources</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<tasks>
								<property name="js2.resources.jar" value="${org.apache.portals.jetspeed-2:jetspeed-portal-resources:jar}" />
								<unzip src="${js2.resources.jar}" dest="${project.build.outputDirectory}/WEB-INF/conf">
									<patternset>
										<include name="conf/jetspeed/jetspeed.properties" />
									</patternset>
									<mapper type="flatten" />
								</unzip>
							</tasks>
						</configuration>
					</execution>
				</executions>
			</plugin>

However, honestly, I don't see why we need these configuration in a separate jar (maven artifact) in the first place. We can just put these config in the JS war, and allow others to override/delete through the overlay mechanism.

Another example is this:

      <plugin>
        <groupId>org.apache.portals.jetspeed-2</groupId>
        <artifactId>jetspeed-deploy-maven-plugin</artifactId>
        <version>${org.apache.portals.jetspeed.version}</version>
        <executions>
          <execution>
            <id>deploy-jetspeed-layouts</id>
            <goals>
              <goal>deploy</goal>
            </goals>
            <phase>process-resources</phase>
            <configuration>
              <targetBaseDir>${project.build.directory}/${project.build.finalName}</targetBaseDir>
              <destinations>
                <local>WEB-INF/deploy/local</local>
              </destinations>
              <deployments>
                <deployment>
                  <artifact>org.apache.portals.jetspeed-2:jetspeed-layouts:war</artifact>
                  <destination>local</destination>
                </deployment>
              </deployments>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.apache.portals.jetspeed-2</groupId>
            <artifactId>jetspeed-layouts</artifactId>
            <version>${org.apache.portals.jetspeed.version}</version>
            <type>war</type>
          </dependency>
        </dependencies>
      </plugin>


This custom plugin copies jetspeed-layouts to JETSPEED_WAR/WEB-INF/deploy/local. Do we need a custom maven plugin for this ?? Here's How I am doing it:
			<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-wars</id>
						<phase>process-resources</phase>
						<goals>
							<goal>copy</goal>
						</goals>
						<configuration>
							<artifactItems>
								<artifactItem>
									<groupId>org.apache.portals.jetspeed-2</groupId>
									<artifactId>j2-admin</artifactId>
									<version>${org.apache.portals.jetspeed.version}</version>
									<type>war</type>
									<outputDirectory>${project.build.outputDirectory}/WEB-INF/deploy</outputDirectory>
								</artifactItem>
								<artifactItem>
									<groupId>org.apache.portals.jetspeed-2</groupId>
									<artifactId>jetspeed-layouts</artifactId>
									<version>${org.apache.portals.jetspeed.version}</version>
									<type>war</type>
									<outputDirectory>${project.build.outputDirectory}/WEB-INF/deploy/local</outputDirectory>
								</artifactItem>
							</artifactItems>
							<stripVersion>true</stripVersion>
						</configuration>
					</execution>
				</executions>
			</plugin>
 
In fact, the way I am doing it, is copying js-admin.war to the WEB-INF/deploy directory plus the layout jar ! Without a custom maven plugin ! 

In the generated archetype for 2.3.0-SNAPSHOT we have this:

			<plugin>
				<groupId>org.apache.portals.jetspeed-2</groupId>
				<artifactId>jetspeed-fileutils-maven-plugin</artifactId>
				<version>${org.apache.portals.jetspeed.version}</version>
				<executions>
					<execution>
						<id>configure-jetspeed-properties</id>
						<goals>
							<goal>event</goal>
						</goals>
						<phase>process-resources</phase>
						<configuration>
							<srcFilePath>${project.build.directory}/${project.build.finalName}/WEB-INF/conf/jetspeed.properties</srcFilePath>
							<editPattern>^jetui.customization.method%5Cs*=.*%24</editPattern>
							use %24 for '$' and %5C for '\'
							<replacePattern>jetui.customization.method%20=%20ajax</replacePattern>
							use %20 for space
							<event>edit</event>
						</configuration>
					</execution>
				</executions>
			</plugin>

I am not sure what it does yet. However, my guess is that it replaces some values in a config file. Do we need a custom plugin to configure values in a plain text file ?? We can edit these values directly, and utilize maven war layout technique again. 

While these plug-ins wont directly simplify the over all build, however, few less things to worry about and maintain. 

With regard to using profiles, I am currently doing this to generate a folder for shared libs. It's not as clean as I want, and still to be improved significantly. For example:

		<profile>
			<id>shared-libs</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-dependency-plugin</artifactId>
						<version>2.8</version>
						<executions>
							<execution>
								<id>copy-dependencies</id>
								<phase>package</phase>
								<goals>
									<goal>copy</goal>
								</goals>
								<configuration>
									<artifactItems>
										<artifactItem>
											<groupId>javax.portlet</groupId>
											<artifactId>portlet-api</artifactId>
											<version>2.0</version>
										</artifactItem>

										<artifactItem>
											<groupId>javax.ccpp</groupId>
											<artifactId>ccpp</artifactId>
											<version>1.0</version>
										</artifactItem>
 .....
	</artifactItems>
									<outputDirectory>${project.build.directory}/tomcat-shared-lib</outputDirectory>
									<overWriteReleases>false</overWriteReleases>
									<overWriteSnapshots>false</overWriteSnapshots>
									<overWriteIfNewer>true</overWriteIfNewer>
								</configuration>
							</execution>
						</executions>
					</plugin>

I run this, with 
$ mvn clean package -P shared-libs

And the generated folder with the jar exist under target/tomcat-shared-libs.
I think, with todays available tools and technologies, we can ignore/drop the whole installer. With JPA we can configure it to create tables automatically, and populate them. This means we can distribute JS2 as a war file only, and allow customization through overlay. 

If we honour convention over configuration, things will start getting simpler. 



> Improve Build to Take Advantage of Maven 3 Features
> ---------------------------------------------------
>
>                 Key: JS2-1291
>                 URL: https://issues.apache.org/jira/browse/JS2-1291
>             Project: Jetspeed 2
>          Issue Type: Improvement
>          Components: Project Build
>    Affects Versions: 2.3.0
>            Reporter: David Sean Taylor
>             Fix For: 2.3.0
>
>
> This is a general effort to simplify the Jetspeed build. For example, leverage new Maven-3 features like Profiles 



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org