Commit affd0c74 authored by mindthegab's avatar mindthegab
Browse files

Share project "maven-amp-plugin" into...

parent 8e41b635
Loading
Loading
Loading
Loading

pom.xml

0 → 100644
+180 −0
Original line number Diff line number Diff line
<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">
	<parent>
		<artifactId>maven-plugins</artifactId>
		<groupId>org.apache.maven.plugins</groupId>
		<version>8</version>
	</parent>
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.alfresco.maven.plugin</groupId>
	<artifactId>maven-amp-plugin</artifactId>
	<packaging>maven-plugin</packaging>
	<name>Alfresco AMP Plugin</name>
	<version>2.0.2-SNAPSHOT</version>
	<description>
		This plugin defines a lifecycle for Alfresco ECM Modules packaging (.amp), handles AMP transitive dependencies from AMP and WAR projects,
		providing a more enterprise oriented support alternative to the Alfresco MMT (module management tool) usage. It is used by
		maven-alfresco-amp-archetype in order to package and test run an AMP and by the maven-alfresco-extension-archetype to depend transitively upon
		AMPs and WARs. It is a modification of the org.apache.maven.plugins:maven-war-plugin of which it uses the whole core infrastructure. See
		${site.url} for more info
	</description>
	<url>${site.url}</url>
	<prerequisites>
		<maven>2.0.1</maven>
	</prerequisites>
	<issueManagement>
		<system>GForge</system>
		<url>https://forge.alfresco.com/tracker/?group_id=121</url>
	</issueManagement>
	<properties>
		<svn.url>https://forge.alfresco.com/svn/maven4alfresco/amp-plugin/branches/2.0.0</svn.url>
		<svn.tags.url>https://forge.alfresco.com/svn/maven4alfresco/amp-plugin/tags</svn.tags.url>
		<site.url>https://repository.sourcesense.com/maven2-sites/${pom.artifactId}</site.url>
		<site_pom_description>${pom.description}</site_pom_description>
		<site_pom_url>${pom.url}</site_pom_url>
		<site_pom_groupId>${pom.groupId}</site_pom_groupId>
		<site_pom_artifactId>${pom.artifactId}</site_pom_artifactId>
		<site_pom_version>${pom.version}</site_pom_version>
		<site_tags_url>${svn.tags.url}</site_tags_url>
	</properties>
	<developers>
		<developer>
			<id>mindthegab</id>
			<name>Gabriele Columbro</name>
			<email>g.columbro@sourcesense.com</email>
			<roles />
			<organization>Sourcesense</organization>
			<organizationUrl>http://www.sourcesense.com</organizationUrl>
		</developer>
		<developer>
			<id>rdanner</id>
			<name>Russ Danner</name>
			<roles />
			<organization>Rivet Logic</organization>
		</developer>
	</developers>

	<scm>
		<developerConnection>scm:svn:https://forge.alfresco.com/svn/maven4alfresco/amp-plugin/tags/maven-amp-plugin-2.0.0</developerConnection>
		<url>https://forge.alfresco.com/svn/maven4alfresco/amp-plugin/tags/maven-amp-plugin-2.0.0</url>
		<connection>scm:svn:https://forge.alfresco.com/svn/maven4alfresco/amp-plugin/tags/maven-amp-plugin-2.0.0</connection>

	</scm>
	<build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.5</source>
					<target>1.5</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-changes-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>announcement-generate</goal>
						</goals>
						<id>announcement-generate</id>
					</execution>
					<execution>
						<goals>
							<goal>announcement-mail</goal>
						</goals>
						<id>announcement-mail</id>
					</execution>
				</executions>
				<!--  Automatically notifies the list when release is done. Please supply username and password in the command line -->
				<configuration>
					<smtpHost>mail.sourcesense.com</smtpHost>
					<smtpPort implementation="java.lang.Integer">25</smtpPort>
					<toAddresses>
						<toAddress implementation="java.lang.String">sysadmin@sourcesense.com</toAddress>
						<toAddress implementation="java.lang.String">alfresco@sourcesense.com</toAddress>
						<toAddress implementation="java.lang.String">alfresco-dev@lists.sourcesense.com</toAddress>
						<toAddress implementation="java.lang.String">users@maven.apache.org</toAddress>
						<toAddress implementation="java.lang.String">announce@maven.apache.org</toAddress>
					</toAddresses>
					<username>${smtp.username}</username>
					<password>${smtp.password}</password>
					<fromDeveloperId>mindthegab</fromDeveloperId>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-release-plugin</artifactId>
				<version>2.0-beta-5</version>
				<configuration>
					<!-- useEditMode>true</useEditMode>-->
					<!--  dryRun>true</dryRun-->
					<preparationGoals>clean package</preparationGoals>
					<goals>deploy site:site site:deploy changes:announcement-mail</goals>
					<tagBase>${svn.tags.url}</tagBase>
					<arguments>-Dgpg.skip=true</arguments>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-gpg-plugin</artifactId>
				<groupId>org.apache.maven.plugins</groupId>
				<configuration>
					<skip>true</skip>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<dependencies>
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-plugin-api</artifactId>
			<version>2.0.6</version>
		</dependency>
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-artifact</artifactId>
			<version>2.0.6</version>
		</dependency>
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-archiver</artifactId>
			<version>2.2</version>
		</dependency>
		<dependency>
			<groupId>org.codehaus.plexus</groupId>
			<artifactId>plexus-utils</artifactId>
			<version>1.4.7</version>
		</dependency>
		<dependency>
			<groupId>com.thoughtworks.xstream</groupId>
			<artifactId>xstream</artifactId>
			<version>1.2.2</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.maven.shared</groupId>
			<artifactId>maven-plugin-testing-harness</artifactId>
			<version>1.1</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<distributionManagement>
		<repository>
			<id>ss-public</id>
			<url>scp://repository.sourcesense.com/var/www/demo.sourcesense.com/maven2</url>
		</repository>
  		<snapshotRepository>
			<id>ss-public</id>
			<name>SS public repo</name>
			<url>scp://repository.sourcesense.com/var/www/demo.sourcesense.com/maven2-snapshots</url>
		</snapshotRepository>
		<site>
			<id>ss-site-public</id>
			<url>scp://repository.sourcesense.com/var/www/demo.sourcesense.com/maven2-sites/${pom.artifactId}</url>
		</site>
	</distributionManagement>
</project>
+21 −0
Original line number Diff line number Diff line
<document>
  <properties>
    <title>Maven AMP plugin</title>
  </properties>
  <body>
    <release version="2.0.0" date="2008-07-06" description="Refactored Public release">
      <action dev="mindthegab" type="add">
			Now consistent maven plugin properties usage and support for AMP overlays and full AMP lifecycle
      </action>
       <action dev="mindthegab" type="add">
			Added UnArchiver to mimic MMT behavior. Not needed anymore as AMPs gets properly unpacked into a WAR artifact. 
      </action>
      <action dev="mindthegab" type="add">
            Added plugin site documentation
      </action>
      <action dev="mindthegab" type="add">
       	 	Deployed on maven repository: http://repository.sourcesense.com/maven2/org/alfresco/maven/plugins
      </action>
    </release>
  </body>
</document>
+765 −0

File added.

Preview size limit exceeded, changes collapsed.

+42 −0
Original line number Diff line number Diff line
package org.alfresco.maven.plugin.amp;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

/**
 * Generate the exploded webapp
 *
 * @goal explodedAmp
 * @phase package
 * @requiresDependencyResolution runtime
 */
public class AmpExplodedMojo extends AbstractAmpMojo
{
    public void execute()
        throws MojoExecutionException, MojoFailureException
    {
        getLog().info( "Exploding AMP" );

        this.buildExplodedAmp( this.getAmpDirectory() );
    }

}
 No newline at end of file
+348 −0
Original line number Diff line number Diff line
package org.alfresco.maven.plugin.amp;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import org.alfresco.plexus.archiver.AmpArchiver;
import org.apache.maven.archiver.MavenArchiver;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProjectHelper;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.jar.ManifestException;
import org.codehaus.plexus.archiver.zip.ZipArchiver;

import java.io.File;
import java.io.IOException;

/**
 * Build a amp/webapp.
 * <p>
 * Note this is a modification of Emmanuel Venisse's (evenisse@apache.org) WAR
 * Mojo and has been adapted to build an Alfresco AMP.
 * @version $Id:$
 * @goal amp
 * @phase package
 * @requiresDependencyResolution runtime
 */
public class AmpMojo extends AbstractAmpMojo
{
    /* ====================================================================== */
    // constructors
    /* ====================================================================== */

    /**
     * default constructor
     */
    public AmpMojo()
    {
        this.setAmpArchiver(null);
        this.setAmpName(null);
        this.setOutputDirectory(null);
    }
    
    /* ====================================================================== */
    // properties
    /* ====================================================================== */

    /**
     * Whether this is the main artifact being built. Set to <code>false</code> if you don't want to install or
     * deploy it to the local repository instead of the default one in an execution.
     *
     * @parameter expression="${primaryArtifact}" default-value="true"
     */
    private boolean mPrimaryArtifact;

    /**
     * get the the internal value for the <code>ampArchiver</code> property.
     * <p>
     * The <code>ampArchiver</code> property 
     * @return Returns the internal value for the ampArchiver property.
     */
    protected AmpArchiver getAmpArchiver()
    {
        return this.mAmpArchiver;
    }

    /**
     * set the internal value for the <code>ampArchiver</code> property
     * @param pAmpArchiver The <code>ampArchiver</code> to set.
     */
    protected void setAmpArchiver(AmpArchiver pAmpArchiver)
    {
        this.mAmpArchiver = pAmpArchiver;
    }

    /**
     * get the the internal value for the <code>ampName</code> property.
     * <p>
     * The <code>ampName</code> property 
     * @return Returns the internal value for the ampName property.
     */
    protected String getAmpName()
    {
        return this.mAmpName;
    }

    /**
     * set the internal value for the <code>ampName</code> property
     * @param pAmpName The <code>ampName</code> to set.
     */
    protected void setAmpName(String pAmpName)
    {
        this.mAmpName = pAmpName;
    }

    /**
     * get the the internal value for the <code>outputDirectory</code> property.
     * <p>
     * The <code>outputDirectory</code> property 
     * @return Returns the internal value for the outputDirectory property.
     */
    protected String getOutputDirectory()
    {
        return this.mOutputDirectory;
    }

    /**
     * set the internal value for the <code>outputDirectory</code> property
     * @param pOutputDirectory The <code>outputDirectory</code> to set.
     */
    protected void setOutputDirectory(String pOutputDirectory)
    {
        this.mOutputDirectory = pOutputDirectory;
    }

    /**
     * get the the internal value for the <code>primaryArtifact</code> property.
     * <p>
     * The <code>primaryArtifact</code> property 
     * @return Returns the internal value for the primaryArtifact property.
     */
    protected boolean isPrimaryArtifact()
    {
        return this.mPrimaryArtifact;
    }

    /**
     * set the internal value for the <code>primaryArtifact</code> property
     * @param pPrimaryArtifact The <code>primaryArtifact</code> to set.
     */
    protected void setPrimaryArtifact(boolean pPrimaryArtifact)
    {
        this.mPrimaryArtifact = pPrimaryArtifact;
    }

    /**
     * get the the internal value for the <code>projectHelper</code> property.
     * <p>
     * The <code>projectHelper</code> property 
     * @return Returns the internal value for the projectHelper property.
     */
    protected MavenProjectHelper getProjectHelper()
    {
        return this.mProjectHelper;
    }

    /**
     * set the internal value for the <code>projectHelper</code> property
     * @param pProjectHelper The <code>projectHelper</code> to set.
     */
    protected void setProjectHelper(MavenProjectHelper pProjectHelper)
    {
        this.mProjectHelper = pProjectHelper;
    }

    /**
     * Overload this to produce a test-war, for example.
     */
    protected String getClassifier()
    {
        return mClassifier;
    }
    
    /**
     * set the internal value for the <code>classifier</code> property
     * @param pClassifier The <code>classifier</code> to set.
     */
    protected void setClassifier(String pClassifier)
    {
        this.mClassifier = pClassifier;
    }

    /* ====================================================================== */
    // public methods
    /* ====================================================================== */

    /**
     * Executes the WarMojo on the current project.
     *
     * @throws MojoExecutionException if an error occured while building the webapp
     */
    public void execute()
    throws MojoExecutionException, 
           MojoFailureException
    {

        File vAmpFile = AmpMojo.getAmpFile(new File( getOutputDirectory() ), getAmpName(), getClassifier());

        try
        {
            this.performPackaging(vAmpFile);
        }
        catch (Exception eAssemblyFailure)
        {
            /* behavior is the same for the following exceptions:
             *    DependencyResolutionRequiredException
             *    ManifestException
             *    IOException
             *    ArchiverException
             */
            throw new MojoExecutionException( "Error assembling AMP: " + eAssemblyFailure.getMessage(), eAssemblyFailure );
        }
    }

    /* ====================================================================== */
    // protected methods
    /* ====================================================================== */


    /**
     * composes the full file name for the AMP and gets a file handle for that file
     * TODO: what happens when nulls are passed in
     * TODO: what does a null response mean?
     * @param pBaseDir  Base directory for AMP
     * @param pFileName Final Name of AMP   
     * @param pClassifier TODO: fill this in
     */
    protected static File getAmpFile( File pBasedir, String pFinalName, String pClassifier )
    {
        String vClassifier = pClassifier;

        if (vClassifier == null)
        {
            vClassifier = "";
        }
        else if (vClassifier.trim().length() > 0 && !vClassifier.startsWith( "-" ) )
        {
            vClassifier = "-" + vClassifier;
        }

        return new File(pBasedir, pFinalName + vClassifier + ".amp" );
    }


    /**
     * Generates the webapp according to the <tt>mode</tt> attribute.
     *
     * @param pAmpFile the target AMP file
     * @throws IOException
     * @throws ArchiverException
     * @throws ManifestException
     * @throws DependencyResolutionRequiredException
     *
     */
    protected void performPackaging(File pAmpFile)
    throws IOException, 
           ArchiverException, 
           ManifestException, 
           DependencyResolutionRequiredException,
           MojoExecutionException, MojoFailureException
    {
        getLog().info( "Packaging Alfresco AMP (" + this.getAmpName() + ")" );

        
        this.buildExplodedAmp(this.getAmpDirectory());

        /* create and setup an archiver */
        MavenArchiver vArchiver = new MavenArchiver();
        vArchiver.setArchiver(this.getAmpArchiver());
        vArchiver.setOutputFile(pAmpFile);

        /* setup amp Archiver */
        this.getAmpArchiver().addDirectory(this.getAmpDirectory(), this.getIncludes(), this.getExcludes());

        // create archive
        vArchiver.createArchive(this.getProject(), archive );

        String vClassifier = this.getClassifier();
        
        if ( vClassifier != null )
        {
            this.getProjectHelper().attachArtifact( this.getProject(), "amp", vClassifier, pAmpFile );
        }
        else
        {
            Artifact vArtifact = this.getProject().getArtifact();
            
            if ( this.isPrimaryArtifact() )
            {
                vArtifact.setFile(pAmpFile);
            }
            else if(vArtifact.getFile() == null || vArtifact.getFile().isDirectory() )
            {
                vArtifact.setFile(pAmpFile);
            }
        }
    }


    /* ====================================================================== */
    // member fields
    /* ====================================================================== */
    
    /**
     * The directory for the generated AMP.
     *
     * @parameter expression="${project.build.directory}"
     * @required
     */
    private String mOutputDirectory;

    /**
     * The name of the generated AMP.
     *
     * @parameter expression="${project.build.finalName}"
     * @required
     */
    private String mAmpName;

    /**
     * Classifier to add to the artifact generated. If given, the artifact will be an attachment instead.
     *
     * @parameter
     */
    private String mClassifier;

    /**
     * The AMP archiver.
     * @parameter expression="${component.org.codehaus.plexus.archiver.Archiver#amp}"
     * @required
     */
    private AmpArchiver mAmpArchiver;


    /**
     * @component
     */
    private MavenProjectHelper mProjectHelper;
}
Loading