Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
add feature to unpack -webapp.zip plugins which are not really true n…
Browse files Browse the repository at this point in the history
…exus plugins - in this case artifactory migration plugin. needed to do this as a way to fix build failures of live snapshots as an alternative to including the migration plugin as a nexusPluginArtifact

git-svn-id: file:///opt/svn/repositories/sonatype.org/plugins/trunk/nexus-test-environment-maven-plugin@535 c2a14038-686d-4adc-8740-a14e5738cb64
  • Loading branch information
Peter Lynch committed Oct 1, 2010
1 parent e87bdd5 commit afa01b2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
Expand Up @@ -71,6 +71,8 @@ public class AbstractEnvironmentMojo
*/
public static final int MAX_PORT_ALLOCATION_RETRY = 3;

protected static final String PROP_NEXUS_BASE_DIR = "nexus-base-dir";

/** @component */
protected org.apache.maven.artifact.factory.ArtifactFactory artifactFactory;

Expand Down Expand Up @@ -253,6 +255,14 @@ public class AbstractEnvironmentMojo
*/
private String nexusBundleExcludes;

/**
* If there is one or more *-webapp.zip files in runtime/apps/nexus/plugin-repository, then unpack that zip to nexus
* base dir and delete the original file
*
* @parameter
*/
private boolean unpackPluginWebapps;

public void execute()
throws MojoExecutionException, MojoFailureException
{
Expand Down Expand Up @@ -283,8 +293,10 @@ public void execute()
}

// since specifying excludes/includes is not implemented for all archive types (tar.gz for example)
// remove files and dirs based on specified pattern after all of the files were unpacked, rather than during the unpack
// the use case for this is that a plugin we are installing later may include a plugin that is already included with bundle
// remove files and dirs based on specified pattern after all of the files were unpacked, rather than during the
// unpack
// the use case for this is that a plugin we are installing later may include a plugin that is already included
// with bundle
if ( nexusBundleExcludes != null )
{
deleteFromDirectory( destination, nexusBundleExcludes );
Expand All @@ -296,7 +308,7 @@ public void execute()
nexusBaseDir = new File( destination, nexusBundleName );
}
File nexusWorkDir = new File( destination, "nexus-work-dir" );
project.getProperties().put( "nexus-base-dir", getPath( nexusBaseDir ) );
project.getProperties().put( PROP_NEXUS_BASE_DIR, getPath( nexusBaseDir ) );
project.getProperties().put( "nexus-work-dir", getPath( nexusWorkDir ) );

// conf dir
Expand Down Expand Up @@ -346,6 +358,26 @@ public void execute()
}
}

if ( unpackPluginWebapps )
{
try
{
// now if we have *-webapp.zip in pluginfolder, unpack that to nexus-work-dir and delete zip file
@SuppressWarnings( "unchecked" )
List<File> webapps = FileUtils.getFiles( pluginFolder, "*-webapp.zip", null );
for ( File webapp : webapps )
{
unpack( webapp, new File( (String) project.getProperties().get( PROP_NEXUS_BASE_DIR ) ), "zip" );
webapp.delete();
}
}
catch ( IOException e )
{
throw new MojoExecutionException( "Failed to unpack webapp plugins:", e );
}

}

// setup Maven if requested for this test
if ( setupMaven )
{
Expand Down Expand Up @@ -430,8 +462,7 @@ protected void deleteFromDirectory( final File baseDirectory, final String patte
try
{
final List<String> filesToDelete =
FileUtils.getFileAndDirectoryNames( baseDirectory, patternsToDelete, null, true, true, true,
true );
FileUtils.getFileAndDirectoryNames( baseDirectory, patternsToDelete, null, true, true, true, true );
for ( String fileToDelete : filesToDelete )
{
FileUtils.forceDelete( fileToDelete );
Expand Down Expand Up @@ -1156,6 +1187,7 @@ private Collection<Artifact> getNonTransitivePlugins( Set<Artifact> projectArtif
LinkedHashSet<Artifact> plugins = new LinkedHashSet<Artifact>();
plugins.addAll( filtterArtifacts( result, getFilters( null, null, "nexus-plugin", null ) ) );
plugins.addAll( filtterArtifacts( result, getFilters( null, null, "zip", "bundle" ) ) );

plugins.addAll( getNonTransitivePlugins( plugins ) );

if ( !plugins.isEmpty() )
Expand Down
Expand Up @@ -21,6 +21,7 @@ public boolean isArtifactIncluded( Artifact artifact )
return true;
}

@SuppressWarnings( "rawtypes" )
public Set filter( Set artifacts )
throws ArtifactFilterException
{
Expand Down

0 comments on commit afa01b2

Please sign in to comment.