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

Commit

Permalink
OPEN - issue NEXUS-1724: Create a maven plugin to prepare nexus test …
Browse files Browse the repository at this point in the history
…environment

https://issues.sonatype.org/browse/NEXUS-1724

git-svn-id: file:///opt/svn/repositories/sonatype.org/plugins/trunk/nexus-test-environment-maven-plugin@168 c2a14038-686d-4adc-8740-a14e5738cb64
  • Loading branch information
velo committed Mar 9, 2009
1 parent f9f01a2 commit 96bfe5a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<dependency>
<groupId>org.sonatype.plugins</groupId>
<artifactId>port-allocator-maven-plugin</artifactId>
<version>1.0</version>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.Set;

Expand Down Expand Up @@ -34,6 +37,8 @@
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.sonatype.plugins.portallocator.Port;
import org.sonatype.plugins.portallocator.PortAllocatorMojo;

/**
* @author velo
Expand Down Expand Up @@ -153,6 +158,8 @@ public void execute()
{
init();

allocatePorts();

project.getProperties().put( "jetty-application-host", "0.0.0.0" );
project.getProperties().put(
"nexus-base-url",
Expand Down Expand Up @@ -243,6 +250,23 @@ public void execute()
}
}

private void allocatePorts()
throws MojoExecutionException, MojoFailureException
{
List<Port> portsList = new ArrayList<Port>();
portsList.add( new Port( "proxy-repo-port" ) );
portsList.add( new Port( "proxy-repo-control-port" ) );
portsList.add( new Port( "nexus-application-port" ) );
portsList.add( new Port( "nexus-control-port" ) );
portsList.add( new Port( "email-server-port" ) );
portsList.add( new Port( "webproxy-server-port" ) );

PortAllocatorMojo portAllocator = new PortAllocatorMojo();
portAllocator.setProject( project );
portAllocator.setPorts( portsList.toArray( new Port[0] ) );
portAllocator.execute();
}

private void copyExtraResources()
throws MojoExecutionException, MojoFailureException
{
Expand Down Expand Up @@ -378,19 +402,32 @@ private void copyAndInterpolate( File sourceDir, File destinationDir )
String[] files = scanner.getIncludedFiles();
for ( String file : files )
{
String extension = FileUtils.getExtension( file );

File source = new File( sourceDir, file );
source.getParentFile().mkdirs();

File destination = new File( destinationDir, file );
destination.getParentFile().mkdirs();

mavenFileFilter.copyFile( source, destination, true, project, null, false, "UTF-8", session );
if ( Arrays.asList( "zip", "jar", "tar.gz" ).contains( extension ) )
{
// just copy know binaries
FileUtils.copyFile( source, destination );
}
else
{
mavenFileFilter.copyFile( source, destination, true, project, null, false, "UTF-8", session );
}
}
}
catch ( MavenFilteringException e )
{
throw new MojoExecutionException( "Failed to copy : " + sourceDir, e );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Failed to copy : " + sourceDir, e );
}
}

private Artifact setupMaven()
Expand Down

0 comments on commit 96bfe5a

Please sign in to comment.