mirror of https://github.com/apache/maven.git
Java7 here too...
This commit is contained in:
parent
184f474c44
commit
248f1b4be5
|
@ -1,17 +1,6 @@
|
|||
package org.apache.maven.it;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.google.common.io.ByteStreams;
|
||||
import org.eclipse.jetty.security.ConstraintMapping;
|
||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||
import org.eclipse.jetty.security.HashLoginService;
|
||||
|
@ -25,13 +14,22 @@ import org.eclipse.jetty.util.security.Password;
|
|||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
|
||||
|
||||
import com.google.common.io.ByteStreams;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* An HTTP server that handles all requests on a given port from a specified source, optionally secured using BASIC auth
|
||||
* by providing a username and password. The source can either be a URL or a directory. When a request is made the
|
||||
* request is satisfied from the provided source.
|
||||
*
|
||||
*
|
||||
* @author Jason van Zyl
|
||||
*/
|
||||
public class HttpServer
|
||||
|
@ -89,7 +87,7 @@ public class HttpServer
|
|||
if ( username != null && password != null )
|
||||
{
|
||||
HashLoginService loginService = new HashLoginService( "Test Server" );
|
||||
loginService.putUser( username, new Password( password ), new String[] { "user" } );
|
||||
loginService.putUser( username, new Password( password ), new String[]{ "user" } );
|
||||
server.addBean( loginService );
|
||||
|
||||
ConstraintSecurityHandler security = new ConstraintSecurityHandler();
|
||||
|
@ -98,7 +96,7 @@ public class HttpServer
|
|||
Constraint constraint = new Constraint();
|
||||
constraint.setName( "auth" );
|
||||
constraint.setAuthenticate( true );
|
||||
constraint.setRoles( new String[] { "user", "admin" } );
|
||||
constraint.setRoles( new String[]{ "user", "admin" } );
|
||||
|
||||
ConstraintMapping mapping = new ConstraintMapping();
|
||||
mapping.setPathSpec( "/*" );
|
||||
|
@ -184,7 +182,7 @@ public class HttpServer
|
|||
}
|
||||
}
|
||||
|
||||
public static interface StreamSource
|
||||
public interface StreamSource
|
||||
{
|
||||
InputStream stream( String path )
|
||||
throws IOException;
|
||||
|
@ -204,13 +202,15 @@ public class HttpServer
|
|||
@Override
|
||||
public void handle( String target, Request baseRequest, HttpServletRequest request,
|
||||
HttpServletResponse response )
|
||||
throws IOException, ServletException
|
||||
throws IOException, ServletException
|
||||
{
|
||||
response.setContentType( "application/octet-stream" );
|
||||
response.setStatus( HttpServletResponse.SC_OK );
|
||||
try(InputStream in = source.stream( target.substring( 1 ) ); OutputStream out = response.getOutputStream() ) {
|
||||
ByteStreams.copy( in, out );
|
||||
}
|
||||
try ( InputStream in = source.stream(
|
||||
target.substring( 1 ) ); OutputStream out = response.getOutputStream() )
|
||||
{
|
||||
ByteStreams.copy( in, out );
|
||||
}
|
||||
baseRequest.setHandled( true );
|
||||
}
|
||||
}
|
||||
|
@ -219,11 +219,11 @@ public class HttpServer
|
|||
throws Exception
|
||||
{
|
||||
HttpServer server = HttpServer.builder() //
|
||||
.port( 0 ) //
|
||||
.username( "maven" ) //
|
||||
.password( "secret" ) //
|
||||
.source( new File( "/tmp/repo" ) ) //
|
||||
.build();
|
||||
.port( 0 ) //
|
||||
.username( "maven" ) //
|
||||
.password( "secret" ) //
|
||||
.source( new File( "/tmp/repo" ) ) //
|
||||
.build();
|
||||
server.start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,9 +35,8 @@ class ItUtils
|
|||
{
|
||||
MessageDigest digester = MessageDigest.getInstance( algo );
|
||||
|
||||
FileInputStream is = new FileInputStream( file );
|
||||
DigestInputStream dis;
|
||||
try
|
||||
try ( FileInputStream is = new FileInputStream( file ) )
|
||||
{
|
||||
dis = new DigestInputStream( is, digester );
|
||||
|
||||
|
@ -46,18 +45,14 @@ class ItUtils
|
|||
// just read it
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
is.close();
|
||||
}
|
||||
|
||||
byte[] digest = digester.digest();
|
||||
|
||||
StringBuffer hash = new StringBuffer( digest.length * 2 );
|
||||
StringBuilder hash = new StringBuilder( digest.length * 2 );
|
||||
|
||||
for ( int i = 0; i < digest.length; i++ )
|
||||
for ( byte aDigest : digest )
|
||||
{
|
||||
int b = digest[i] & 0xFF;
|
||||
int b = aDigest & 0xFF;
|
||||
|
||||
if ( b < 0x10 )
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -45,7 +44,7 @@ public class MavenIT0090EnvVarInterpolationTest
|
|||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0090" );
|
||||
|
||||
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
|
||||
Map<String, String> envVars = new HashMap<String, String>();
|
||||
Map<String, String> envVars = new HashMap<>();
|
||||
envVars.put( "MAVEN_TEST_ENVAR", "MAVEN_TEST_ENVAR_VALUE" );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.deleteDirectory( "target" );
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -28,7 +27,6 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -52,11 +50,11 @@ public class MavenIT0144LifecycleExecutionOrderTest
|
|||
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
|
||||
verifier.deleteDirectory( "target" );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.executeGoals( Arrays.asList( new String[] { "post-clean", "deploy", "site-deploy" } ) );
|
||||
verifier.executeGoals( Arrays.asList( new String[]{ "post-clean", "deploy", "site-deploy" } ) );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
List<String> expected = new ArrayList<String>();
|
||||
List<String> expected = new ArrayList<>();
|
||||
|
||||
expected.add( "pre-clean" );
|
||||
expected.add( "clean" );
|
||||
|
|
|
@ -19,20 +19,18 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-187">MNG-187</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng0187CollectedProjectsTest
|
||||
|
@ -66,24 +64,24 @@ public class MavenITmng0187CollectedProjectsTest
|
|||
|
||||
props = verifier.loadProperties( "target/project.properties" );
|
||||
assertEquals( "2", props.getProperty( "project.collectedProjects.size" ) );
|
||||
assertEquals( Arrays.asList( new String[] { "sub-1", "sub-2" } ), getProjects( props ) );
|
||||
assertEquals( Arrays.asList( new String[]{ "sub-1", "sub-2" } ), getProjects( props ) );
|
||||
|
||||
props = verifier.loadProperties( "sub-1/target/project.properties" );
|
||||
assertEquals( "1", props.getProperty( "project.collectedProjects.size" ) );
|
||||
assertEquals( Arrays.asList( new String[] { "sub-2" } ), getProjects( props ) );
|
||||
assertEquals( Arrays.asList( new String[]{ "sub-2" } ), getProjects( props ) );
|
||||
|
||||
props = verifier.loadProperties( "sub-1/sub-2/target/project.properties" );
|
||||
assertEquals( "0", props.getProperty( "project.collectedProjects.size" ) );
|
||||
assertEquals( Arrays.asList( new String[] {} ), getProjects( props ) );
|
||||
assertEquals( Arrays.asList( new String[]{} ), getProjects( props ) );
|
||||
}
|
||||
|
||||
private List<String> getProjects( Properties props )
|
||||
{
|
||||
List<String> projects = new ArrayList<String>();
|
||||
List<String> projects = new ArrayList<>();
|
||||
|
||||
for ( Iterator<?> it = props.keySet().iterator(); it.hasNext(); )
|
||||
for ( Object o : props.keySet() )
|
||||
{
|
||||
String key = it.next().toString();
|
||||
String key = o.toString();
|
||||
if ( key.startsWith( "project.collectedProjects." ) && !key.endsWith( ".size" ) )
|
||||
{
|
||||
projects.add( props.getProperty( key ) );
|
||||
|
|
|
@ -19,14 +19,13 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-1021">MNG-1021</a>.
|
||||
*
|
||||
*
|
||||
* @author John Casey
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -81,9 +80,9 @@ public class MavenITmng1021EqualAttachmentBuildNumberTest
|
|||
private String getSnapshotVersion( File artifactDir )
|
||||
{
|
||||
File[] files = artifactDir.listFiles();
|
||||
for ( int i = 0; i < files.length; i++ )
|
||||
for ( File file : files )
|
||||
{
|
||||
String name = files[i].getName();
|
||||
String name = file.getName();
|
||||
if ( name.endsWith( ".pom" ) )
|
||||
{
|
||||
return name.substring( "test-".length(), name.length() - ".pom".length() );
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -27,7 +26,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-1803">MNG-1803</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng1803PomValidationErrorIncludesLineNumberTest
|
||||
|
@ -67,7 +66,7 @@ public class MavenITmng1803PomValidationErrorIncludesLineNumberTest
|
|||
List<String> lines = verifier.loadLines( verifier.getLogFileName(), null );
|
||||
for ( String line : lines )
|
||||
{
|
||||
if ( line.indexOf( ":bad/id:" ) >= 0 )
|
||||
if ( line.contains( ":bad/id:" ) )
|
||||
{
|
||||
assertTrue( "Line number not found in: " + line, line.indexOf( "38" ) > 0 );
|
||||
assertTrue( "Column number not found in: " + line, line.indexOf( "19" ) > 0 );
|
||||
|
|
|
@ -19,14 +19,14 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.apache.maven.shared.utils.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-2362">MNG-2362</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng2362DeployedPomEncodingTest
|
||||
|
@ -92,8 +92,8 @@ public class MavenITmng2362DeployedPomEncodingTest
|
|||
{
|
||||
String prefix = "TEST-CHARS: ";
|
||||
int pos = pom.indexOf( prefix );
|
||||
assertTrue( "Corrupt data " + pom.substring( pos, pos + prefix.length() + chars.length() ) + " in " + pomFile,
|
||||
pom.indexOf( prefix + chars ) >= 0 );
|
||||
assertTrue( "Corrupt data " + pom.substring( pos, pos + prefix.length() + chars.length() ) + " in " + pomFile,
|
||||
pom.contains( prefix + chars ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.VerificationException;
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -29,11 +27,9 @@ import java.util.List;
|
|||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-2739">MNG-2739</a>.
|
||||
*
|
||||
* @todo Fill in a better description of what this test verifies!
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
* @author jdcasey
|
||||
*
|
||||
* @todo Fill in a better description of what this test verifies!
|
||||
*/
|
||||
public class MavenITmng2739RequiredRepositoryElementsTest
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
|
@ -57,8 +53,8 @@ public class MavenITmng2739RequiredRepositoryElementsTest
|
|||
{
|
||||
verifier.executeGoal( "validate" );
|
||||
|
||||
fail( "POM should NOT validate: repository <id/> element is missing in: "
|
||||
+ new File( testDir, "pom.xml" ) );
|
||||
fail(
|
||||
"POM should NOT validate: repository <id/> element is missing in: " + new File( testDir, "pom.xml" ) );
|
||||
}
|
||||
catch ( VerificationException e )
|
||||
{
|
||||
|
@ -71,7 +67,7 @@ public class MavenITmng2739RequiredRepositoryElementsTest
|
|||
boolean foundNpe = false;
|
||||
for ( String line : listing )
|
||||
{
|
||||
if ( line.indexOf( "NullPointerException" ) > -1 )
|
||||
if ( line.contains( "NullPointerException" ) )
|
||||
{
|
||||
foundNpe = true;
|
||||
break;
|
||||
|
@ -97,8 +93,8 @@ public class MavenITmng2739RequiredRepositoryElementsTest
|
|||
{
|
||||
verifier.executeGoal( "validate" );
|
||||
|
||||
fail( "POM should NOT validate: repository <url/> element is missing in: "
|
||||
+ new File( testDir, "pom.xml" ) );
|
||||
fail(
|
||||
"POM should NOT validate: repository <url/> element is missing in: " + new File( testDir, "pom.xml" ) );
|
||||
}
|
||||
catch ( VerificationException e )
|
||||
{
|
||||
|
@ -111,7 +107,7 @@ public class MavenITmng2739RequiredRepositoryElementsTest
|
|||
boolean foundNpe = false;
|
||||
for ( String line : listing )
|
||||
{
|
||||
if ( line.indexOf( "NullPointerException" ) > -1 )
|
||||
if ( line.contains( "NullPointerException" ) )
|
||||
{
|
||||
foundNpe = true;
|
||||
break;
|
||||
|
|
|
@ -19,14 +19,14 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.apache.maven.shared.utils.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-2820">MNG-2820</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng2820PomCommentsTest
|
||||
|
@ -78,7 +78,7 @@ public class MavenITmng2820PomCommentsTest
|
|||
private void assertPomComment( String pom, String comment )
|
||||
throws Exception
|
||||
{
|
||||
assertTrue( "Missing comment: " + comment, pom.indexOf( comment ) >= 0 );
|
||||
assertTrue( "Missing comment: " + comment, pom.contains( comment ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.VerificationException;
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -32,7 +30,6 @@ import java.util.List;
|
|||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-2883">MNG-2883</a>.
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
*
|
||||
*/
|
||||
public class MavenITmng2883LegacyRepoOfflineTest
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
|
@ -56,7 +53,7 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
verifier.deleteDirectory( "target" );
|
||||
verifier.deleteArtifacts( "org.apache.maven.its.mng2883" );
|
||||
|
||||
File settings = verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
|
||||
File settings = verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
|
||||
verifier.newDefaultFilterProperties() );
|
||||
|
||||
// used to inject the remote repository
|
||||
|
@ -72,7 +69,8 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
}
|
||||
catch ( VerificationException e )
|
||||
{
|
||||
throw new VerificationException( "Build should succeed the first time through when NOT in offline mode!", e );
|
||||
throw new VerificationException( "Build should succeed the first time through when NOT in offline mode!",
|
||||
e );
|
||||
}
|
||||
|
||||
// the centerpiece of these tests!
|
||||
|
@ -97,7 +95,7 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
// expected
|
||||
}
|
||||
|
||||
List<String> missingMessages = new ArrayList<String>();
|
||||
List<String> missingMessages = new ArrayList<>();
|
||||
missingMessages.add( " is offline" );
|
||||
missingMessages.add( "org.apache.maven.its.mng2883:parent:pom:1.0-SNAPSHOT" );
|
||||
|
||||
|
@ -109,7 +107,7 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
{
|
||||
String message = messageIt.next();
|
||||
|
||||
if ( line.indexOf( message ) > -1 )
|
||||
if ( line.contains( message ) )
|
||||
{
|
||||
messageIt.remove();
|
||||
}
|
||||
|
@ -118,7 +116,7 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
|
||||
if ( !missingMessages.isEmpty() )
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append( "The following key messages were missing from build output:\n\n" );
|
||||
|
||||
|
@ -148,7 +146,7 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
verifier.deleteDirectory( "target" );
|
||||
verifier.deleteArtifacts( "org.apache.maven.its.mng2883" );
|
||||
|
||||
File settings = verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
|
||||
File settings = verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
|
||||
verifier.newDefaultFilterProperties() );
|
||||
|
||||
// used to inject the remote repository
|
||||
|
@ -164,7 +162,8 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
}
|
||||
catch ( VerificationException e )
|
||||
{
|
||||
throw new VerificationException( "Build should succeed the first time through when NOT in offline mode!", e );
|
||||
throw new VerificationException( "Build should succeed the first time through when NOT in offline mode!",
|
||||
e );
|
||||
}
|
||||
|
||||
// the centerpiece of these tests!
|
||||
|
@ -189,7 +188,7 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
// expected
|
||||
}
|
||||
|
||||
List<String> missingMessages = new ArrayList<String>();
|
||||
List<String> missingMessages = new ArrayList<>();
|
||||
|
||||
// FIXME: We need a more prominent diagnosis including system being in offline mode for 2.0.x.
|
||||
missingMessages.add( "offline mode." );
|
||||
|
@ -203,7 +202,7 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
{
|
||||
String message = (String) messageIt.next();
|
||||
|
||||
if ( line.indexOf( message ) > -1 )
|
||||
if ( line.contains( message ) )
|
||||
{
|
||||
messageIt.remove();
|
||||
}
|
||||
|
@ -212,7 +211,7 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
|
||||
if ( !missingMessages.isEmpty() )
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append( "The following key messages were missing from build output:\n\n" );
|
||||
|
||||
|
@ -242,7 +241,7 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
verifier.deleteDirectory( "target" );
|
||||
verifier.deleteArtifacts( "org.apache.maven.its.mng2883" );
|
||||
|
||||
File settings = verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
|
||||
File settings = verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
|
||||
verifier.newDefaultFilterProperties() );
|
||||
|
||||
// used to inject the remote repository
|
||||
|
@ -274,7 +273,7 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
// expected
|
||||
}
|
||||
|
||||
List<String> missingMessages = new ArrayList<String>();
|
||||
List<String> missingMessages = new ArrayList<>();
|
||||
missingMessages.add( " is offline" );
|
||||
missingMessages.add( "org.apache.maven.its.mng2883:plugin" );
|
||||
|
||||
|
@ -286,7 +285,7 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
{
|
||||
String message = messageIt.next();
|
||||
|
||||
if ( line.indexOf( message ) > -1 )
|
||||
if ( line.contains( message ) )
|
||||
{
|
||||
messageIt.remove();
|
||||
}
|
||||
|
@ -295,7 +294,7 @@ public class MavenITmng2883LegacyRepoOfflineTest
|
|||
|
||||
if ( !missingMessages.isEmpty() )
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append( "The following key messages were missing from build output:\n\n" );
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.VerificationException;
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -28,7 +26,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3220">MNG-3220</a>.
|
||||
*
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MavenITmng3220ImportScopeTest
|
||||
|
@ -50,7 +48,8 @@ public class MavenITmng3220ImportScopeTest
|
|||
verifier.setAutoclean( false );
|
||||
verifier.deleteDirectory( "target" );
|
||||
verifier.deleteArtifacts( "org.apache.maven.its.mng3220" );
|
||||
verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
|
||||
verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
|
||||
verifier.newDefaultFilterProperties() );
|
||||
verifier.addCliOption( "--settings" );
|
||||
verifier.addCliOption( "settings.xml" );
|
||||
verifier.executeGoal( "validate" );
|
||||
|
@ -69,7 +68,8 @@ public class MavenITmng3220ImportScopeTest
|
|||
verifier.setAutoclean( false );
|
||||
verifier.deleteDirectory( "target" );
|
||||
verifier.deleteArtifacts( "org.apache.maven.its.mng3220" );
|
||||
verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
|
||||
verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
|
||||
verifier.newDefaultFilterProperties() );
|
||||
verifier.addCliOption( "--settings" );
|
||||
verifier.addCliOption( "settings.xml" );
|
||||
|
||||
|
@ -91,8 +91,8 @@ public class MavenITmng3220ImportScopeTest
|
|||
boolean found = false;
|
||||
for ( String line : lines )
|
||||
{
|
||||
if ( line.indexOf( "\'dependencies.dependency.version\' is missing for junit:junit" ) > -1
|
||||
|| line.indexOf( "\'dependencies.dependency.version\' for junit:junit:jar is missing" ) > -1 )
|
||||
if ( line.contains( "\'dependencies.dependency.version\' is missing for junit:junit" ) || line.contains(
|
||||
"\'dependencies.dependency.version\' for junit:junit:jar is missing" ) )
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
|
|
|
@ -19,15 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.apache.maven.shared.utils.io.FileUtils;
|
||||
import org.mortbay.jetty.Handler;
|
||||
|
@ -35,9 +26,17 @@ import org.mortbay.jetty.Request;
|
|||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.handler.AbstractHandler;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3415">MNG-3415</a>.
|
||||
*
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MavenITmng3415JunkRepositoryMetadataTest
|
||||
|
@ -56,25 +55,25 @@ public class MavenITmng3415JunkRepositoryMetadataTest
|
|||
/**
|
||||
* This test simply verifies that when a metadata transfer fails (network error, etc.)
|
||||
* no metadata file is written to the local repository.
|
||||
*
|
||||
* <p/>
|
||||
* Steps executed to verify this test:
|
||||
*
|
||||
* <p/>
|
||||
* 0. Find the local repository directory:
|
||||
* a. build the maven-find-local-repo-plugin, then run it, to spit out the path of the
|
||||
* local repository in use by default. Read the output file to get this path.
|
||||
* (Yes, it's heavy, but it's reliable.)
|
||||
* a. build the maven-find-local-repo-plugin, then run it, to spit out the path of the
|
||||
* local repository in use by default. Read the output file to get this path.
|
||||
* (Yes, it's heavy, but it's reliable.)
|
||||
* 1. Setup the test:
|
||||
* a. Make sure the metadata for the test-repo is NOT in the local repository.
|
||||
* b. Make sure the dependency POM IS in the local repository, so we're not
|
||||
* distracted by failed builds that are unrelated.
|
||||
* c. Create the settings file for use in this test, which contains the invalid
|
||||
* remote repository entry.
|
||||
* a. Make sure the metadata for the test-repo is NOT in the local repository.
|
||||
* b. Make sure the dependency POM IS in the local repository, so we're not
|
||||
* distracted by failed builds that are unrelated.
|
||||
* c. Create the settings file for use in this test, which contains the invalid
|
||||
* remote repository entry.
|
||||
* 2. Build the test project the first time
|
||||
* a. Verify that a TransferFailedException is in the build output for the test-repo
|
||||
* b. Verify that the metadata for the dependency POM is NOT in the local
|
||||
* repository afterwards.
|
||||
* a. Verify that a TransferFailedException is in the build output for the test-repo
|
||||
* b. Verify that the metadata for the dependency POM is NOT in the local
|
||||
* repository afterwards.
|
||||
* 3. Build the test project the second time
|
||||
* a. See (2.a) and (2.b) above; the same criteria applies here.
|
||||
* a. See (2.a) and (2.b) above; the same criteria applies here.
|
||||
*/
|
||||
public void testitTransferFailed()
|
||||
throws Exception
|
||||
|
@ -126,25 +125,25 @@ public class MavenITmng3415JunkRepositoryMetadataTest
|
|||
/**
|
||||
* This test simply verifies that when metadata doesn't exist on the remote
|
||||
* repository, a basic metadata file is written to the local repository.
|
||||
*
|
||||
* <p/>
|
||||
* Steps executed to verify this test:
|
||||
*
|
||||
* <p/>
|
||||
* 0. Find the local repository directory:
|
||||
* a. build the maven-find-local-repo-plugin, then run it, to spit out the path of the
|
||||
* local repository in use by default. Read the output file to get this path.
|
||||
* (Yes, it's heavy, but it's reliable.)
|
||||
* a. build the maven-find-local-repo-plugin, then run it, to spit out the path of the
|
||||
* local repository in use by default. Read the output file to get this path.
|
||||
* (Yes, it's heavy, but it's reliable.)
|
||||
* 1. Setup the test:
|
||||
* a. Make sure the metadata for the test-repo is NOT in the local repository.
|
||||
* b. Make sure the dependency POM IS in the local repository, so we're not
|
||||
* distracted by failed builds that are unrelated.
|
||||
* c. Create the settings file for use in this test, which contains the VALID
|
||||
* remote repository entry.
|
||||
* a. Make sure the metadata for the test-repo is NOT in the local repository.
|
||||
* b. Make sure the dependency POM IS in the local repository, so we're not
|
||||
* distracted by failed builds that are unrelated.
|
||||
* c. Create the settings file for use in this test, which contains the VALID
|
||||
* remote repository entry.
|
||||
* 2. Build the test project the first time
|
||||
* a. Verify that the remote repository is checked for the metadata file
|
||||
* a. Verify that the remote repository is checked for the metadata file
|
||||
* 3. Build the test project the second time
|
||||
* a. Verify that the remote repository is NOT checked for the metadata file again
|
||||
* b. Verify that the file used for updateInterval calculations was NOT changed from
|
||||
* the first build.
|
||||
* a. Verify that the remote repository is NOT checked for the metadata file again
|
||||
* b. Verify that the file used for updateInterval calculations was NOT changed from
|
||||
* the first build.
|
||||
*/
|
||||
public void testShouldNotRepeatedlyUpdateOnResourceNotFoundException()
|
||||
throws Exception
|
||||
|
@ -159,7 +158,7 @@ public class MavenITmng3415JunkRepositoryMetadataTest
|
|||
verifier.setAutoclean( false );
|
||||
verifier.deleteArtifacts( "org.apache.maven.its.mng3415" );
|
||||
|
||||
final List<String> requestUris = new ArrayList<String>();
|
||||
final List<String> requestUris = new ArrayList<>();
|
||||
|
||||
Handler repoHandler = new AbstractHandler()
|
||||
{
|
||||
|
@ -199,8 +198,8 @@ public class MavenITmng3415JunkRepositoryMetadataTest
|
|||
|
||||
verifier.verifyErrorFreeLog();
|
||||
|
||||
assertTrue( requestUris.toString(),
|
||||
requestUris.contains( "/org/apache/maven/its/mng3415/missing/1.0-SNAPSHOT/maven-metadata.xml" ) );
|
||||
assertTrue( requestUris.toString(), requestUris.contains(
|
||||
"/org/apache/maven/its/mng3415/missing/1.0-SNAPSHOT/maven-metadata.xml" ) );
|
||||
|
||||
requestUris.clear();
|
||||
|
||||
|
@ -215,10 +214,13 @@ public class MavenITmng3415JunkRepositoryMetadataTest
|
|||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
assertFalse( requestUris.toString(),
|
||||
requestUris.contains( "/org/apache/maven/its/mng3415/missing/1.0-SNAPSHOT/maven-metadata.xml" ) );
|
||||
assertFalse( requestUris.toString(), requestUris.contains(
|
||||
"/org/apache/maven/its/mng3415/missing/1.0-SNAPSHOT/maven-metadata.xml" ) );
|
||||
|
||||
assertEquals( "Last-modified time should be unchanged from first build through second build for the file we use for updateInterval checks.", firstLastMod, updateCheckFile.lastModified() );
|
||||
assertEquals(
|
||||
"Last-modified time should be unchanged from first build through second build for the file we use for"
|
||||
+ " updateInterval checks.",
|
||||
firstLastMod, updateCheckFile.lastModified() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -231,8 +233,8 @@ public class MavenITmng3415JunkRepositoryMetadataTest
|
|||
{
|
||||
File metadata = getMetadataFile( verifier );
|
||||
|
||||
assertFalse( "Metadata file should NOT be present in local repository: "
|
||||
+ metadata.getAbsolutePath(), metadata.exists() );
|
||||
assertFalse( "Metadata file should NOT be present in local repository: " + metadata.getAbsolutePath(),
|
||||
metadata.exists() );
|
||||
}
|
||||
|
||||
private void setupDummyDependency( Verifier verifier, File testDir, boolean resetUpdateInterval )
|
||||
|
|
|
@ -19,19 +19,19 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.apache.maven.shared.utils.io.FileUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3441">MNG-3441</a>.
|
||||
*
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MavenITmng3441MetadataUpdatedFromDeploymentRepositoryTest
|
||||
|
@ -45,8 +45,7 @@ public class MavenITmng3441MetadataUpdatedFromDeploymentRepositoryTest
|
|||
public void testitMNG3441()
|
||||
throws Exception
|
||||
{
|
||||
File testDir =
|
||||
ResourceExtractor.simpleExtractResources( getClass(), "/mng-3441" );
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3441" );
|
||||
|
||||
File targetRepository = new File( testDir, "target-repo" );
|
||||
FileUtils.deleteDirectory( targetRepository );
|
||||
|
@ -63,7 +62,8 @@ public class MavenITmng3441MetadataUpdatedFromDeploymentRepositoryTest
|
|||
verifier.verifyErrorFreeLog();
|
||||
|
||||
Xpp3Dom dom = readDom( new File( targetRepository,
|
||||
"org/apache/maven/its/mng3441/test-artifact/1.0-SNAPSHOT/maven-metadata.xml" ) );
|
||||
"org/apache/maven/its/mng3441/test-artifact/1.0-SNAPSHOT/maven-metadata.xml"
|
||||
) );
|
||||
assertEquals( "2", dom.getChild( "versioning" ).getChild( "snapshot" ).getChild( "buildNumber" ).getValue() );
|
||||
|
||||
dom = readDom( new File( targetRepository, "org/apache/maven/its/mng3441/maven-metadata.xml" ) );
|
||||
|
@ -77,14 +77,9 @@ public class MavenITmng3441MetadataUpdatedFromDeploymentRepositoryTest
|
|||
private Xpp3Dom readDom( File file )
|
||||
throws XmlPullParserException, IOException
|
||||
{
|
||||
FileReader reader = new FileReader( file );
|
||||
try
|
||||
try ( FileReader reader = new FileReader( file ) )
|
||||
{
|
||||
return Xpp3DomBuilder.build( reader );
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,19 +19,18 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3710">MNG-3710</a>.
|
||||
*
|
||||
* @todo Fill in a better description of what this test verifies!
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
* @author jdcasey
|
||||
* @todo Fill in a better description of what this test verifies!
|
||||
*/
|
||||
public class MavenITmng3710PollutedClonedPluginsTest
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
|
@ -44,8 +43,7 @@ public class MavenITmng3710PollutedClonedPluginsTest
|
|||
public void testitMNG3710_POMInheritance()
|
||||
throws Exception
|
||||
{
|
||||
File testDir =
|
||||
ResourceExtractor.simpleExtractResources( getClass(), "/mng-3710/pom-inheritance" );
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3710/pom-inheritance" );
|
||||
File pluginDir = new File( testDir, "maven-mng3710-pomInheritance-plugin" );
|
||||
File projectsDir = new File( testDir, "projects" );
|
||||
|
||||
|
@ -77,8 +75,7 @@ public class MavenITmng3710PollutedClonedPluginsTest
|
|||
public void testitMNG3710_OriginalModel()
|
||||
throws Exception
|
||||
{
|
||||
File testDir =
|
||||
ResourceExtractor.simpleExtractResources( getClass(), "/mng-3710/original-model" );
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3710/original-model" );
|
||||
File pluginsDir = new File( testDir, "plugins" );
|
||||
File projectDir = new File( testDir, "project" );
|
||||
|
||||
|
@ -91,11 +88,11 @@ public class MavenITmng3710PollutedClonedPluginsTest
|
|||
verifier.resetStreams();
|
||||
|
||||
verifier = newVerifier( projectDir.getAbsolutePath() );
|
||||
|
||||
List<String> goals = new ArrayList<String>();
|
||||
|
||||
List<String> goals = new ArrayList<>();
|
||||
goals.add( "org.apache.maven.its.mng3710:mavenit-mng3710-directInvoke-plugin:1:run" );
|
||||
goals.add( "validate" );
|
||||
|
||||
|
||||
verifier.executeGoals( goals );
|
||||
|
||||
verifier.verifyErrorFreeLog();
|
||||
|
|
|
@ -19,16 +19,16 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3719">MNG-3719</a>.
|
||||
*
|
||||
*
|
||||
* @author Brett Porter
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -63,11 +63,11 @@ public class MavenITmng3719PomExecutionOrderingTest
|
|||
for ( int i = 0; i < content.size(); i++ )
|
||||
{
|
||||
String line = (String) content.get( i );
|
||||
|
||||
|
||||
Matcher m = pattern.matcher( line );
|
||||
if ( m.matches() )
|
||||
{
|
||||
int step = Integer.valueOf( m.group( 1 ) ).intValue();
|
||||
int step = Integer.valueOf( m.group( 1 ) );
|
||||
stepLines[step - 1] = i + 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -31,7 +30,7 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3732">MNG-3732</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -63,7 +62,7 @@ public class MavenITmng3732ActiveProfilesTest
|
|||
verifier.resetStreams();
|
||||
|
||||
Properties props = verifier.loadProperties( "target/profile.properties" );
|
||||
List<String> ids = new ArrayList<String>();
|
||||
List<String> ids = new ArrayList<>();
|
||||
|
||||
// support for profiles.xml removed from 3.x (see MNG-4060)
|
||||
if ( matchesVersionRange( "[2.0,3.0-alpha-1)" ) )
|
||||
|
@ -75,7 +74,7 @@ public class MavenITmng3732ActiveProfilesTest
|
|||
ids.remove( "it-defaults" );
|
||||
Collections.sort( ids );
|
||||
|
||||
assertEquals( Arrays.asList( new String[] { "pom", "profiles", "settings" } ), ids );
|
||||
assertEquals( Arrays.asList( new String[]{ "pom", "profiles", "settings" } ), ids );
|
||||
assertEquals( "4", props.getProperty( "project.activeProfiles" ) );
|
||||
|
||||
assertEquals( "PASSED-1", props.getProperty( "project.properties.pomProperty" ) );
|
||||
|
@ -90,9 +89,9 @@ public class MavenITmng3732ActiveProfilesTest
|
|||
ids.remove( "it-defaults" );
|
||||
Collections.sort( ids );
|
||||
|
||||
assertEquals( Arrays.asList( new String[] { "pom", "settings" } ), ids );
|
||||
assertEquals( Arrays.asList( new String[]{ "pom", "settings" } ), ids );
|
||||
assertEquals( "3", props.getProperty( "project.activeProfiles" ) );
|
||||
|
||||
|
||||
assertEquals( "PASSED-1", props.getProperty( "project.properties.pomProperty" ) );
|
||||
assertEquals( "PASSED-2", props.getProperty( "project.properties.settingsProperty" ) );
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -27,7 +26,7 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3807">MNG-3807</a>.
|
||||
*
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MavenITmng3807PluginConfigExpressionEvaluationTest
|
||||
|
@ -73,7 +72,7 @@ public class MavenITmng3807PluginConfigExpressionEvaluationTest
|
|||
{
|
||||
assertNotNull( value );
|
||||
assertTrue( value.length() > 0 );
|
||||
assertTrue( value, value.indexOf( "${" ) < 0 );
|
||||
assertTrue( value, !value.contains( "${" ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,18 +19,16 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3843">MNG-3843</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -100,7 +98,8 @@ public class MavenITmng3843PomInheritanceTest
|
|||
assertEquals( "1", props.getProperty( "project.build.resources" ) );
|
||||
assertPathEquals( basedir, "src/main/resources", props.getProperty( "project.build.resources.0.directory" ) );
|
||||
assertEquals( "1", props.getProperty( "project.build.testResources" ) );
|
||||
assertPathEquals( basedir, "src/test/resources", props.getProperty( "project.build.testResources.0.directory" ) );
|
||||
assertPathEquals( basedir, "src/test/resources",
|
||||
props.getProperty( "project.build.testResources.0.directory" ) );
|
||||
assertPathEquals( basedir, "target", props.getProperty( "project.build.directory" ) );
|
||||
assertPathEquals( basedir, "target/classes", props.getProperty( "project.build.outputDirectory" ) );
|
||||
assertPathEquals( basedir, "target/test-classes", props.getProperty( "project.build.testOutputDirectory" ) );
|
||||
|
@ -147,9 +146,11 @@ public class MavenITmng3843PomInheritanceTest
|
|||
assertEquals( "http://parent.url/ci", props.getProperty( "project.ciManagement.url" ) );
|
||||
assertEquals( "http://parent.url/issues", props.getProperty( "project.issueManagement.url" ) );
|
||||
assertEquals( "http://parent.url/dist", props.getProperty( "project.distributionManagement.repository.url" ) );
|
||||
assertEquals( "http://parent.url/snaps", props.getProperty( "project.distributionManagement.snapshotRepository.url" ) );
|
||||
assertEquals( "http://parent.url/snaps",
|
||||
props.getProperty( "project.distributionManagement.snapshotRepository.url" ) );
|
||||
assertUrlCommon( "http://parent.url/site", props.getProperty( "project.distributionManagement.site.url" ) );
|
||||
assertUrlCommon( "http://parent.url/download", props.getProperty( "project.distributionManagement.downloadUrl" ) );
|
||||
assertUrlCommon( "http://parent.url/download",
|
||||
props.getProperty( "project.distributionManagement.downloadUrl" ) );
|
||||
if ( matchesVersionRange( "(2.0.2,)" ) )
|
||||
{
|
||||
assertMissing( props, "project.distributionManagement.relocation." );
|
||||
|
@ -214,9 +215,11 @@ public class MavenITmng3843PomInheritanceTest
|
|||
assertEquals( "http://child.url/ci", props.getProperty( "project.ciManagement.url" ) );
|
||||
assertEquals( "http://child.url/issues", props.getProperty( "project.issueManagement.url" ) );
|
||||
assertEquals( "http://child.url/dist", props.getProperty( "project.distributionManagement.repository.url" ) );
|
||||
assertEquals( "http://child.url/snaps", props.getProperty( "project.distributionManagement.snapshotRepository.url" ) );
|
||||
assertEquals( "http://child.url/snaps",
|
||||
props.getProperty( "project.distributionManagement.snapshotRepository.url" ) );
|
||||
assertUrlCommon( "http://child.url/site", props.getProperty( "project.distributionManagement.site.url" ) );
|
||||
assertUrlCommon( "http://child.url/download", props.getProperty( "project.distributionManagement.downloadUrl" ) );
|
||||
assertUrlCommon( "http://child.url/download",
|
||||
props.getProperty( "project.distributionManagement.downloadUrl" ) );
|
||||
assertEquals( "child-reloc-msg", props.getProperty( "project.distributionManagement.relocation.message" ) );
|
||||
assertMissing( props, "project.profiles." );
|
||||
assertEquals( "coreit", props.getProperty( "project.build.finalName" ) );
|
||||
|
@ -239,22 +242,22 @@ public class MavenITmng3843PomInheritanceTest
|
|||
assertEquals( "1", props.getProperty( "project.build.plugins" ) );
|
||||
}
|
||||
assertEquals( "4", props.getProperty( "project.dependencies" ) );
|
||||
Collection<String> actualDeps = new TreeSet<String>();
|
||||
Collection<String> actualDeps = new TreeSet<>();
|
||||
actualDeps.add( props.getProperty( "project.dependencies.0.artifactId" ) );
|
||||
actualDeps.add( props.getProperty( "project.dependencies.1.artifactId" ) );
|
||||
actualDeps.add( props.getProperty( "project.dependencies.2.artifactId" ) );
|
||||
actualDeps.add( props.getProperty( "project.dependencies.3.artifactId" ) );
|
||||
Collection<String> expectedDeps = new TreeSet<String>();
|
||||
Collection<String> expectedDeps = new TreeSet<>();
|
||||
expectedDeps.add( "parent-dep-b" );
|
||||
expectedDeps.add( "child-dep-b" );
|
||||
expectedDeps.add( "child-dep-c" );
|
||||
expectedDeps.add( "child-dep-d" );
|
||||
assertEquals( expectedDeps, actualDeps );
|
||||
assertEquals( "2", props.getProperty( "project.dependencyManagement.dependencies" ) );
|
||||
Collection<String> actualMngtDeps = new TreeSet<String>();
|
||||
Collection<String> actualMngtDeps = new TreeSet<>();
|
||||
actualMngtDeps.add( props.getProperty( "project.dependencyManagement.dependencies.0.artifactId" ) );
|
||||
actualMngtDeps.add( props.getProperty( "project.dependencyManagement.dependencies.1.artifactId" ) );
|
||||
Collection<String> expectedMngtDeps = new TreeSet<String>();
|
||||
Collection<String> expectedMngtDeps = new TreeSet<>();
|
||||
expectedMngtDeps.add( "parent-dep-a" );
|
||||
expectedMngtDeps.add( "child-dep-a" );
|
||||
assertEquals( expectedMngtDeps, actualMngtDeps );
|
||||
|
@ -286,9 +289,9 @@ public class MavenITmng3843PomInheritanceTest
|
|||
|
||||
private void assertMissing( Properties props, String prefix )
|
||||
{
|
||||
for ( Iterator<?> it = props.keySet().iterator(); it.hasNext(); )
|
||||
for ( Object o : props.keySet() )
|
||||
{
|
||||
String key = it.next().toString();
|
||||
String key = o.toString();
|
||||
assertFalse( "Found unexpected key: " + key, key.startsWith( prefix ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,17 +19,17 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.apache.maven.shared.utils.Os;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.apache.maven.shared.utils.Os;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3940">MNG-3940</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -51,7 +51,7 @@ public class MavenITmng3940EnvVarInterpolationTest
|
|||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3940" );
|
||||
|
||||
Map<String, String> envVars = new HashMap<String, String>();
|
||||
Map<String, String> envVars = new HashMap<>();
|
||||
/*
|
||||
* NOTE: The POM is using MAVEN_MNG_3940 to reference the var (just as one would refer to PATH). On Windows,
|
||||
* this must resolve case-insensitively so we use different character casing for the variable here.
|
||||
|
@ -64,7 +64,7 @@ public class MavenITmng3940EnvVarInterpolationTest
|
|||
{
|
||||
envVars.put( "MAVEN_MNG_3940", "PASSED" );
|
||||
}
|
||||
|
||||
|
||||
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.deleteDirectory( "target" );
|
||||
|
|
|
@ -19,12 +19,12 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4091">MNG-4091</a>:
|
||||
* Bad plugin descriptor error handling
|
||||
|
@ -61,7 +61,6 @@ public class MavenITmng4091BadPluginDescriptorTest
|
|||
verifier.resetStreams();
|
||||
}
|
||||
|
||||
|
||||
List<String> logFile = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
|
||||
|
||||
String msg = "Plugin's descriptor contains the wrong version: 2.0-SNAPSHOT";
|
||||
|
@ -69,7 +68,7 @@ public class MavenITmng4091BadPluginDescriptorTest
|
|||
boolean foundMessage = false;
|
||||
for ( String line : logFile )
|
||||
{
|
||||
if ( line.indexOf( msg ) > -1 )
|
||||
if ( line.contains( msg ) )
|
||||
{
|
||||
foundMessage = true;
|
||||
break;
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -29,7 +28,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4180">MNG-4180</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4180PerDependencyExclusionsTest
|
||||
|
@ -64,7 +63,7 @@ public class MavenITmng4180PerDependencyExclusionsTest
|
|||
List<String> artifacts = verifier.loadLines( "target/artifacts.txt", "UTF-8" );
|
||||
Collections.sort( artifacts );
|
||||
|
||||
List<String> expected = new ArrayList<String>();
|
||||
List<String> expected = new ArrayList<>();
|
||||
expected.add( "org.apache.maven.its.mng4180:a:jar:0.1" );
|
||||
expected.add( "org.apache.maven.its.mng4180:b:jar:0.1" );
|
||||
expected.add( "org.apache.maven.its.mng4180:c:jar:0.1" );
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -30,7 +29,7 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4190">MNG-4190</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4190MirrorRepoMergingTest
|
||||
|
@ -66,7 +65,7 @@ public class MavenITmng4190MirrorRepoMergingTest
|
|||
List<String> artifacts = verifier.loadLines( "target/artifacts.txt", "UTF-8" );
|
||||
Collections.sort( artifacts );
|
||||
|
||||
List<String> expected = new ArrayList<String>();
|
||||
List<String> expected = new ArrayList<>();
|
||||
expected.add( "org.apache.maven.its.mng4190:a:jar:0.1" );
|
||||
expected.add( "org.apache.maven.its.mng4190:b:jar:0.1-SNAPSHOT" );
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -29,7 +28,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4203">MNG-4203</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4203TransitiveDependencyExclusionTest
|
||||
|
@ -63,7 +62,7 @@ public class MavenITmng4203TransitiveDependencyExclusionTest
|
|||
List<String> artifacts = verifier.loadLines( "target/artifacts.txt", "UTF-8" );
|
||||
Collections.sort( artifacts );
|
||||
|
||||
List<String> expected = new ArrayList<String>();
|
||||
List<String> expected = new ArrayList<>();
|
||||
expected.add( "org.apache.maven.its.mng4203:b:jar:0.1" );
|
||||
expected.add( "org.apache.maven.its.mng4203:c:jar:0.1" );
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ public class MavenITmng4235HttpAuthDeploymentChecksumsTest
|
|||
public static class RepoHandler
|
||||
extends ResourceHandler
|
||||
{
|
||||
List<DeployedResource> deployedResources = new ArrayList<DeployedResource>();
|
||||
List<DeployedResource> deployedResources = new ArrayList<>();
|
||||
|
||||
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
|
||||
throws IOException, ServletException
|
||||
|
@ -193,18 +193,12 @@ public class MavenITmng4235HttpAuthDeploymentChecksumsTest
|
|||
dir.mkdirs();
|
||||
}
|
||||
|
||||
OutputStream os = resource.getOutputStream();
|
||||
|
||||
request.getContentLength();
|
||||
|
||||
try
|
||||
try ( OutputStream os = resource.getOutputStream() )
|
||||
{
|
||||
IO.copy( request.getInputStream(), os );
|
||||
}
|
||||
finally
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
|
||||
DeployedResource deployedResource = new DeployedResource();
|
||||
|
||||
|
|
|
@ -56,29 +56,30 @@ public class MavenITmng4275RelocationWarningTest
|
|||
verifier.executeGoal( "validate" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
|
||||
List<String> lines = verifier.loadFile( new File( testDir, verifier.getLogFileName() ), false );
|
||||
boolean foundWarning = false;
|
||||
for ( String line : lines )
|
||||
{
|
||||
if ( foundWarning )
|
||||
{
|
||||
assertTrue(
|
||||
"Relocation target should have been logged right after warning.",
|
||||
line.indexOf( "This artifact has been relocated to org.apache.maven.its.mng4275:relocated:1" ) > -1 );
|
||||
assertTrue( "Relocation target should have been logged right after warning.", line.contains(
|
||||
"This artifact has been relocated to org.apache.maven.its.mng4275:relocated:1" ) );
|
||||
break;
|
||||
}
|
||||
else if ( line.startsWith( "[WARNING] While downloading org.apache.maven.its.mng4275:relocation:1" ) )
|
||||
{
|
||||
foundWarning = true;
|
||||
}
|
||||
else if ( line.matches( "\\[WARNING\\].* org.apache.maven.its.mng4275:relocation:jar:1 .* org.apache.maven.its.mng4275:relocated:jar:1.*" ) )
|
||||
else if ( line.matches(
|
||||
"\\[WARNING\\].* org.apache.maven.its.mng4275:relocation:jar:1 .* org.apache.maven.its"
|
||||
+ ".mng4275:relocated:jar:1.*" ) )
|
||||
{
|
||||
foundWarning = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
assertTrue( "Relocation warning should haven been logged.", foundWarning );
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,15 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.mortbay.jetty.Handler;
|
||||
import org.mortbay.jetty.Request;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.handler.AbstractHandler;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
@ -30,18 +36,9 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.mortbay.jetty.Handler;
|
||||
import org.mortbay.jetty.Request;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.handler.AbstractHandler;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4326">MNG-4326</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4326LocalSnapshotSuppressesRemoteCheckTest
|
||||
|
@ -71,7 +68,7 @@ public class MavenITmng4326LocalSnapshotSuppressesRemoteCheckTest
|
|||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
final List<String> uris = new ArrayList<String>();
|
||||
final List<String> uris = new ArrayList<>();
|
||||
|
||||
Handler repoHandler = new AbstractHandler()
|
||||
{
|
||||
|
@ -82,8 +79,8 @@ public class MavenITmng4326LocalSnapshotSuppressesRemoteCheckTest
|
|||
|
||||
String uri = request.getRequestURI();
|
||||
|
||||
if ( uri.startsWith( "/repo/org/apache/maven/its/mng4326" )
|
||||
&& !uri.endsWith( ".md5" ) && !uri.endsWith( ".sha1" ) )
|
||||
if ( uri.startsWith( "/repo/org/apache/maven/its/mng4326" ) && !uri.endsWith( ".md5" ) && !uri.endsWith(
|
||||
".sha1" ) )
|
||||
{
|
||||
uris.add( uri.substring( 34 ) );
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -27,7 +26,7 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4353">MNG-4353</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4353PluginDependencyResolutionFromPomRepoTest
|
||||
|
@ -53,15 +52,17 @@ public class MavenITmng4353PluginDependencyResolutionFromPomRepoTest
|
|||
verifier.deleteArtifacts( "org.apache.maven.its.mng4353" );
|
||||
Properties filterProps = verifier.newDefaultFilterProperties();
|
||||
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
|
||||
verifier.filterFile( "repo-1/org/apache/maven/its/mng4353/maven-mng4353-plugin/0.1/template.pom",
|
||||
"repo-1/org/apache/maven/its/mng4353/maven-mng4353-plugin/0.1/maven-mng4353-plugin-0.1.pom", "UTF-8", filterProps );
|
||||
verifier.filterFile( "repo-1/org/apache/maven/its/mng4353/maven-mng4353-plugin/0.1/template.pom",
|
||||
"repo-1/org/apache/maven/its/mng4353/maven-mng4353-plugin/0.1/maven-mng4353-plugin-0.1"
|
||||
+ ".pom",
|
||||
"UTF-8", filterProps );
|
||||
verifier.addCliOption( "--settings" );
|
||||
verifier.addCliOption( "settings.xml" );
|
||||
verifier.executeGoal( "validate" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
Properties props = verifier.loadProperties( "target/touch.properties" );;
|
||||
Properties props = verifier.loadProperties( "target/touch.properties" );
|
||||
assertEquals( "passed", props.getProperty( "test" ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,14 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.apache.maven.shared.utils.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4368">MNG-4368</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4368TimestampAwareArtifactInstallerTest
|
||||
|
@ -63,11 +63,12 @@ public class MavenITmng4368TimestampAwareArtifactInstallerTest
|
|||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
File installedPom = new File( verifier.getArtifactPath( "org.apache.maven.its.mng4368", "test", "0.1-SNAPSHOT", "pom" ) );
|
||||
File installedPom =
|
||||
new File( verifier.getArtifactPath( "org.apache.maven.its.mng4368", "test", "0.1-SNAPSHOT", "pom" ) );
|
||||
|
||||
String pom = FileUtils.fileRead( installedPom, "UTF-8" );
|
||||
assertTrue( pom.indexOf( "Branch-A" ) > 0 );
|
||||
assertTrue( pom.indexOf( "Branch-B" ) < 0 );
|
||||
assertTrue( !pom.contains( "Branch-B" ) );
|
||||
|
||||
assertEquals( aPom.length(), bPom.length() );
|
||||
assertTrue( aPom.lastModified() > bPom.lastModified() );
|
||||
|
@ -81,7 +82,7 @@ public class MavenITmng4368TimestampAwareArtifactInstallerTest
|
|||
verifier.resetStreams();
|
||||
|
||||
pom = FileUtils.fileRead( installedPom, "UTF-8" );
|
||||
assertTrue( pom.indexOf( "Branch-A" ) < 0 );
|
||||
assertTrue( !pom.contains( "Branch-A" ) );
|
||||
assertTrue( pom.indexOf( "Branch-B" ) > 0 );
|
||||
}
|
||||
|
||||
|
@ -114,11 +115,12 @@ public class MavenITmng4368TimestampAwareArtifactInstallerTest
|
|||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
File installedArtifact = new File( verifier.getArtifactPath( "org.apache.maven.its.mng4368", "test", "0.1-SNAPSHOT", "jar" ) );
|
||||
File installedArtifact =
|
||||
new File( verifier.getArtifactPath( "org.apache.maven.its.mng4368", "test", "0.1-SNAPSHOT", "jar" ) );
|
||||
|
||||
String data = FileUtils.fileRead( installedArtifact, "UTF-8" );
|
||||
assertTrue( data.indexOf( "Branch-A" ) > 0 );
|
||||
assertTrue( data.indexOf( "Branch-B" ) < 0 );
|
||||
assertTrue( !data.contains( "Branch-B" ) );
|
||||
|
||||
assertEquals( aArtifact.length(), bArtifact.length() );
|
||||
assertTrue( aArtifact.lastModified() > bArtifact.lastModified() );
|
||||
|
@ -132,7 +134,7 @@ public class MavenITmng4368TimestampAwareArtifactInstallerTest
|
|||
verifier.resetStreams();
|
||||
|
||||
data = FileUtils.fileRead( installedArtifact, "UTF-8" );
|
||||
assertTrue( data.indexOf( "Branch-A" ) < 0 );
|
||||
assertTrue( !data.contains( "Branch-A" ) );
|
||||
assertTrue( data.indexOf( "Branch-B" ) > 0 );
|
||||
|
||||
long lastModified = installedArtifact.lastModified();
|
||||
|
@ -148,7 +150,7 @@ public class MavenITmng4368TimestampAwareArtifactInstallerTest
|
|||
verifier.resetStreams();
|
||||
|
||||
data = FileUtils.fileRead( installedArtifact, "UTF-8" );
|
||||
assertTrue( data.indexOf( "Branch-B" ) < 0 );
|
||||
assertTrue( !data.contains( "Branch-B" ) );
|
||||
assertTrue( data.indexOf( "Branch-C" ) > 0 );
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -29,7 +28,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4403">MNG-4403</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4403LenientDependencyPomParsingTest
|
||||
|
@ -65,7 +64,7 @@ public class MavenITmng4403LenientDependencyPomParsingTest
|
|||
List<String> artifacts = verifier.loadLines( "target/artifacts.txt", "UTF-8" );
|
||||
Collections.sort( artifacts );
|
||||
|
||||
List<String> expected = new ArrayList<String>();
|
||||
List<String> expected = new ArrayList<>();
|
||||
expected.add( "org.apache.maven.its.mng4403:a:jar:0.1" );
|
||||
expected.add( "org.apache.maven.its.mng4403:b:jar:0.1" );
|
||||
expected.add( "org.apache.maven.its.mng4403:c:jar:0.1" );
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -29,7 +28,7 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4415">MNG-4415</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4415InheritedPluginOrderTest
|
||||
|
@ -62,7 +61,7 @@ public class MavenITmng4415InheritedPluginOrderTest
|
|||
Properties props = verifier.loadProperties( "target/it.properties" );
|
||||
assertNotNull( props.getProperty( "project.build.plugins" ) );
|
||||
|
||||
List<String> expected = new ArrayList<String>();
|
||||
List<String> expected = new ArrayList<>();
|
||||
expected.add( "maven-it-plugin-error" );
|
||||
expected.add( "maven-it-plugin-configuration" );
|
||||
expected.add( "maven-it-plugin-dependency-resolution" );
|
||||
|
@ -72,7 +71,7 @@ public class MavenITmng4415InheritedPluginOrderTest
|
|||
expected.add( "maven-it-plugin-fork" );
|
||||
expected.add( "maven-it-plugin-touch" );
|
||||
|
||||
List<String> actual = new ArrayList<String>();
|
||||
List<String> actual = new ArrayList<>();
|
||||
|
||||
int count = Integer.parseInt( props.getProperty( "project.build.plugins" ) );
|
||||
for ( int i = 0; i < count; i++ )
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -29,7 +28,7 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4416">MNG-4416</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4416PluginOrderAfterProfileInjectionTest
|
||||
|
@ -62,7 +61,7 @@ public class MavenITmng4416PluginOrderAfterProfileInjectionTest
|
|||
Properties props = verifier.loadProperties( "target/it.properties" );
|
||||
assertNotNull( props.getProperty( "project.build.plugins" ) );
|
||||
|
||||
List<String> expected = new ArrayList<String>();
|
||||
List<String> expected = new ArrayList<>();
|
||||
expected.add( "maven-it-plugin-error" );
|
||||
expected.add( "maven-it-plugin-configuration" );
|
||||
expected.add( "maven-it-plugin-dependency-resolution" );
|
||||
|
@ -72,7 +71,7 @@ public class MavenITmng4416PluginOrderAfterProfileInjectionTest
|
|||
expected.add( "maven-it-plugin-fork" );
|
||||
expected.add( "maven-it-plugin-touch" );
|
||||
|
||||
List<String> actual = new ArrayList<String>();
|
||||
List<String> actual = new ArrayList<>();
|
||||
|
||||
int count = Integer.parseInt( props.getProperty( "project.build.plugins" ) );
|
||||
for ( int i = 0; i < count; i++ )
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -28,7 +27,7 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4421">MNG-4421</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4421DeprecatedPomInterpolationExpressionsTest
|
||||
|
@ -60,19 +59,19 @@ public class MavenITmng4421DeprecatedPomInterpolationExpressionsTest
|
|||
assertEquals( "0.1", props.getProperty( "project.properties.property2" ) );
|
||||
|
||||
List<String> lines = verifier.loadLines( "log.txt", null );
|
||||
|
||||
|
||||
boolean warnedPomPrefix = false;
|
||||
boolean warnedEmptyPrefix = false;
|
||||
|
||||
|
||||
for ( String line : lines )
|
||||
{
|
||||
if ( line.startsWith( "[WARN" ) )
|
||||
{
|
||||
if ( line.indexOf( "${pom.version}" ) >= 0 )
|
||||
if ( line.contains( "${pom.version}" ) )
|
||||
{
|
||||
warnedPomPrefix = true;
|
||||
}
|
||||
if ( line.indexOf( "${version}" ) >= 0 )
|
||||
if ( line.contains( "${version}" ) )
|
||||
{
|
||||
warnedEmptyPrefix = true;
|
||||
}
|
||||
|
|
|
@ -19,17 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.apache.maven.it.utils.DeployedResource;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
@ -44,9 +33,18 @@ import org.mortbay.jetty.security.ConstraintMapping;
|
|||
import org.mortbay.jetty.security.HashUserRealm;
|
||||
import org.mortbay.jetty.security.SecurityHandler;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4470">MNG-4470</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -60,7 +58,7 @@ public class MavenITmng4470AuthenticatedDeploymentToProxyTest
|
|||
|
||||
private volatile boolean deployed;
|
||||
|
||||
List<DeployedResource> deployedResources = new ArrayList<DeployedResource>();
|
||||
List<DeployedResource> deployedResources = new ArrayList<>();
|
||||
|
||||
public MavenITmng4470AuthenticatedDeploymentToProxyTest()
|
||||
{
|
||||
|
@ -138,7 +136,7 @@ public class MavenITmng4470AuthenticatedDeploymentToProxyTest
|
|||
|
||||
Constraint constraint = new Constraint();
|
||||
constraint.setName( Constraint.__BASIC_AUTH );
|
||||
constraint.setRoles( new String[] { "deployer" } );
|
||||
constraint.setRoles( new String[]{ "deployer" } );
|
||||
constraint.setAuthenticate( true );
|
||||
|
||||
ConstraintMapping constraintMapping = new ConstraintMapping();
|
||||
|
@ -151,7 +149,7 @@ public class MavenITmng4470AuthenticatedDeploymentToProxyTest
|
|||
|
||||
SecurityHandler securityHandler = new SecurityHandler();
|
||||
securityHandler.setUserRealm( userRealm );
|
||||
securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
|
||||
securityHandler.setConstraintMappings( new ConstraintMapping[]{ constraintMapping } );
|
||||
|
||||
HandlerList handlerList = new HandlerList();
|
||||
handlerList.addHandler( proxyHandler );
|
||||
|
@ -201,14 +199,14 @@ public class MavenITmng4470AuthenticatedDeploymentToProxyTest
|
|||
throws Exception
|
||||
{
|
||||
|
||||
deployedResources = new ArrayList<DeployedResource>();
|
||||
deployedResources = new ArrayList<>();
|
||||
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4470/" + project );
|
||||
|
||||
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8",
|
||||
Collections.singletonMap( "@port@", Integer.toString( port ) ) );
|
||||
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8",
|
||||
Collections.singletonMap( "@port@", Integer.toString( port ) ) );
|
||||
verifier.addCliOption( "--settings" );
|
||||
verifier.addCliOption( "settings.xml" );
|
||||
verifier.executeGoal( "validate" );
|
||||
|
|
|
@ -19,26 +19,23 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.mortbay.jetty.Handler;
|
||||
import org.mortbay.jetty.Request;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.handler.AbstractHandler;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.mortbay.jetty.Handler;
|
||||
import org.mortbay.jetty.Request;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.handler.AbstractHandler;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4555">MNG-4555</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4555MetaversionResolutionOfflineTest
|
||||
|
@ -58,7 +55,7 @@ public class MavenITmng4555MetaversionResolutionOfflineTest
|
|||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4555" );
|
||||
|
||||
final List<String> uris = new ArrayList<String>();
|
||||
final List<String> uris = new ArrayList<>();
|
||||
|
||||
Handler repoHandler = new AbstractHandler()
|
||||
{
|
||||
|
|
|
@ -19,18 +19,16 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4666">MNG-4666</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4666CoreRealmImportTest
|
||||
|
@ -97,10 +95,10 @@ public class MavenITmng4666CoreRealmImportTest
|
|||
|
||||
private List<String> getTypes( Properties props )
|
||||
{
|
||||
List<String> types = new ArrayList<String>();
|
||||
for ( Iterator<?> it = props.keySet().iterator(); it.hasNext(); )
|
||||
List<String> types = new ArrayList<>();
|
||||
for ( Object o : props.keySet() )
|
||||
{
|
||||
String key = it.next().toString();
|
||||
String key = o.toString();
|
||||
if ( key.startsWith( "core." ) )
|
||||
{
|
||||
String type = key.substring( 5 );
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -28,7 +27,7 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4696">MNG-4696</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4696MavenProjectDependencyArtifactsTest
|
||||
|
@ -63,7 +62,7 @@ public class MavenITmng4696MavenProjectDependencyArtifactsTest
|
|||
Properties props = verifier.loadProperties( "target/artifact.properties" );
|
||||
assertEquals( "3", props.getProperty( "project.dependencyArtifacts.size" ) );
|
||||
|
||||
HashSet<String> ids = new HashSet<String>();
|
||||
HashSet<String> ids = new HashSet<>();
|
||||
ids.add( props.getProperty( "project.dependencyArtifacts.0.artifactId" ) );
|
||||
ids.add( props.getProperty( "project.dependencyArtifacts.1.artifactId" ) );
|
||||
ids.add( props.getProperty( "project.dependencyArtifacts.2.artifactId" ) );
|
||||
|
|
|
@ -19,15 +19,15 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.apache.maven.shared.utils.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4745">MNG-4745</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4745PluginVersionUpdateTest
|
||||
|
@ -142,7 +142,7 @@ public class MavenITmng4745PluginVersionUpdateTest
|
|||
private static void writeMetadata( File testdir, String version, String timestamp )
|
||||
throws Exception
|
||||
{
|
||||
StringBuffer content = new StringBuffer( 1024 );
|
||||
StringBuilder content = new StringBuilder( 1024 );
|
||||
content.append( "<?xml version=\"1.0\"?>\n" );
|
||||
content.append( "<metadata>\n" );
|
||||
content.append( " <groupId>org.apache.maven.its.mng4745</groupId>\n" );
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -28,7 +27,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4814">MNG-4814</a>.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4814ReResolutionOfDependenciesDuringReactorTest
|
||||
|
@ -57,7 +56,7 @@ public class MavenITmng4814ReResolutionOfDependenciesDuringReactorTest
|
|||
verifier.addCliOption( "-s" );
|
||||
verifier.addCliOption( "settings.xml" );
|
||||
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
|
||||
List<String> goals = new ArrayList<String>();
|
||||
List<String> goals = new ArrayList<>();
|
||||
goals.add( "org.apache.maven.its.plugins:maven-it-plugin-dependency-resolution:2.1-SNAPSHOT:aggregate-test" );
|
||||
goals.add( "validate" );
|
||||
verifier.executeGoals( goals );
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package org.apache.maven.it;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
|
@ -26,22 +25,23 @@ import org.apache.maven.it.util.ResourceExtractor;
|
|||
*/
|
||||
|
||||
|
||||
public class MavenITmng5214DontMapWsdlToJar extends AbstractMavenIntegrationTestCase
|
||||
public class MavenITmng5214DontMapWsdlToJar
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
public MavenITmng5214DontMapWsdlToJar()
|
||||
{
|
||||
super( "[3.1,)" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that the code that allows test-jar and ejb-client dependencies to resolve to the
|
||||
* Test that the code that allows test-jar and ejb-client dependencies to resolve to the
|
||||
* target/classes or target/test-class is *not* applies to other types, e.g. wsdl.
|
||||
*/
|
||||
public void testitTestPhase()
|
||||
throws Exception
|
||||
{
|
||||
File setupDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5214/dependency" );
|
||||
|
||||
|
||||
Verifier setupVerifier = newVerifier( setupDir.getAbsolutePath() );
|
||||
setupVerifier.setAutoclean( false );
|
||||
setupVerifier.setMavenDebug( true );
|
||||
|
@ -52,7 +52,7 @@ public class MavenITmng5214DontMapWsdlToJar extends AbstractMavenIntegrationTest
|
|||
setupVerifier.executeGoal( "generate-resources" );
|
||||
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5214" );
|
||||
|
||||
|
||||
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.deleteDirectory( "consumer/target" );
|
||||
|
@ -61,12 +61,11 @@ public class MavenITmng5214DontMapWsdlToJar extends AbstractMavenIntegrationTest
|
|||
verifier.executeGoal( "test" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
List<String> lines = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
|
||||
Iterator<String> lineIt = lines.iterator();
|
||||
// RESOLVE-ONE-DEPENDENCY org.apache.maven.its.mng5214:dependency:wsdl:1.0-SNAPSHOT $ /tmp/it.repo/org/apache/maven/its/mng5214/dependency/1.0-SNAPSHOT/dependency-1.0-SNAPSHOT.wsdl
|
||||
while ( lineIt.hasNext() )
|
||||
// RESOLVE-ONE-DEPENDENCY org.apache.maven.its.mng5214:dependency:wsdl:1.0-SNAPSHOT $ /tmp/it
|
||||
// .repo/org/apache/maven/its/mng5214/dependency/1.0-SNAPSHOT/dependency-1.0-SNAPSHOT.wsdl
|
||||
for ( String line : lines )
|
||||
{
|
||||
String line = (String) lineIt.next();
|
||||
if ( line.contains( "RESOLVE-ONE-DEPENDENCY org.apache.maven.its.mng5214:dependency:wsdl:1.0-SNAPSHOT" ) )
|
||||
if ( line.contains( "RESOLVE-ONE-DEPENDENCY org.apache.maven.its.mng5214:dependency:wsdl:1.0-SNAPSHOT" ) )
|
||||
{
|
||||
assertFalse( line.contains( "classes-main" ) );
|
||||
assertTrue( line.endsWith( ".wsdl" ) );
|
||||
|
|
|
@ -99,7 +99,7 @@ public class MavenITmng5224InjectedSettings
|
|||
</profiles>
|
||||
**/
|
||||
|
||||
List<String> profileIds = new ArrayList<String>( 4 );
|
||||
List<String> profileIds = new ArrayList<>( 4 );
|
||||
|
||||
for ( Xpp3Dom node : profileNodes )
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ public class MavenITmng5224InjectedSettings
|
|||
assertEquals( 1, activeProfilesNode.getChildCount() );
|
||||
}
|
||||
|
||||
List<String> activeProfiles = new ArrayList<String>( 2 );
|
||||
List<String> activeProfiles = new ArrayList<>( 2 );
|
||||
|
||||
for ( Xpp3Dom node : activeProfilesNode.getChildren() )
|
||||
{
|
||||
|
|
|
@ -19,12 +19,11 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-5452">MNG-5452</a>
|
||||
* Make sure that the maven.build.timestamp is in UTC.
|
||||
|
|
|
@ -19,13 +19,12 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-5608">MNG-5608</a>:
|
||||
* Profile activation warning test when file specification contains <code>${project.basedir}</code>
|
||||
|
@ -63,12 +62,13 @@ public class MavenITmng5608ProfileActivationWarningTest
|
|||
private void assertFileExists( File dir, String filename )
|
||||
{
|
||||
File file = new File( dir, filename );
|
||||
assertTrue( "expected file: " + file , file.exists() );
|
||||
assertTrue( "expected file: " + file, file.exists() );
|
||||
}
|
||||
|
||||
private String findWarning( List<String> logLines, String profileId )
|
||||
{
|
||||
Pattern pattern = Pattern.compile( "(?i).*Failed to interpolate file location ..project.basedir./pom.xml for profile " + profileId + ": .*" );
|
||||
Pattern pattern = Pattern.compile(
|
||||
"(?i).*Failed to interpolate file location ..project.basedir./pom.xml for profile " + profileId + ": .*" );
|
||||
|
||||
for ( String logLine : logLines )
|
||||
{
|
||||
|
|
|
@ -22,9 +22,6 @@ package org.apache.maven.it;
|
|||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-5639">MNG-5639</a>:
|
||||
|
@ -60,5 +57,4 @@ public class MavenITmng5639ImportScopePomResolutionTest
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
/**
|
||||
* A simple HTTP proxy that only understands the CONNECT method to check HTTPS tunneling.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class TunnelingProxyServer
|
||||
|
@ -166,7 +166,7 @@ public class TunnelingProxyServer
|
|||
private String readLine( PushbackInputStream is )
|
||||
throws IOException
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer( 1024 );
|
||||
StringBuilder buffer = new StringBuilder( 1024 );
|
||||
|
||||
while ( true )
|
||||
{
|
||||
|
@ -217,7 +217,7 @@ public class TunnelingProxyServer
|
|||
{
|
||||
try
|
||||
{
|
||||
for ( byte[] buffer = new byte[1024 * 8];; )
|
||||
for ( byte[] buffer = new byte[1024 * 8]; ; )
|
||||
{
|
||||
int n = is.read( buffer );
|
||||
if ( n < 0 )
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.io.IOException;
|
|||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DefaultStatefulSingleton
|
||||
implements StatefulSingleton
|
||||
|
@ -48,15 +48,10 @@ public class DefaultStatefulSingleton
|
|||
{
|
||||
propertiesFile.getParentFile().mkdirs();
|
||||
|
||||
FileOutputStream os = new FileOutputStream( propertiesFile );
|
||||
try
|
||||
try ( FileOutputStream os = new FileOutputStream( propertiesFile ) )
|
||||
{
|
||||
properties.store( os, "MAVEN-CORE-IT" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
@ -34,11 +33,10 @@ import java.util.Vector;
|
|||
|
||||
/**
|
||||
* Checks the thread-safe retrieval of components from active component collections.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @goal check-thread-safety
|
||||
* @phase validate
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class CheckThreadSafetyMojo
|
||||
extends AbstractMojo
|
||||
|
@ -46,7 +44,7 @@ public class CheckThreadSafetyMojo
|
|||
|
||||
/**
|
||||
* Project base directory used for manual path alignment.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${basedir}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -54,28 +52,28 @@ public class CheckThreadSafetyMojo
|
|||
|
||||
/**
|
||||
* The available components, as a map.
|
||||
*
|
||||
*
|
||||
* @component role="org.apache.maven.plugin.coreit.Component"
|
||||
*/
|
||||
private Map componentMap;
|
||||
|
||||
/**
|
||||
* The available components, as a list.
|
||||
*
|
||||
*
|
||||
* @component role="org.apache.maven.plugin.coreit.Component"
|
||||
*/
|
||||
private List componentList;
|
||||
|
||||
/**
|
||||
* The path to the properties file to create.
|
||||
*
|
||||
*
|
||||
* @parameter property="collections.outputFile"
|
||||
*/
|
||||
private File outputFile;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoFailureException If the output file could not be created.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -114,13 +112,13 @@ public class CheckThreadSafetyMojo
|
|||
{
|
||||
try
|
||||
{
|
||||
for ( Iterator it = map.values().iterator(); it.hasNext(); )
|
||||
for ( Object o : map.values() )
|
||||
{
|
||||
it.next().toString();
|
||||
o.toString();
|
||||
}
|
||||
for ( Iterator it = list.iterator(); it.hasNext(); )
|
||||
for ( Object aList : list )
|
||||
{
|
||||
it.next().toString();
|
||||
aList.toString();
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
|
@ -135,15 +133,15 @@ public class CheckThreadSafetyMojo
|
|||
}
|
||||
|
||||
go.add( null );
|
||||
for ( int i = 0; i < threads.length; i++ )
|
||||
for ( Thread thread : threads )
|
||||
{
|
||||
try
|
||||
{
|
||||
threads[i].join();
|
||||
thread.join();
|
||||
}
|
||||
catch ( InterruptedException e )
|
||||
{
|
||||
getLog().warn( "[MAVEN-CORE-IT-LOG] Interrupted while joining " + threads[i] );
|
||||
getLog().warn( "[MAVEN-CORE-IT-LOG] Interrupted while joining " + thread );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,18 +27,16 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Dumps the role hints of the available repository layouts to a properties file.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @goal dump-repo-layouts
|
||||
* @phase validate
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class DumpRepoLayoutsMojo
|
||||
extends AbstractMojo
|
||||
|
@ -46,7 +44,7 @@ public class DumpRepoLayoutsMojo
|
|||
|
||||
/**
|
||||
* Project base directory used for manual path alignment.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${basedir}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -54,28 +52,28 @@ public class DumpRepoLayoutsMojo
|
|||
|
||||
/**
|
||||
* The available repository layouts, as a map.
|
||||
*
|
||||
*
|
||||
* @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
|
||||
*/
|
||||
private Map repositoryLayouts;
|
||||
|
||||
/**
|
||||
* The available repository layouts, as a list.
|
||||
*
|
||||
*
|
||||
* @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
|
||||
*/
|
||||
private List repoLayouts;
|
||||
|
||||
/**
|
||||
* The path to the properties file used to dump the repository layouts.
|
||||
*
|
||||
*
|
||||
* @parameter property="collections.layoutsFile"
|
||||
*/
|
||||
private File layoutsFile;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoFailureException If the output file could not be created.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -87,9 +85,9 @@ public class DumpRepoLayoutsMojo
|
|||
|
||||
layoutProperties.setProperty( "layouts", Integer.toString( repositoryLayouts.size() ) );
|
||||
|
||||
for ( Iterator it = repositoryLayouts.keySet().iterator(); it.hasNext(); )
|
||||
for ( Object o : repositoryLayouts.keySet() )
|
||||
{
|
||||
String roleHint = (String) it.next();
|
||||
String roleHint = (String) o;
|
||||
Object repoLayout = repositoryLayouts.get( roleHint );
|
||||
if ( repoLayout != null )
|
||||
{
|
||||
|
|
|
@ -36,11 +36,10 @@ import java.util.Set;
|
|||
|
||||
/**
|
||||
* Collects user-specified artifacts. This mimics in part the Maven Assembly Plugin.
|
||||
*
|
||||
* @goal collect
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal collect
|
||||
*/
|
||||
public class CollectMojo
|
||||
extends AbstractMojo
|
||||
|
@ -48,7 +47,7 @@ public class CollectMojo
|
|||
|
||||
/**
|
||||
* The local repository.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${localRepository}"
|
||||
* @readonly
|
||||
* @required
|
||||
|
@ -57,7 +56,7 @@ public class CollectMojo
|
|||
|
||||
/**
|
||||
* The remote repositories of the current Maven project.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project.remoteArtifactRepositories}"
|
||||
* @readonly
|
||||
* @required
|
||||
|
@ -66,35 +65,35 @@ public class CollectMojo
|
|||
|
||||
/**
|
||||
* The artifact collector.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactCollector collector;
|
||||
|
||||
/**
|
||||
* The artifact factory.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactFactory factory;
|
||||
|
||||
/**
|
||||
* The metadata source.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactMetadataSource metadataSource;
|
||||
|
||||
/**
|
||||
* The dependencies to resolve.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private Dependency[] dependencies;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoFailureException If the artifact file has not been set.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -110,10 +109,8 @@ public class CollectMojo
|
|||
|
||||
if ( dependencies != null )
|
||||
{
|
||||
for ( int i = 0; i < dependencies.length; i++ )
|
||||
for ( Dependency dependency : dependencies )
|
||||
{
|
||||
Dependency dependency = dependencies[i];
|
||||
|
||||
Artifact artifact =
|
||||
factory.createArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(),
|
||||
dependency.getVersion(), dependency.getType(),
|
||||
|
|
|
@ -36,7 +36,7 @@ public class CustomRepositoryLayout
|
|||
{
|
||||
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
|
||||
|
||||
StringBuffer path = new StringBuffer();
|
||||
StringBuilder path = new StringBuilder();
|
||||
|
||||
path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
|
||||
|
||||
|
|
|
@ -24,16 +24,13 @@ import org.apache.maven.artifact.deployer.ArtifactDeployer;
|
|||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Deploys the project artifacts to the distribution repository. This is the essence of the Maven Deploy Plugin.
|
||||
*
|
||||
* @goal deploy
|
||||
* @phase deploy
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal deploy
|
||||
* @phase deploy
|
||||
*/
|
||||
public class DeployMojo
|
||||
extends AbstractRepoMojo
|
||||
|
@ -41,7 +38,7 @@ public class DeployMojo
|
|||
|
||||
/**
|
||||
* The distribution repository.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project.distributionManagementArtifactRepository}"
|
||||
* @readonly
|
||||
* @required
|
||||
|
@ -50,14 +47,14 @@ public class DeployMojo
|
|||
|
||||
/**
|
||||
* The artifact deployer.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactDeployer deployer;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If any artifact could not be installed.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -78,9 +75,9 @@ public class DeployMojo
|
|||
|
||||
if ( attachedArtifacts != null )
|
||||
{
|
||||
for ( Iterator it = attachedArtifacts.iterator(); it.hasNext(); )
|
||||
for ( Object attachedArtifact1 : attachedArtifacts )
|
||||
{
|
||||
Artifact attachedArtifact = (Artifact) it.next();
|
||||
Artifact attachedArtifact = (Artifact) attachedArtifact1;
|
||||
deployer.deploy( attachedArtifact.getFile(), attachedArtifact, deploymentRepository,
|
||||
localRepository );
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.apache.maven.plugin.MojoExecutionException;
|
|||
import org.apache.maven.plugin.MojoFailureException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -87,9 +86,9 @@ public class InstallArtifactsMojo
|
|||
ArtifactRepository artifactRepository =
|
||||
artifactRepositoryFactory.createDeploymentArtifactRepository( "appassembler", "file://"
|
||||
+ assembleDirectory.getAbsolutePath() + "/" + repositoryName, artifactRepositoryLayout, false );
|
||||
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
|
||||
for ( Object artifact1 : artifacts )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
Artifact artifact = (Artifact) artifact1;
|
||||
|
||||
installArtifact( artifactRepository, artifact );
|
||||
}
|
||||
|
@ -115,7 +114,7 @@ public class InstallArtifactsMojo
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static class FlatRepositoryLayout
|
||||
implements ArtifactRepositoryLayout
|
||||
|
@ -128,7 +127,7 @@ public class InstallArtifactsMojo
|
|||
{
|
||||
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
|
||||
|
||||
StringBuffer path = new StringBuffer();
|
||||
StringBuilder path = new StringBuilder();
|
||||
|
||||
path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() );
|
||||
|
||||
|
@ -152,7 +151,7 @@ public class InstallArtifactsMojo
|
|||
|
||||
private String pathOfRepositoryMetadata( String filename )
|
||||
{
|
||||
StringBuffer path = new StringBuffer();
|
||||
StringBuilder path = new StringBuilder();
|
||||
|
||||
path.append( filename );
|
||||
|
||||
|
|
|
@ -23,16 +23,13 @@ import org.apache.maven.artifact.Artifact;
|
|||
import org.apache.maven.artifact.installer.ArtifactInstaller;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Installs the project artifacts into the local repository. This is the essence of the Maven Install Plugin.
|
||||
*
|
||||
* @goal install
|
||||
* @phase install
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal install
|
||||
* @phase install
|
||||
*/
|
||||
public class InstallMojo
|
||||
extends AbstractRepoMojo
|
||||
|
@ -40,14 +37,14 @@ public class InstallMojo
|
|||
|
||||
/**
|
||||
* The artifact installer.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactInstaller installer;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If any artifact could not be installed.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -68,9 +65,9 @@ public class InstallMojo
|
|||
|
||||
if ( attachedArtifacts != null )
|
||||
{
|
||||
for ( Iterator it = attachedArtifacts.iterator(); it.hasNext(); )
|
||||
for ( Object attachedArtifact1 : attachedArtifacts )
|
||||
{
|
||||
Artifact attachedArtifact = (Artifact) it.next();
|
||||
Artifact attachedArtifact = (Artifact) attachedArtifact1;
|
||||
installer.install( attachedArtifact.getFile(), attachedArtifact, localRepository );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,11 +35,10 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* Resolves user-specified artifacts. This mimics in part the Maven Dependency Plugin and the Maven Surefire Plugin.
|
||||
*
|
||||
* @goal resolve
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal resolve
|
||||
*/
|
||||
public class ResolveMojo
|
||||
extends AbstractMojo
|
||||
|
@ -47,7 +46,7 @@ public class ResolveMojo
|
|||
|
||||
/**
|
||||
* The local repository.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${localRepository}"
|
||||
* @readonly
|
||||
* @required
|
||||
|
@ -56,7 +55,7 @@ public class ResolveMojo
|
|||
|
||||
/**
|
||||
* The remote repositories of the current Maven project.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project.remoteArtifactRepositories}"
|
||||
* @readonly
|
||||
* @required
|
||||
|
@ -65,35 +64,35 @@ public class ResolveMojo
|
|||
|
||||
/**
|
||||
* The artifact resolver.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactResolver resolver;
|
||||
|
||||
/**
|
||||
* The artifact factory.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactFactory factory;
|
||||
|
||||
/**
|
||||
* The dependencies to resolve.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private Dependency[] dependencies;
|
||||
|
||||
/**
|
||||
* The path to a properties file to store the resolved artifact paths in.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private File propertiesFile;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoFailureException If the artifact could not be resolved
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -107,10 +106,8 @@ public class ResolveMojo
|
|||
{
|
||||
if ( dependencies != null )
|
||||
{
|
||||
for ( int i = 0; i < dependencies.length; i++ )
|
||||
for ( Dependency dependency : dependencies )
|
||||
{
|
||||
Dependency dependency = dependencies[i];
|
||||
|
||||
Artifact artifact =
|
||||
factory.createArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(),
|
||||
dependency.getVersion(), dependency.getType(),
|
||||
|
@ -142,15 +139,10 @@ public class ResolveMojo
|
|||
{
|
||||
propertiesFile.getParentFile().mkdirs();
|
||||
|
||||
FileOutputStream fos = new FileOutputStream( propertiesFile );
|
||||
try
|
||||
try ( FileOutputStream fos = new FileOutputStream( propertiesFile ) )
|
||||
{
|
||||
props.store( fos, "MAVEN-CORE-IT" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.apache.maven.plugin.MojoExecutionException;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
@ -40,10 +39,9 @@ import java.util.Set;
|
|||
/**
|
||||
* Resolves user-specified artifacts transitively. As an additional exercise, the resolution happens in a forked thread
|
||||
* to test access to any shared session state.
|
||||
*
|
||||
* @goal resolve-transitive
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @goal resolve-transitive
|
||||
*/
|
||||
public class ResolveTransitiveMojo
|
||||
extends AbstractMojo
|
||||
|
@ -51,7 +49,7 @@ public class ResolveTransitiveMojo
|
|||
|
||||
/**
|
||||
* The local repository.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${localRepository}"
|
||||
* @readonly
|
||||
* @required
|
||||
|
@ -60,7 +58,7 @@ public class ResolveTransitiveMojo
|
|||
|
||||
/**
|
||||
* The remote repositories of the current Maven project.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project.remoteArtifactRepositories}"
|
||||
* @readonly
|
||||
* @required
|
||||
|
@ -69,42 +67,42 @@ public class ResolveTransitiveMojo
|
|||
|
||||
/**
|
||||
* The artifact resolver.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactResolver resolver;
|
||||
|
||||
/**
|
||||
* The artifact factory.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactFactory factory;
|
||||
|
||||
/**
|
||||
* The metadata source.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactMetadataSource metadataSource;
|
||||
|
||||
/**
|
||||
* The dependencies to resolve.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private Dependency[] dependencies;
|
||||
|
||||
/**
|
||||
* The path to a properties file to store the resolved artifact paths in.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private File propertiesFile;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the artifacts couldn't be resolved.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -140,15 +138,10 @@ public class ResolveTransitiveMojo
|
|||
{
|
||||
propertiesFile.getParentFile().mkdirs();
|
||||
|
||||
FileOutputStream fos = new FileOutputStream( propertiesFile );
|
||||
try
|
||||
try ( FileOutputStream fos = new FileOutputStream( propertiesFile ) )
|
||||
{
|
||||
thread.props.store( fos, "MAVEN-CORE-IT" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
@ -179,30 +172,27 @@ public class ResolveTransitiveMojo
|
|||
{
|
||||
Set artifacts = new LinkedHashSet();
|
||||
|
||||
for ( int i = 0; i < dependencies.length; i++ )
|
||||
for ( Dependency dependency : dependencies )
|
||||
{
|
||||
Dependency dependency = dependencies[i];
|
||||
|
||||
Artifact artifact =
|
||||
factory.createArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(),
|
||||
dependency.getVersion(), dependency.getType(),
|
||||
dependency.getClassifier() );
|
||||
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Resolving "
|
||||
+ ResolveTransitiveMojo.this.getId( artifact ) );
|
||||
getLog().info(
|
||||
"[MAVEN-CORE-IT-LOG] Resolving " + ResolveTransitiveMojo.this.getId( artifact ) );
|
||||
|
||||
artifacts.add( artifact );
|
||||
}
|
||||
|
||||
Artifact origin = factory.createArtifact( "it", "it", "0.1", null, "pom" );
|
||||
|
||||
artifacts =
|
||||
resolver.resolveTransitively( artifacts, origin, remoteRepositories, localRepository,
|
||||
metadataSource ).getArtifacts();
|
||||
artifacts = resolver.resolveTransitively( artifacts, origin, remoteRepositories, localRepository,
|
||||
metadataSource ).getArtifacts();
|
||||
|
||||
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
|
||||
for ( Object artifact1 : artifacts )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
Artifact artifact = (Artifact) artifact1;
|
||||
|
||||
if ( artifact.getFile() != null )
|
||||
{
|
||||
|
|
|
@ -30,13 +30,12 @@ import java.net.URL;
|
|||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Loads classes and/or resources from a class loader and records the results in a properties file.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -50,7 +49,7 @@ public abstract class AbstractLoadMojo
|
|||
* key will be the hash code of the requested class. In addition, a key named <code>QCN.methods</code> holds the
|
||||
* comma separated list of all public methods declared directly in that class, in alphabetic order and possibly with
|
||||
* duplicates to account for overloaded methods.
|
||||
*
|
||||
*
|
||||
* @parameter property="clsldr.classNames"
|
||||
*/
|
||||
protected String classNames;
|
||||
|
@ -60,15 +59,15 @@ public abstract class AbstractLoadMojo
|
|||
* successfully loaded, the generated properties files will contain a key named <code>ARP</code> whose value gives
|
||||
* the URL to the resource. In addition, the keys <code>ARP.count</code>, <code>ARP.0</code>, <code>ARP.1</code>
|
||||
* etc. will enumerate all URLs matching the resource name.
|
||||
*
|
||||
*
|
||||
* @parameter property="clsldr.resourcePaths"
|
||||
*/
|
||||
protected String resourcePaths;
|
||||
|
||||
/**
|
||||
* Loads the classes/resources.
|
||||
*
|
||||
* @param outputFile The path to the properties file to generate, must not be <code>null</code>.
|
||||
*
|
||||
* @param outputFile The path to the properties file to generate, must not be <code>null</code>.
|
||||
* @param classLoader The class loader to use, must not be <code>null</code>.
|
||||
* @throws MojoExecutionException If the output file could not be created.
|
||||
*/
|
||||
|
@ -94,9 +93,8 @@ public abstract class AbstractLoadMojo
|
|||
if ( classNames != null && classNames.length() > 0 )
|
||||
{
|
||||
String[] names = classNames.split( "," );
|
||||
for ( int i = 0; i < names.length; i++ )
|
||||
for ( String name : names )
|
||||
{
|
||||
String name = names[i];
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Loading class " + name );
|
||||
|
||||
// test ClassLoader.loadClass(String) and (indirectly) ClassLoader.loadClass(String, boolean)
|
||||
|
@ -120,22 +118,22 @@ public abstract class AbstractLoadMojo
|
|||
|
||||
Method[] methods = type.getDeclaredMethods();
|
||||
List methodNames = new ArrayList();
|
||||
for ( int j = 0; j < methods.length; j++ )
|
||||
for ( Method method : methods )
|
||||
{
|
||||
if ( Modifier.isPublic( methods[j].getModifiers() ) )
|
||||
if ( Modifier.isPublic( method.getModifiers() ) )
|
||||
{
|
||||
methodNames.add( methods[j].getName() );
|
||||
methodNames.add( method.getName() );
|
||||
}
|
||||
}
|
||||
Collections.sort( methodNames );
|
||||
StringBuffer buffer = new StringBuffer( 1024 );
|
||||
for ( Iterator it = methodNames.iterator(); it.hasNext(); )
|
||||
StringBuilder buffer = new StringBuilder( 1024 );
|
||||
for ( Object methodName : methodNames )
|
||||
{
|
||||
if ( buffer.length() > 0 )
|
||||
{
|
||||
buffer.append( ',' );
|
||||
}
|
||||
buffer.append( it.next() );
|
||||
buffer.append( methodName );
|
||||
}
|
||||
|
||||
loaderProperties.setProperty( name + ".methods", buffer.toString() );
|
||||
|
@ -156,9 +154,8 @@ public abstract class AbstractLoadMojo
|
|||
if ( resourcePaths != null && resourcePaths.length() > 0 )
|
||||
{
|
||||
String[] paths = resourcePaths.split( "," );
|
||||
for ( int i = 0; i < paths.length; i++ )
|
||||
for ( String path : paths )
|
||||
{
|
||||
String path = paths[i];
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Loading resource " + path );
|
||||
|
||||
// test ClassLoader.getResource()
|
||||
|
|
|
@ -29,11 +29,10 @@ import java.util.Properties;
|
|||
/**
|
||||
* Checks whether API classes exported by the Maven core are assignment-compatible with types loaded from the plugin
|
||||
* class loader. In other words, checks that types shared with the core realm are imported into the plugin realm.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @goal assignment-compatible
|
||||
* @phase initialize
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class AssignmentCompatibleMojo
|
||||
extends AbstractMojo
|
||||
|
@ -41,21 +40,21 @@ public class AssignmentCompatibleMojo
|
|||
|
||||
/**
|
||||
* The path to the properties file used to track the results of the assignment compatibility tests.
|
||||
*
|
||||
*
|
||||
* @parameter property="clsldr.assigncompatPropertiesFile"
|
||||
*/
|
||||
private File assigncompatPropertiesFile;
|
||||
|
||||
/**
|
||||
* The qualified names of the types to check.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String[] classNames;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -73,9 +72,8 @@ public class AssignmentCompatibleMojo
|
|||
|
||||
if ( classNames != null )
|
||||
{
|
||||
for ( int i = 0; i < classNames.length; i++ )
|
||||
for ( String className : classNames )
|
||||
{
|
||||
String className = classNames[i];
|
||||
String result;
|
||||
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Loading class " + className );
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* Assists in evaluating expressions.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -52,10 +52,11 @@ class ExpressionUtil
|
|||
* root objects are available. For instance, if <code>contexts</code> maps the token "project" to a Maven project
|
||||
* instance, the expression "project/build/resources/0/directory" specifies the first resource directory of the
|
||||
* project.
|
||||
*
|
||||
*
|
||||
* @param expression The expression to evaluate, may be <code>null</code>.
|
||||
* @param contexts The possible root objects for the expression evaluation, indexed by their identifying token, must
|
||||
* not be <code>null</code>.
|
||||
* @param contexts The possible root objects for the expression evaluation, indexed by their identifying token,
|
||||
* must
|
||||
* not be <code>null</code>.
|
||||
* @return The value of the expression or <code>null</code> if the expression could not be evaluated.
|
||||
*/
|
||||
public static Object evaluate( String expression, Map contexts )
|
||||
|
@ -80,8 +81,8 @@ class ExpressionUtil
|
|||
|
||||
/**
|
||||
* Evaluates the given expression segments against the specified object.
|
||||
*
|
||||
* @param context The object to evaluate the segments against, may be <code>null</code>.
|
||||
*
|
||||
* @param context The object to evaluate the segments against, may be <code>null</code>.
|
||||
* @param segments The expression segments to evaluate, must not be <code>null</code>.
|
||||
* @return The value of the evaluation or <code>null</code> if the segments could not be evaluated.
|
||||
*/
|
||||
|
@ -137,8 +138,8 @@ class ExpressionUtil
|
|||
|
||||
/**
|
||||
* Gets the value of a (public) bean property from the specified object.
|
||||
*
|
||||
* @param context The object whose bean property should be retrieved, must not be <code>null</code>.
|
||||
*
|
||||
* @param context The object whose bean property should be retrieved, must not be <code>null</code>.
|
||||
* @param property The name of the bean property, must not be <code>null</code>.
|
||||
* @return The value of the bean property or <code>null</code> if the property does not exist.
|
||||
*/
|
||||
|
@ -192,7 +193,7 @@ class ExpressionUtil
|
|||
{
|
||||
method = type.getMethod( "get", OBJECT_PARAM );
|
||||
}
|
||||
value = method.invoke( context, new Object[] { property } );
|
||||
value = method.invoke( context, new Object[]{ property } );
|
||||
}
|
||||
catch ( NoSuchMethodException e3 )
|
||||
{
|
||||
|
@ -205,7 +206,7 @@ class ExpressionUtil
|
|||
{
|
||||
if ( "length".equals( property ) && type.isArray() )
|
||||
{
|
||||
value = new Integer( Array.getLength( context ) );
|
||||
value = Array.getLength( context );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.apache.maven.plugin.MojoFailureException;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
@ -33,12 +32,11 @@ import java.util.Properties;
|
|||
/**
|
||||
* Checks whether objects obtained from the Maven core are assignment-compatible with types loaded from the plugin class
|
||||
* loader. In other words, checks that types shared with the core realm are imported into the plugin realm.
|
||||
*
|
||||
* @goal instanceof
|
||||
* @phase initialize
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal instanceof
|
||||
* @phase initialize
|
||||
*/
|
||||
public class InstanceofMojo
|
||||
extends AbstractMojo
|
||||
|
@ -46,7 +44,7 @@ public class InstanceofMojo
|
|||
|
||||
/**
|
||||
* The path to the properties file used to track the results of the instanceof tests.
|
||||
*
|
||||
*
|
||||
* @parameter property="clsldr.instanceofPropertiesFile"
|
||||
*/
|
||||
private File instanceofPropertiesFile;
|
||||
|
@ -54,28 +52,28 @@ public class InstanceofMojo
|
|||
/**
|
||||
* The qualified name of the type to which the objects should be assignment-compatible. This type will be loaded
|
||||
* from the plugin class loader, just like as if it was imported in the plugin source code.
|
||||
*
|
||||
*
|
||||
* @parameter property="clsldr.className"
|
||||
*/
|
||||
private String className;
|
||||
|
||||
/**
|
||||
* A list of expressions that denote the object instances that should be type-checked.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String[] objectExpressions;
|
||||
|
||||
/**
|
||||
* A list of injected component instances that should be type-checked.
|
||||
*
|
||||
*
|
||||
* @component role="org.apache.maven.plugin.coreit.Component"
|
||||
*/
|
||||
private List components;
|
||||
|
||||
/**
|
||||
* The current Maven project against which expressions are evaluated.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -83,7 +81,7 @@ public class InstanceofMojo
|
|||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -109,9 +107,8 @@ public class InstanceofMojo
|
|||
contexts.put( "project", project );
|
||||
contexts.put( "pom", project );
|
||||
|
||||
for ( int i = 0; i < objectExpressions.length; i++ )
|
||||
for ( String expression : objectExpressions )
|
||||
{
|
||||
String expression = objectExpressions[i];
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Evaluating expression " + expression );
|
||||
Object object = ExpressionUtil.evaluate( expression, contexts );
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Checking object " + object );
|
||||
|
@ -127,9 +124,8 @@ public class InstanceofMojo
|
|||
|
||||
if ( components != null && !components.isEmpty() )
|
||||
{
|
||||
for ( Iterator it = components.iterator(); it.hasNext(); )
|
||||
for ( Object object : components )
|
||||
{
|
||||
Object object = it.next();
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Checking component " + object );
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Loaded class " + object.getClass().getName() );
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Loaded class from " + object.getClass().getClassLoader() );
|
||||
|
|
|
@ -19,13 +19,13 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
|
@ -36,8 +36,8 @@ public class ExpressionUtilTest
|
|||
|
||||
public void testEvaluate()
|
||||
{
|
||||
Object array = new String[] { "one", "two", "three" };
|
||||
Object list = Arrays.asList( new String[] { "0", "-1", "-2" } );
|
||||
Object array = new String[]{ "one", "two", "three" };
|
||||
Object list = Arrays.asList( new String[]{ "0", "-1", "-2" } );
|
||||
Object map = Collections.singletonMap( "some.key", "value" );
|
||||
Object bean = new BeanTwo();
|
||||
|
||||
|
@ -54,20 +54,20 @@ public class ExpressionUtilTest
|
|||
assertSame( bean, ExpressionUtil.evaluate( "bean", contexts ) );
|
||||
assertNull( ExpressionUtil.evaluate( "no-root", contexts ) );
|
||||
|
||||
assertEquals( new Integer( 3 ), ExpressionUtil.evaluate( "array/length", contexts ) );
|
||||
assertEquals( 3, ExpressionUtil.evaluate( "array/length", contexts ) );
|
||||
assertEquals( "three", ExpressionUtil.evaluate( "array/2", contexts ) );
|
||||
assertEquals( new Integer( 5 ), ExpressionUtil.evaluate( "array/2/length", contexts ) );
|
||||
assertEquals( 5, ExpressionUtil.evaluate( "array/2/length", contexts ) );
|
||||
assertNull( ExpressionUtil.evaluate( "array/invalid", contexts ) );
|
||||
assertNull( ExpressionUtil.evaluate( "array/-1", contexts ) );
|
||||
assertNull( ExpressionUtil.evaluate( "array/999", contexts ) );
|
||||
|
||||
assertEquals( new Integer( 3 ), ExpressionUtil.evaluate( "list/size", contexts ) );
|
||||
assertEquals( 3, ExpressionUtil.evaluate( "list/size", contexts ) );
|
||||
assertEquals( "-2", ExpressionUtil.evaluate( "list/2", contexts ) );
|
||||
assertNull( ExpressionUtil.evaluate( "list/invalid", contexts ) );
|
||||
assertNull( ExpressionUtil.evaluate( "list/-1", contexts ) );
|
||||
assertNull( ExpressionUtil.evaluate( "list/999", contexts ) );
|
||||
|
||||
assertEquals( new Integer( 1 ), ExpressionUtil.evaluate( "map/size", contexts ) );
|
||||
assertEquals( 1, ExpressionUtil.evaluate( "map/size", contexts ) );
|
||||
assertEquals( "value", ExpressionUtil.evaluate( "map/some.key", contexts ) );
|
||||
assertNull( ExpressionUtil.evaluate( "map/invalid", contexts ) );
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class ExpressionUtilTest
|
|||
assertEquals( bean2.field, ExpressionUtil.getProperty( bean2, "field" ) );
|
||||
assertSame( bean2.bean, ExpressionUtil.getProperty( bean2, "bean" ) );
|
||||
|
||||
assertEquals( new Integer( 0 ), ExpressionUtil.getProperty( new String[0], "length" ) );
|
||||
assertEquals( 0, ExpressionUtil.getProperty( new String[0], "length" ) );
|
||||
}
|
||||
|
||||
public static class BeanOne
|
||||
|
|
|
@ -19,6 +19,10 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
@ -28,18 +32,13 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||
|
||||
/**
|
||||
* Dumps this mojo's configuration into a properties file.
|
||||
*
|
||||
* @goal config
|
||||
* @phase validate
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal config
|
||||
* @phase validate
|
||||
*/
|
||||
public class ConfigMojo
|
||||
extends AbstractMojo
|
||||
|
@ -47,7 +46,7 @@ public class ConfigMojo
|
|||
|
||||
/**
|
||||
* The current project's base directory, used for path alignment.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${basedir}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -55,210 +54,210 @@ public class ConfigMojo
|
|||
|
||||
/**
|
||||
* The path to the properties file into which to save the mojo configuration.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.propertiesFile"
|
||||
*/
|
||||
private File propertiesFile;
|
||||
|
||||
/**
|
||||
* A parameter with an alias.
|
||||
*
|
||||
*
|
||||
* @parameter alias="aliasParamLegacy"
|
||||
*/
|
||||
private String aliasParam;
|
||||
|
||||
/**
|
||||
* A parameter with a constant default value.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="maven-core-it"
|
||||
*/
|
||||
private String defaultParam;
|
||||
|
||||
/**
|
||||
* A parameter with a default value using multiple expressions.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project.groupId}:${project.artifactId}:${project.version}"
|
||||
*/
|
||||
private String defaultParamWithExpression;
|
||||
|
||||
/**
|
||||
* A parameter that combines all of the annotations.
|
||||
*
|
||||
*
|
||||
* @parameter alias="fullyAnnotatedParam" property="config.aliasDefaultExpressionParam" default-value="test"
|
||||
*/
|
||||
private String aliasDefaultExpressionParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.lang.Boolean}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.booleanParam"
|
||||
*/
|
||||
private Boolean booleanParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.lang.Boolean#TYPE}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.primitiveBooleanParam"
|
||||
*/
|
||||
private boolean primitiveBooleanParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.lang.Byte}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.byteParam"
|
||||
*/
|
||||
private Byte byteParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.lang.Short}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.shortParam"
|
||||
*/
|
||||
private Short shortParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.lang.Integer}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.intergerParam"
|
||||
*/
|
||||
private Integer integerParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.lang.Integer#TYPE}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.primitiveIntegerParam"
|
||||
*/
|
||||
private int primitiveIntegerParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.lang.Long}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.longParam"
|
||||
*/
|
||||
private Long longParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.lang.Float}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.floatParam"
|
||||
*/
|
||||
private Float floatParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.lang.Double}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.doubleParam"
|
||||
*/
|
||||
private Double doubleParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.lang.Character}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.characterParam"
|
||||
*/
|
||||
private Character characterParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.lang.String}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.stringParam"
|
||||
*/
|
||||
private String stringParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.io.File}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.fileParam"
|
||||
*/
|
||||
private File fileParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.util.Date}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.dateParam"
|
||||
*/
|
||||
private Date dateParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.net.URL}.
|
||||
*
|
||||
*
|
||||
* @parameter property="config.urlParam"
|
||||
*/
|
||||
private URL urlParam;
|
||||
|
||||
/**
|
||||
* A simple parameter of type {@link java.net.URI} (requires Maven 3.x).
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private URI uriParam;
|
||||
|
||||
/**
|
||||
* An array parameter of component type {@link java.lang.String}.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String[] stringParams;
|
||||
|
||||
/**
|
||||
* An array parameter of component type {@link java.io.File}.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private File[] fileParams;
|
||||
|
||||
/**
|
||||
* A collection parameter of type {@link java.util.List}.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private List listParam;
|
||||
|
||||
/**
|
||||
* A collection parameter of type {@link java.util.Set}.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private Set setParam;
|
||||
|
||||
/**
|
||||
* A collection parameter of type {@link java.util.Map}.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private Map mapParam;
|
||||
|
||||
/**
|
||||
* A collection parameter of type {@link java.util.Properties}.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private Properties propertiesParam;
|
||||
|
||||
/**
|
||||
* A complex parameter with an alias.
|
||||
*
|
||||
*
|
||||
* @parameter alias="aliasStringParamsLegacy"
|
||||
*/
|
||||
private String[] aliasStringParams;
|
||||
|
||||
/**
|
||||
* A complex parameter of type {@link org.apache.maven.plugin.coreit.Bean}.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private Bean beanParam;
|
||||
|
||||
/**
|
||||
* A raw DOM snippet.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private PlexusConfiguration domParam;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -289,7 +288,7 @@ public class ConfigMojo
|
|||
|
||||
/**
|
||||
* Dumps the mojo configuration into the specified properties.
|
||||
*
|
||||
*
|
||||
* @param props The properties to dump the configuration into, must not be <code>null</code>.
|
||||
*/
|
||||
private void dumpConfiguration( Properties props )
|
||||
|
@ -306,14 +305,14 @@ public class ConfigMojo
|
|||
PropertiesUtil.serialize( props, "booleanParam", booleanParam );
|
||||
if ( primitiveBooleanParam )
|
||||
{
|
||||
PropertiesUtil.serialize( props, "primitiveBooleanParam", Boolean.valueOf( primitiveBooleanParam ) );
|
||||
PropertiesUtil.serialize( props, "primitiveBooleanParam", primitiveBooleanParam );
|
||||
}
|
||||
PropertiesUtil.serialize( props, "byteParam", byteParam );
|
||||
PropertiesUtil.serialize( props, "shortParam", shortParam );
|
||||
PropertiesUtil.serialize( props, "integerParam", integerParam );
|
||||
if ( primitiveIntegerParam != 0 )
|
||||
{
|
||||
PropertiesUtil.serialize( props, "primitiveIntegerParam", new Integer( primitiveIntegerParam ) );
|
||||
PropertiesUtil.serialize( props, "primitiveIntegerParam", primitiveIntegerParam );
|
||||
}
|
||||
PropertiesUtil.serialize( props, "longParam", longParam );
|
||||
PropertiesUtil.serialize( props, "floatParam", floatParam );
|
||||
|
@ -336,7 +335,7 @@ public class ConfigMojo
|
|||
{
|
||||
PropertiesUtil.serialize( props, "beanParam.fieldParam", beanParam.fieldParam );
|
||||
PropertiesUtil.serialize( props, "beanParam.setterParam", beanParam.setterParam );
|
||||
PropertiesUtil.serialize( props, "beanParam.setterCalled", Boolean.valueOf( beanParam.setterCalled ) );
|
||||
PropertiesUtil.serialize( props, "beanParam.setterCalled", beanParam.setterCalled );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -34,12 +37,9 @@ import java.util.Iterator;
|
|||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||
|
||||
/**
|
||||
* Assists in handling properties.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
class PropertiesUtil
|
||||
|
@ -164,18 +164,17 @@ class PropertiesUtil
|
|||
|
||||
PlexusConfiguration children[] = config.getChildren();
|
||||
props.setProperty( key + ".children", Integer.toString( children.length ) );
|
||||
Map indices = new HashMap();
|
||||
for ( int i = 0; i < children.length; i++ )
|
||||
Map<String, Integer> indices = new HashMap<>();
|
||||
for ( PlexusConfiguration child : children )
|
||||
{
|
||||
PlexusConfiguration child = children[i];
|
||||
String name = child.getName();
|
||||
Integer index = (Integer) indices.get( name );
|
||||
Integer index = indices.get( name );
|
||||
if ( index == null )
|
||||
{
|
||||
index = new Integer( 0 );
|
||||
index = 0;
|
||||
}
|
||||
serialize( props, key + ".children." + name + "." + index, child );
|
||||
indices.put( name, new Integer( index.intValue() + 1 ) );
|
||||
indices.put( name, index + 1 );
|
||||
}
|
||||
}
|
||||
else if ( value instanceof Date )
|
||||
|
|
|
@ -31,12 +31,11 @@ import java.io.OutputStreamWriter;
|
|||
|
||||
/**
|
||||
* Creates a text file in the project base directory.
|
||||
*
|
||||
* @goal resources
|
||||
* @phase process-resources
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal resources
|
||||
* @phase process-resources
|
||||
*/
|
||||
public class ResourcesMojo
|
||||
extends AbstractMojo
|
||||
|
@ -44,7 +43,7 @@ public class ResourcesMojo
|
|||
|
||||
/**
|
||||
* The current Maven project.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project}"
|
||||
* @required
|
||||
* @readonly
|
||||
|
@ -53,7 +52,7 @@ public class ResourcesMojo
|
|||
|
||||
/**
|
||||
* The path to the output file, relative to the project base directory directory.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String pathname = "target/resources-resources.txt";
|
||||
|
@ -61,16 +60,16 @@ public class ResourcesMojo
|
|||
/**
|
||||
* An optional message line to write to the output file (using UTF-8 encoding). If given, the output file will be
|
||||
* opened in append mode.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created.
|
||||
* @throws MojoFailureException If the output file has not been set.
|
||||
* @throws MojoFailureException If the output file has not been set.
|
||||
*/
|
||||
public void execute()
|
||||
throws MojoExecutionException, MojoFailureException
|
||||
|
@ -98,16 +97,12 @@ public class ResourcesMojo
|
|||
{
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] " + message );
|
||||
|
||||
OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream( outputFile, true ), "UTF-8" );
|
||||
try
|
||||
try ( OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream( outputFile, true ),
|
||||
"UTF-8" ) )
|
||||
{
|
||||
writer.write( message );
|
||||
writer.write( "\n" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -30,11 +30,10 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Provides common services for all mojos of this plugin.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -44,7 +43,7 @@ public abstract class AbstractDependencyMojo
|
|||
|
||||
/**
|
||||
* The current Maven project.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project}"
|
||||
* @required
|
||||
* @readonly
|
||||
|
@ -53,9 +52,9 @@ public abstract class AbstractDependencyMojo
|
|||
|
||||
/**
|
||||
* Writes the specified artifacts to the given output file.
|
||||
*
|
||||
* @param pathname The path to the output file, relative to the project base directory, may be <code>null</code> or
|
||||
* empty if the output file should not be written.
|
||||
*
|
||||
* @param pathname The path to the output file, relative to the project base directory, may be <code>null</code> or
|
||||
* empty if the output file should not be written.
|
||||
* @param artifacts The list of artifacts to write to the file, may be <code>null</code>.
|
||||
* @throws MojoExecutionException If the output file could not be written.
|
||||
*/
|
||||
|
@ -80,9 +79,9 @@ public abstract class AbstractDependencyMojo
|
|||
|
||||
if ( artifacts != null )
|
||||
{
|
||||
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
|
||||
for ( Object artifact1 : artifacts )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
Artifact artifact = (Artifact) artifact1;
|
||||
writer.write( artifact.getId() );
|
||||
writer.newLine();
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] " + artifact.getId() );
|
||||
|
|
|
@ -19,24 +19,22 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Combines dependency collection with aggregation. The path parameters of this mojo support the token
|
||||
* <code>@artifactId@</code> to dynamically adjust the output file for each project in the reactor whose
|
||||
* dependencies are dumped.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal aggregate-test
|
||||
* @requiresDependencyCollection test
|
||||
* @aggregator true
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AggregateTestMojo
|
||||
extends AbstractDependencyMojo
|
||||
|
@ -47,14 +45,14 @@ public class AggregateTestMojo
|
|||
* UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
|
||||
* disk. Unlike the test artifacts, the collection of project artifacts additionally contains those artifacts that
|
||||
* do not contribute to the class path.
|
||||
*
|
||||
*
|
||||
* @parameter property="depres.projectArtifacts"
|
||||
*/
|
||||
private String projectArtifacts;
|
||||
|
||||
/**
|
||||
* The Maven projects in the reactor.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${reactorProjects}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -62,7 +60,7 @@ public class AggregateTestMojo
|
|||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -70,9 +68,9 @@ public class AggregateTestMojo
|
|||
{
|
||||
try
|
||||
{
|
||||
for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
|
||||
for ( Object reactorProject : reactorProjects )
|
||||
{
|
||||
MavenProject project = (MavenProject) it.next();
|
||||
MavenProject project = (MavenProject) reactorProject;
|
||||
|
||||
writeArtifacts( filter( projectArtifacts, project ), project.getArtifacts() );
|
||||
|
||||
|
|
|
@ -34,12 +34,11 @@ import java.security.DigestInputStream;
|
|||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Provides common services for all mojos of this plugin.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -49,7 +48,7 @@ public abstract class AbstractDependencyMojo
|
|||
|
||||
/**
|
||||
* The current Maven project.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project}"
|
||||
* @required
|
||||
* @readonly
|
||||
|
@ -62,16 +61,16 @@ public abstract class AbstractDependencyMojo
|
|||
* this parameter to 1 to keep only the simple file name. The trimmed down paths will always use the forward slash
|
||||
* as directory separator. For non-positive values, the full/absolute path is returned, using the platform-specific
|
||||
* separator.
|
||||
*
|
||||
*
|
||||
* @parameter property="depres.significantPathLevels"
|
||||
*/
|
||||
private int significantPathLevels;
|
||||
|
||||
/**
|
||||
* Writes the specified artifacts to the given output file.
|
||||
*
|
||||
* @param pathname The path to the output file, relative to the project base directory, may be <code>null</code> or
|
||||
* empty if the output file should not be written.
|
||||
*
|
||||
* @param pathname The path to the output file, relative to the project base directory, may be <code>null</code> or
|
||||
* empty if the output file should not be written.
|
||||
* @param artifacts The list of artifacts to write to the file, may be <code>null</code>.
|
||||
* @throws MojoExecutionException If the output file could not be written.
|
||||
*/
|
||||
|
@ -96,9 +95,9 @@ public abstract class AbstractDependencyMojo
|
|||
|
||||
if ( artifacts != null )
|
||||
{
|
||||
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
|
||||
for ( Object artifact1 : artifacts )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
Artifact artifact = (Artifact) artifact1;
|
||||
String id = getId( artifact );
|
||||
writer.write( id );
|
||||
writer.newLine();
|
||||
|
@ -134,9 +133,9 @@ public abstract class AbstractDependencyMojo
|
|||
|
||||
/**
|
||||
* Writes the specified class path elements to the given output file.
|
||||
*
|
||||
* @param pathname The path to the output file, relative to the project base directory, may be <code>null</code> or
|
||||
* empty if the output file should not be written.
|
||||
*
|
||||
* @param pathname The path to the output file, relative to the project base directory, may be <code>null</code> or
|
||||
* empty if the output file should not be written.
|
||||
* @param classPath The list of class path elements to write to the file, may be <code>null</code>.
|
||||
* @throws MojoExecutionException If the output file could not be written.
|
||||
*/
|
||||
|
@ -161,9 +160,9 @@ public abstract class AbstractDependencyMojo
|
|||
|
||||
if ( classPath != null )
|
||||
{
|
||||
for ( Iterator it = classPath.iterator(); it.hasNext(); )
|
||||
for ( Object aClassPath : classPath )
|
||||
{
|
||||
String element = it.next().toString();
|
||||
String element = aClassPath.toString();
|
||||
writer.write( stripLeadingDirs( element, significantPathLevels ) );
|
||||
writer.newLine();
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] " + element );
|
||||
|
@ -206,9 +205,9 @@ public abstract class AbstractDependencyMojo
|
|||
|
||||
if ( classPath != null )
|
||||
{
|
||||
for ( Iterator it = classPath.iterator(); it.hasNext(); )
|
||||
for ( Object aClassPath : classPath )
|
||||
{
|
||||
String element = it.next().toString();
|
||||
String element = aClassPath.toString();
|
||||
|
||||
File jarFile = new File( element );
|
||||
|
||||
|
@ -274,8 +273,7 @@ public abstract class AbstractDependencyMojo
|
|||
{
|
||||
MessageDigest digester = MessageDigest.getInstance( "SHA-1" );
|
||||
|
||||
FileInputStream is = new FileInputStream( jarFile );
|
||||
try
|
||||
try ( FileInputStream is = new FileInputStream( jarFile ) )
|
||||
{
|
||||
DigestInputStream dis = new DigestInputStream( is, digester );
|
||||
|
||||
|
@ -284,19 +282,14 @@ public abstract class AbstractDependencyMojo
|
|||
// just read it
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
is.close();
|
||||
}
|
||||
|
||||
byte[] digest = digester.digest();
|
||||
|
||||
StringBuffer hash = new StringBuffer( digest.length * 2 );
|
||||
StringBuilder hash = new StringBuilder( digest.length * 2 );
|
||||
|
||||
for ( int i = 0; i < digest.length; i++ )
|
||||
for ( byte aDigest : digest )
|
||||
{
|
||||
@SuppressWarnings( "checkstyle:magicnumber" )
|
||||
int b = digest[i] & 0xFF;
|
||||
@SuppressWarnings( "checkstyle:magicnumber" ) int b = aDigest & 0xFF;
|
||||
|
||||
if ( b < 0x10 )
|
||||
{
|
||||
|
@ -341,7 +334,7 @@ public abstract class AbstractDependencyMojo
|
|||
|
||||
if ( pathname != null )
|
||||
{
|
||||
if ( pathname.indexOf( "@idx@" ) >= 0 )
|
||||
if ( pathname.contains( "@idx@" ) )
|
||||
{
|
||||
// helps to distinguished forked executions of the same mojo
|
||||
pathname = pathname.replaceAll( "@idx@", String.valueOf( nextCounter() ) );
|
||||
|
@ -366,7 +359,7 @@ public abstract class AbstractDependencyMojo
|
|||
|
||||
synchronized ( System.class )
|
||||
{
|
||||
counter = Integer.getInteger( key, 0 ).intValue();
|
||||
counter = Integer.getInteger( key, 0 );
|
||||
System.setProperty( key, Integer.toString( counter + 1 ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -19,24 +19,22 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Combines dependency resolution with aggregation. The path parameters of this mojo support the token
|
||||
* <code>@artifactId@</code> to dynamically adjust the output file for each project in the reactor whose
|
||||
* dependencies are dumped.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal aggregate-test
|
||||
* @requiresDependencyResolution test
|
||||
* @aggregator true
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AggregateTestMojo
|
||||
extends AbstractDependencyMojo
|
||||
|
@ -47,7 +45,7 @@ public class AggregateTestMojo
|
|||
* UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
|
||||
* disk. Unlike the test artifacts, the collection of project artifacts additionally contains those artifacts that
|
||||
* do not contribute to the class path.
|
||||
*
|
||||
*
|
||||
* @parameter property="depres.projectArtifacts"
|
||||
*/
|
||||
private String projectArtifacts;
|
||||
|
@ -56,7 +54,7 @@ public class AggregateTestMojo
|
|||
* The path to the output file for the test class path, relative to the project base directory. Each line of
|
||||
* this UTF-8 encoded file specifies the absolute path to a class path element. If not specified, the class path
|
||||
* will not be written to disk.
|
||||
*
|
||||
*
|
||||
* @parameter property="depres.testClassPath"
|
||||
*/
|
||||
private String testClassPath;
|
||||
|
@ -65,14 +63,14 @@ public class AggregateTestMojo
|
|||
* The path to the properties file for the checksums of the test class path elements, relative to the project base
|
||||
* directory. The (trimmed) path to a JAR is used as the property key, the property value is the SHA-1 hash of the
|
||||
* JAR. If not specified, the class path checksums will not be calculated.
|
||||
*
|
||||
*
|
||||
* @parameter property="depres.testClassPathChecksums"
|
||||
*/
|
||||
private String testClassPathChecksums;
|
||||
|
||||
/**
|
||||
* The Maven projects in the reactor.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${reactorProjects}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -80,7 +78,7 @@ public class AggregateTestMojo
|
|||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -88,9 +86,9 @@ public class AggregateTestMojo
|
|||
{
|
||||
try
|
||||
{
|
||||
for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
|
||||
for ( Object reactorProject : reactorProjects )
|
||||
{
|
||||
MavenProject project = (MavenProject) it.next();
|
||||
MavenProject project = (MavenProject) reactorProject;
|
||||
|
||||
writeArtifacts( filter( projectArtifacts, project ), project.getArtifacts() );
|
||||
writeClassPath( filter( testClassPath, project ), project.getTestClasspathElements() );
|
||||
|
|
|
@ -19,25 +19,23 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Injects artifacts from the plugin into the dependency artifacts of the project.
|
||||
*
|
||||
* @goal inject
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal inject
|
||||
*/
|
||||
public class InjectMojo
|
||||
extends AbstractMojo
|
||||
|
@ -46,7 +44,7 @@ public class InjectMojo
|
|||
/**
|
||||
* The version-less keys in the form <code>groupId:artifactId</code> of the plugin artifacts to inject into
|
||||
* dependency artifacts of the project.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String[] artifacts;
|
||||
|
@ -59,7 +57,7 @@ public class InjectMojo
|
|||
|
||||
/**
|
||||
* The current Maven project.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project}"
|
||||
* @required
|
||||
* @readonly
|
||||
|
@ -68,14 +66,14 @@ public class InjectMojo
|
|||
|
||||
/**
|
||||
* The artifact factory.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactFactory factory;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If an error occured.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -99,16 +97,17 @@ public class InjectMojo
|
|||
dependencyArtifacts = new LinkedHashSet();
|
||||
}
|
||||
|
||||
for ( Iterator it = pluginArtifacts.iterator(); it.hasNext(); )
|
||||
for ( Object pluginArtifact : pluginArtifacts )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
Artifact artifact = (Artifact) pluginArtifact;
|
||||
|
||||
String artifactKey = artifact.getGroupId() + ':' + artifact.getArtifactId();
|
||||
|
||||
if ( artifactKeys.remove( artifactKey ) )
|
||||
{
|
||||
artifact = factory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(),
|
||||
artifact.getVersion(), Artifact.SCOPE_COMPILE, artifact.getType() );
|
||||
artifact =
|
||||
factory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
|
||||
Artifact.SCOPE_COMPILE, artifact.getType() );
|
||||
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Injecting dependency artifact " + artifact );
|
||||
|
||||
|
|
|
@ -19,11 +19,6 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||
|
@ -36,13 +31,17 @@ import org.apache.maven.execution.MavenSession;
|
|||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Attempts to resolve a single artifact from dependencies, and logs the results for the Verifier to look at.
|
||||
*
|
||||
* @goal resolve-one-dependency
|
||||
* @requiresDependencyResolution runtime
|
||||
*
|
||||
* @author bimargulies
|
||||
* @version $Id$
|
||||
* @goal resolve-one-dependency
|
||||
* @requiresDependencyResolution runtime
|
||||
*/
|
||||
public class ResolveOneDependencyMojo
|
||||
extends AbstractDependencyMojo
|
||||
|
@ -50,42 +49,46 @@ public class ResolveOneDependencyMojo
|
|||
|
||||
/**
|
||||
* Group ID of the artifact to resolve.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
* @required
|
||||
*/
|
||||
private String groupId;
|
||||
|
||||
/**
|
||||
* Artifact ID of the artifact to resolve.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
* @required
|
||||
*/
|
||||
private String artifactId;
|
||||
|
||||
/**
|
||||
* Version of the artifact to resolve.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
* @required
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* Type of the artifact to resolve.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
* @required
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* Classifier of the artifact to resolve.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String classifier;
|
||||
|
||||
/**
|
||||
* The scope to resolve for.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
* @required
|
||||
*/
|
||||
|
@ -111,7 +114,7 @@ public class ResolveOneDependencyMojo
|
|||
|
||||
/**
|
||||
* The Maven session.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${session}"
|
||||
* @readonly
|
||||
* @required
|
||||
|
@ -120,14 +123,14 @@ public class ResolveOneDependencyMojo
|
|||
|
||||
/**
|
||||
* Metadata source object.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactMetadataSource metadataSource;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -137,9 +140,8 @@ public class ResolveOneDependencyMojo
|
|||
Artifact projectArtifact = project.getArtifact();
|
||||
if ( projectArtifact == null )
|
||||
{
|
||||
projectArtifact =
|
||||
artifactFactory.createProjectArtifact( project.getGroupId(), project.getArtifactId(),
|
||||
project.getVersion() );
|
||||
projectArtifact = artifactFactory.createProjectArtifact( project.getGroupId(), project.getArtifactId(),
|
||||
project.getVersion() );
|
||||
}
|
||||
|
||||
Set depArtifacts = new HashSet();
|
||||
|
@ -152,10 +154,10 @@ public class ResolveOneDependencyMojo
|
|||
ArtifactResolutionResult result;
|
||||
try
|
||||
{
|
||||
result =
|
||||
resolver.resolveTransitively( depArtifacts, projectArtifact, project.getManagedVersionMap(),
|
||||
session.getLocalRepository(), project.getRemoteArtifactRepositories(),
|
||||
metadataSource, scopeFilter );
|
||||
result = resolver.resolveTransitively( depArtifacts, projectArtifact, project.getManagedVersionMap(),
|
||||
session.getLocalRepository(),
|
||||
project.getRemoteArtifactRepositories(), metadataSource,
|
||||
scopeFilter );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
|
@ -173,13 +175,12 @@ public class ResolveOneDependencyMojo
|
|||
else
|
||||
{
|
||||
Set resolvedArtifacts = result.getArtifacts();
|
||||
Iterator it = resolvedArtifacts.iterator();
|
||||
/*
|
||||
* Assume that the user of this is not interested in transitive deps and such, just report the one.
|
||||
*/
|
||||
while ( it.hasNext() )
|
||||
for ( Object resolvedArtifact : resolvedArtifacts )
|
||||
{
|
||||
Artifact a = (Artifact) it.next();
|
||||
Artifact a = (Artifact) resolvedArtifact;
|
||||
if ( a.equals( artifact ) )
|
||||
{
|
||||
File file = a.getFile();
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.apache.maven.plugin.MojoFailureException;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -37,7 +36,7 @@ import java.util.Properties;
|
|||
* value but can also be a collection/array or a bean-like object (from the Maven model). For example, the expression
|
||||
* "project/dependencies/0" would extract the first project dependency. In more detail, this example expression could
|
||||
* output the following keys to the properties file:
|
||||
*
|
||||
* <p/>
|
||||
* <pre>
|
||||
* project.dependencies.0.groupId = org.apache.maven
|
||||
* project.dependencies.0.artifactId = maven-project
|
||||
|
@ -50,15 +49,14 @@ import java.util.Properties;
|
|||
* project.dependencies.0.exclusions.1.groupId = plexus
|
||||
* project.dependencies.0.exclusions.1.artifactId = plexus-container-default
|
||||
* </pre>
|
||||
*
|
||||
* <p/>
|
||||
* Expressions that reference non-existing objects or use invalid collection/array indices silently resolve to
|
||||
* <code>null</code>. For collections and arrays, the special index "*" can be used to iterate all elements.
|
||||
*
|
||||
* @goal eval
|
||||
* @phase initialize
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal eval
|
||||
* @phase initialize
|
||||
*/
|
||||
public class EvalMojo
|
||||
extends AbstractMojo
|
||||
|
@ -66,7 +64,7 @@ public class EvalMojo
|
|||
|
||||
/**
|
||||
* The project's base directory, used for manual path translation.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${basedir}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -76,28 +74,28 @@ public class EvalMojo
|
|||
* The path to the output file for the properties with the expression values. For each expression given by the
|
||||
* parameter {@link #expressions} an similar named properties key will be used to save the expression value. If an
|
||||
* expression evaluated to <code>null</code>, there will be no corresponding key in the properties file.
|
||||
*
|
||||
*
|
||||
* @parameter property="expression.outputFile"
|
||||
*/
|
||||
private File outputFile;
|
||||
|
||||
/**
|
||||
* The set of expressions to evaluate.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String[] expressions;
|
||||
|
||||
/**
|
||||
* The comma separated set of expressions to evaluate.
|
||||
*
|
||||
*
|
||||
* @parameter property="expression.expressions"
|
||||
*/
|
||||
private String expressionList;
|
||||
|
||||
/**
|
||||
* The current Maven project against which expressions are evaluated.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -105,7 +103,7 @@ public class EvalMojo
|
|||
|
||||
/**
|
||||
* The forked Maven project against which expressions are evaluated.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${executedProject}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -113,7 +111,7 @@ public class EvalMojo
|
|||
|
||||
/**
|
||||
* The merged user/global settings of the current build against which expressions are evaluated.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${settings}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -121,7 +119,7 @@ public class EvalMojo
|
|||
|
||||
/**
|
||||
* The session context of the current build against which expressions are evaluated.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${session}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -129,7 +127,7 @@ public class EvalMojo
|
|||
|
||||
/**
|
||||
* The local repository of the current build against which expressions are evaluated.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${localRepository}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -137,9 +135,9 @@ public class EvalMojo
|
|||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created.
|
||||
* @throws MojoFailureException If the output file has not been set.
|
||||
* @throws MojoFailureException If the output file has not been set.
|
||||
*/
|
||||
public void execute()
|
||||
throws MojoExecutionException, MojoFailureException
|
||||
|
@ -175,12 +173,11 @@ public class EvalMojo
|
|||
contexts.put( "session", session );
|
||||
contexts.put( "localRepository", localRepository );
|
||||
|
||||
for ( int i = 0; i < expressions.length; i++ )
|
||||
for ( String expression : expressions )
|
||||
{
|
||||
Map values = ExpressionUtil.evaluate( expressions[i], contexts );
|
||||
for ( Iterator it = values.keySet().iterator(); it.hasNext(); )
|
||||
Map values = ExpressionUtil.evaluate( expression, contexts );
|
||||
for ( Object key : values.keySet() )
|
||||
{
|
||||
Object key = it.next();
|
||||
Object value = values.get( key );
|
||||
PropertyUtil.store( expressionProperties, key.toString().replace( '/', '.' ), value );
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* Assists in evaluating expressions.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -55,11 +55,11 @@ class ExpressionUtil
|
|||
* objects are available. For instance, if <code>contexts</code> maps the token "project" to a Maven project
|
||||
* instance, the expression "project/build/resources/0/directory" specifies the first resource directory of the
|
||||
* project.
|
||||
*
|
||||
*
|
||||
* @param expression The expression to evaluate, may be <code>null</code>.
|
||||
* @param context The object to start expression evaluation at, must not be <code>null</code>.
|
||||
* @param context The object to start expression evaluation at, must not be <code>null</code>.
|
||||
* @return The values of the evaluation, indexed by expression, or an empty map if the segments could not be
|
||||
* evaluated.
|
||||
* evaluated.
|
||||
*/
|
||||
public static Map evaluate( String expression, Object context )
|
||||
{
|
||||
|
@ -76,12 +76,12 @@ class ExpressionUtil
|
|||
|
||||
/**
|
||||
* Evaluates the given expression segments against the specified object.
|
||||
*
|
||||
* @param prefix The expression prefix that led to the current context, must not be <code>null</code>.
|
||||
*
|
||||
* @param prefix The expression prefix that led to the current context, must not be <code>null</code>.
|
||||
* @param segments The expression segments to evaluate, must not be <code>null</code>.
|
||||
* @param context The object to evaluate the segments against, may be <code>null</code>.
|
||||
* @param context The object to evaluate the segments against, may be <code>null</code>.
|
||||
* @return The values of the evaluation, indexed by expression, or an empty map if the segments could not be
|
||||
* evaluated.
|
||||
* evaluated.
|
||||
*/
|
||||
private static Map evaluate( String prefix, List segments, Object context )
|
||||
{
|
||||
|
@ -142,12 +142,12 @@ class ExpressionUtil
|
|||
}
|
||||
|
||||
values = new LinkedHashMap();
|
||||
for ( Iterator it = targets.keySet().iterator(); it.hasNext(); )
|
||||
for ( Object key : targets.keySet() )
|
||||
{
|
||||
Object key = it.next();
|
||||
Object target = targets.get( key );
|
||||
values.putAll( evaluate( concat( prefix, String.valueOf( key ) ),
|
||||
segments.subList( 1, segments.size() ), target ) );
|
||||
values.putAll(
|
||||
evaluate( concat( prefix, String.valueOf( key ) ), segments.subList( 1, segments.size() ),
|
||||
target ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,8 +161,8 @@ class ExpressionUtil
|
|||
|
||||
/**
|
||||
* Gets the value of a (public) bean property from the specified object.
|
||||
*
|
||||
* @param context The object whose bean property should be retrieved, must not be <code>null</code>.
|
||||
*
|
||||
* @param context The object whose bean property should be retrieved, must not be <code>null</code>.
|
||||
* @param property The name of the bean property, must not be <code>null</code>.
|
||||
* @return The value of the bean property or <code>null</code> if the property does not exist.
|
||||
*/
|
||||
|
@ -220,7 +220,7 @@ class ExpressionUtil
|
|||
method = type.getMethod( "get", OBJECT_PARAM );
|
||||
}
|
||||
method.setAccessible( true );
|
||||
value = method.invoke( context, new Object[] { property } );
|
||||
value = method.invoke( context, new Object[]{ property } );
|
||||
}
|
||||
catch ( NoSuchMethodException e3 )
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ class ExpressionUtil
|
|||
{
|
||||
if ( "length".equals( property ) && type.isArray() )
|
||||
{
|
||||
value = new Integer( Array.getLength( context ) );
|
||||
value = Array.getLength( context );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* Assists in serializing primitives and beans into properties for later inspection/verification.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -49,10 +49,10 @@ class PropertyUtil
|
|||
/**
|
||||
* Serializes the specified object into the given properties, using the provided key. The object may be a scalar
|
||||
* value like a string or some array/collection/map or a bean.
|
||||
*
|
||||
*
|
||||
* @param props The properties to serialize into, must not be <code>null</code>.
|
||||
* @param key The key to use for serialization of the object data, must not be <code>null</code>.
|
||||
* @param obj The object to serialize, may be <code>null</code>.
|
||||
* @param key The key to use for serialization of the object data, must not be <code>null</code>.
|
||||
* @param obj The object to serialize, may be <code>null</code>.
|
||||
*/
|
||||
public static void store( Properties props, String key, Object obj )
|
||||
{
|
||||
|
@ -62,12 +62,12 @@ class PropertyUtil
|
|||
/**
|
||||
* Serializes the specified object into the given properties, using the provided key. The object may be a scalar
|
||||
* value like a string or some array/collection/map or a bean.
|
||||
*
|
||||
* @param props The properties to serialize into, must not be <code>null</code>.
|
||||
* @param key The key to use for serialization of the object data, must not be <code>null</code>.
|
||||
* @param obj The object to serialize, may be <code>null</code>.
|
||||
*
|
||||
* @param props The properties to serialize into, must not be <code>null</code>.
|
||||
* @param key The key to use for serialization of the object data, must not be <code>null</code>.
|
||||
* @param obj The object to serialize, may be <code>null</code>.
|
||||
* @param visited The set/stack of already visited objects, used to detect back references in the object graph, must
|
||||
* not be <code>null</code>.
|
||||
* not be <code>null</code>.
|
||||
*/
|
||||
private static void store( Properties props, String key, Object obj, Collection visited )
|
||||
{
|
||||
|
@ -132,21 +132,19 @@ class PropertyUtil
|
|||
props.put( key + ".children", Integer.toString( children.length ) );
|
||||
|
||||
Map indices = new HashMap();
|
||||
for ( int i = 0; i < children.length; i++ )
|
||||
for ( Object child : children )
|
||||
{
|
||||
Object child = children[i];
|
||||
|
||||
String name = (String) getName.invoke( child, NO_ARGS );
|
||||
|
||||
Integer index = (Integer) indices.get( name );
|
||||
if ( index == null )
|
||||
{
|
||||
index = new Integer( 0 );
|
||||
index = 0;
|
||||
}
|
||||
|
||||
store( props, key + ".children." + name + "." + index, child, visited );
|
||||
|
||||
indices.put( name, new Integer( index.intValue() + 1 ) );
|
||||
indices.put( name, index + 1 );
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
|
@ -158,13 +156,12 @@ class PropertyUtil
|
|||
{
|
||||
Class type = obj.getClass();
|
||||
Method[] methods = type.getMethods();
|
||||
for ( int i = 0; i < methods.length; i++ )
|
||||
for ( Method method : methods )
|
||||
{
|
||||
Method method = methods[i];
|
||||
if ( Modifier.isStatic( method.getModifiers() ) || method.getParameterTypes().length > 0
|
||||
|| !method.getName().matches( "(get|is)\\p{Lu}.*" ) || method.getName().endsWith( "AsMap" )
|
||||
|| Class.class.isAssignableFrom( method.getReturnType() )
|
||||
|| Object.class.equals( method.getReturnType() ) )
|
||||
|| Class.class.isAssignableFrom( method.getReturnType() ) || Object.class.equals(
|
||||
method.getReturnType() ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -186,7 +183,7 @@ class PropertyUtil
|
|||
|
||||
/**
|
||||
* Derives the bean property name from the specified method for its getter.
|
||||
*
|
||||
*
|
||||
* @param methodName The method name of the property's getter, must not be <code>null</code>.
|
||||
* @return The property name, never <code>null</code>.
|
||||
*/
|
||||
|
@ -206,9 +203,9 @@ class PropertyUtil
|
|||
|
||||
/**
|
||||
* Writes the specified properties to the given file.
|
||||
*
|
||||
*
|
||||
* @param props The properties to write, must not be <code>null</code>.
|
||||
* @param file The output file for the properties, must not be <code>null</code>.
|
||||
* @param file The output file for the properties, must not be <code>null</code>.
|
||||
* @throws IOException If the properties could not be written to the file.
|
||||
*/
|
||||
public static void write( Properties props, File file )
|
||||
|
|
|
@ -19,13 +19,13 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
|
@ -36,8 +36,8 @@ public class ExpressionUtilTest
|
|||
|
||||
public void testEvaluate()
|
||||
{
|
||||
Object array = new String[] { "one", "two", "three" };
|
||||
Object list = Arrays.asList( new String[] { "0", "-1", "-2" } );
|
||||
Object array = new String[]{ "one", "two", "three" };
|
||||
Object list = Arrays.asList( new String[]{ "0", "-1", "-2" } );
|
||||
Object map = Collections.singletonMap( "some.key", "value" );
|
||||
Object bean = new BeanTwo();
|
||||
|
||||
|
@ -54,9 +54,9 @@ public class ExpressionUtilTest
|
|||
assertSame( bean, evaluate( "bean", contexts ) );
|
||||
assertNull( evaluate( "no-root", contexts ) );
|
||||
|
||||
assertEquals( new Integer( 3 ), evaluate( "array/length", contexts ) );
|
||||
assertEquals( 3, evaluate( "array/length", contexts ) );
|
||||
assertEquals( "three", evaluate( "array/2", contexts ) );
|
||||
assertEquals( new Integer( 5 ), evaluate( "array/2/length", contexts ) );
|
||||
assertEquals( 5, evaluate( "array/2/length", contexts ) );
|
||||
assertNull( evaluate( "array/invalid", contexts ) );
|
||||
assertNull( evaluate( "array/-1", contexts ) );
|
||||
assertNull( evaluate( "array/999", contexts ) );
|
||||
|
@ -65,7 +65,7 @@ public class ExpressionUtilTest
|
|||
assertEquals( "two", ExpressionUtil.evaluate( "array/*", contexts ).get( "array/1" ) );
|
||||
assertEquals( "three", ExpressionUtil.evaluate( "array/*", contexts ).get( "array/2" ) );
|
||||
|
||||
assertEquals( new Integer( 3 ), evaluate( "list/size", contexts ) );
|
||||
assertEquals( 3, evaluate( "list/size", contexts ) );
|
||||
assertEquals( "-2", evaluate( "list/2", contexts ) );
|
||||
assertNull( evaluate( "list/invalid", contexts ) );
|
||||
assertNull( evaluate( "list/-1", contexts ) );
|
||||
|
@ -75,7 +75,7 @@ public class ExpressionUtilTest
|
|||
assertEquals( "-1", ExpressionUtil.evaluate( "list/*", contexts ).get( "list/1" ) );
|
||||
assertEquals( "-2", ExpressionUtil.evaluate( "list/*", contexts ).get( "list/2" ) );
|
||||
|
||||
assertEquals( new Integer( 1 ), evaluate( "map/size", contexts ) );
|
||||
assertEquals( 1, evaluate( "map/size", contexts ) );
|
||||
assertEquals( "value", evaluate( "map/some.key", contexts ) );
|
||||
assertNull( evaluate( "map/invalid", contexts ) );
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class ExpressionUtilTest
|
|||
assertEquals( bean2.field, ExpressionUtil.getProperty( bean2, "field" ) );
|
||||
assertSame( bean2.bean, ExpressionUtil.getProperty( bean2, "bean" ) );
|
||||
|
||||
assertEquals( new Integer( 0 ), ExpressionUtil.getProperty( new String[0], "length" ) );
|
||||
assertEquals( 0, ExpressionUtil.getProperty( new String[0], "length" ) );
|
||||
}
|
||||
|
||||
public static class BeanOne
|
||||
|
|
|
@ -19,13 +19,13 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Properties;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
|
@ -40,7 +40,7 @@ public class PropertyUtilTest
|
|||
PropertyUtil.store( props, "null", null );
|
||||
PropertyUtil.store( props, "string", "str" );
|
||||
PropertyUtil.store( props, "boolean", Boolean.TRUE );
|
||||
PropertyUtil.store( props, "int", new Integer( 7 ) );
|
||||
PropertyUtil.store( props, "int", 7 );
|
||||
PropertyUtil.store( props, "file", new File( "pom.xml" ) );
|
||||
|
||||
assertNull( props.get( "null" ) );
|
||||
|
@ -54,7 +54,7 @@ public class PropertyUtilTest
|
|||
public void testStoreArray()
|
||||
{
|
||||
Properties props = new Properties();
|
||||
PropertyUtil.store( props, "arr", new String[] { "one", "two" } );
|
||||
PropertyUtil.store( props, "arr", new String[]{ "one", "two" } );
|
||||
|
||||
assertEquals( "2", props.get( "arr" ) );
|
||||
assertEquals( "one", props.get( "arr.0" ) );
|
||||
|
@ -65,7 +65,7 @@ public class PropertyUtilTest
|
|||
public void testStoreList()
|
||||
{
|
||||
Properties props = new Properties();
|
||||
PropertyUtil.store( props, "arr", Arrays.asList( new String[] { "one", "two" } ) );
|
||||
PropertyUtil.store( props, "arr", Arrays.asList( new String[]{ "one", "two" } ) );
|
||||
|
||||
assertEquals( "2", props.get( "arr" ) );
|
||||
assertEquals( "one", props.get( "arr.0" ) );
|
||||
|
|
|
@ -19,17 +19,15 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @goal fork-goal-aggregator
|
||||
* @aggregator true
|
||||
*
|
||||
* @execute goal="touch"
|
||||
*/
|
||||
public class ForkGoalAggregatorMojo
|
||||
|
@ -48,22 +46,23 @@ public class ForkGoalAggregatorMojo
|
|||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
|
||||
for ( Object reactorProject : reactorProjects )
|
||||
{
|
||||
MavenProject executedProject = ( (MavenProject) it.next() ).getExecutionProject();
|
||||
MavenProject executedProject = ( (MavenProject) reactorProject ).getExecutionProject();
|
||||
|
||||
if ( !executedProject.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||
{
|
||||
throw new MojoExecutionException( "Unexpected result, final name of executed project "
|
||||
+ executedProject + " is " + executedProject.getBuild().getFinalName() + " (should be \'"
|
||||
+ TouchMojo.FINAL_NAME + "\')." );
|
||||
throw new MojoExecutionException(
|
||||
"Unexpected result, final name of executed project " + executedProject + " is "
|
||||
+ executedProject.getBuild().getFinalName() + " (should be \'" + TouchMojo.FINAL_NAME
|
||||
+ "\')." );
|
||||
}
|
||||
}
|
||||
|
||||
if ( project.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||
{
|
||||
throw new MojoExecutionException( "forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME
|
||||
+ "\')." );
|
||||
throw new MojoExecutionException(
|
||||
"forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME + "\')." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,17 +19,15 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @goal fork-lifecycle-aggregator
|
||||
* @aggregator true
|
||||
*
|
||||
* @execute phase="generate-sources" lifecycle="foo"
|
||||
*/
|
||||
public class ForkLifecycleAggregatorMojo
|
||||
|
@ -49,22 +47,23 @@ public class ForkLifecycleAggregatorMojo
|
|||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
|
||||
for ( Object reactorProject : reactorProjects )
|
||||
{
|
||||
MavenProject executedProject = ( (MavenProject) it.next() ).getExecutionProject();
|
||||
MavenProject executedProject = ( (MavenProject) reactorProject ).getExecutionProject();
|
||||
|
||||
if ( !executedProject.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||
{
|
||||
throw new MojoExecutionException( "Unexpected result, final name of executed project "
|
||||
+ executedProject + " is " + executedProject.getBuild().getFinalName() + " (should be \'"
|
||||
+ TouchMojo.FINAL_NAME + "\')." );
|
||||
throw new MojoExecutionException(
|
||||
"Unexpected result, final name of executed project " + executedProject + " is "
|
||||
+ executedProject.getBuild().getFinalName() + " (should be \'" + TouchMojo.FINAL_NAME
|
||||
+ "\')." );
|
||||
}
|
||||
}
|
||||
|
||||
if ( project.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||
{
|
||||
throw new MojoExecutionException( "forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME
|
||||
+ "\')." );
|
||||
throw new MojoExecutionException(
|
||||
"forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME + "\')." );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,12 +23,11 @@ import org.apache.maven.plugin.MojoExecutionException;
|
|||
|
||||
/**
|
||||
* Appends a separator line to the log file.
|
||||
*
|
||||
* @goal log-separator
|
||||
* @phase initialize
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal log-separator
|
||||
* @phase initialize
|
||||
*/
|
||||
public class LogSeparatorMojo
|
||||
extends AbstractLogMojo
|
||||
|
@ -36,20 +35,20 @@ public class LogSeparatorMojo
|
|||
|
||||
/**
|
||||
* The length of the separator line.
|
||||
*
|
||||
*
|
||||
* @parameter property="log.length" default-value="80"
|
||||
*/
|
||||
private int length;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created.
|
||||
*/
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer( length );
|
||||
StringBuilder buffer = new StringBuilder( length );
|
||||
for ( int i = 0; i < length; i++ )
|
||||
{
|
||||
buffer.append( '-' );
|
||||
|
|
|
@ -19,22 +19,21 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
/**
|
||||
* Requires a component with a non-default role hint and dumps this hint to a properties file.
|
||||
*
|
||||
* @goal it
|
||||
* @phase initialize
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal it
|
||||
* @phase initialize
|
||||
*/
|
||||
public class ItMojo
|
||||
extends AbstractMojo
|
||||
|
@ -42,21 +41,21 @@ public class ItMojo
|
|||
|
||||
/**
|
||||
* The path to the output file.
|
||||
*
|
||||
*
|
||||
* @parameter property="touch.outputFile" default-value="target/comp.properties"
|
||||
*/
|
||||
private File outputFile;
|
||||
|
||||
/**
|
||||
* NOTE: We don't specify a role hint here!
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private Component component;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -72,15 +71,10 @@ public class ItMojo
|
|||
try
|
||||
{
|
||||
outputFile.getParentFile().mkdirs();
|
||||
FileOutputStream os = new FileOutputStream( outputFile );
|
||||
try
|
||||
try ( FileOutputStream os = new FileOutputStream( outputFile ) )
|
||||
{
|
||||
props.store( os, "MAVEN-CORE-IT-LOG" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.io.OutputStreamWriter;
|
|||
|
||||
/**
|
||||
* Appends a message to an UTF-8 encoded plain text file.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @goal append
|
||||
*/
|
||||
|
@ -58,16 +58,12 @@ public class AppendMojo
|
|||
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] " + message );
|
||||
|
||||
OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream( outputFile, true ), "UTF-8" );
|
||||
try
|
||||
try ( OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream( outputFile, true ),
|
||||
"UTF-8" ) )
|
||||
{
|
||||
writer.write( message );
|
||||
writer.write( "\n" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -19,14 +19,14 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
/**
|
||||
* Check that we correctly use the implementation parameter.
|
||||
*
|
||||
|
@ -38,14 +38,14 @@ public class ParameterImplementationMojo
|
|||
|
||||
/**
|
||||
* The path to the properties file for the parameter information.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private File outputFile;
|
||||
|
||||
/**
|
||||
* A parameter whose type is an interface but with a default implementation class.
|
||||
*
|
||||
*
|
||||
* @parameter implementation="org.apache.maven.plugin.coreit.sub.AnImplementation"
|
||||
*/
|
||||
private AnInterface theParameter;
|
||||
|
@ -69,15 +69,10 @@ public class ParameterImplementationMojo
|
|||
{
|
||||
outputFile.getParentFile().mkdirs();
|
||||
|
||||
FileOutputStream os = new FileOutputStream( outputFile );
|
||||
try
|
||||
try ( FileOutputStream os = new FileOutputStream( outputFile ) )
|
||||
{
|
||||
props.store( os, "[MAVEN-CORE-IT-LOG]" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -19,15 +19,15 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @goal verify-property
|
||||
* @phase validate
|
||||
|
@ -65,7 +65,7 @@ public class PropertyInterpolationVerifierMojo
|
|||
throw new MojoExecutionException( "Properties do not match: Name = " + name + ", Value = " + value );
|
||||
}
|
||||
|
||||
if ( value.indexOf( "${" ) > -1 )
|
||||
if ( value.contains( "${" ) )
|
||||
{
|
||||
throw new MojoExecutionException( "Unresolved value: Name = " + name + ", Value = " + value );
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public abstract class AbstractPomMojo
|
|||
|
||||
/**
|
||||
* The project builder.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
protected MavenProjectBuilder builder;
|
||||
|
@ -69,15 +69,10 @@ public abstract class AbstractPomMojo
|
|||
{
|
||||
file.getParentFile().mkdirs();
|
||||
|
||||
FileOutputStream os = new FileOutputStream( file );
|
||||
try
|
||||
try ( FileOutputStream os = new FileOutputStream( file ) )
|
||||
{
|
||||
props.store( os, "[MAVEN-CORE-IT-LOG]" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -28,9 +28,9 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* Builds the local POMs.
|
||||
*
|
||||
* @goal local-pom
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @goal local-pom
|
||||
*/
|
||||
public class BuildLocalPomMojo
|
||||
extends AbstractPomMojo
|
||||
|
@ -38,14 +38,14 @@ public class BuildLocalPomMojo
|
|||
|
||||
/**
|
||||
* The properties file to dump the POM info to.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="target/pom.properties"
|
||||
*/
|
||||
private File propertiesFile;
|
||||
|
||||
/**
|
||||
* The local repository.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${localRepository}"
|
||||
* @readonly
|
||||
* @required
|
||||
|
@ -54,14 +54,14 @@ public class BuildLocalPomMojo
|
|||
|
||||
/**
|
||||
* The POM files to build.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private File[] files;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoFailureException If the artifact file has not been set.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -73,10 +73,8 @@ public class BuildLocalPomMojo
|
|||
|
||||
if ( files != null )
|
||||
{
|
||||
for ( int i = 0; i < files.length; i++ )
|
||||
for ( File file : files )
|
||||
{
|
||||
File file = files[i];
|
||||
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Building " + file );
|
||||
|
||||
try
|
||||
|
|
|
@ -32,11 +32,10 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* Builds the remote POMs of user-specified artifacts. This mimics in part the Maven Remote Resources Plugin.
|
||||
*
|
||||
* @goal remote-pom
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal remote-pom
|
||||
*/
|
||||
public class BuildRemotePomMojo
|
||||
extends AbstractPomMojo
|
||||
|
@ -44,14 +43,14 @@ public class BuildRemotePomMojo
|
|||
|
||||
/**
|
||||
* The properties file to dump the POM info to.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="target/pom.properties"
|
||||
*/
|
||||
private File propertiesFile;
|
||||
|
||||
/**
|
||||
* The local repository.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${localRepository}"
|
||||
* @readonly
|
||||
* @required
|
||||
|
@ -60,7 +59,7 @@ public class BuildRemotePomMojo
|
|||
|
||||
/**
|
||||
* The remote repositories of the current Maven project.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project.remoteArtifactRepositories}"
|
||||
* @readonly
|
||||
* @required
|
||||
|
@ -69,21 +68,21 @@ public class BuildRemotePomMojo
|
|||
|
||||
/**
|
||||
* The artifact factory.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private ArtifactFactory factory;
|
||||
|
||||
/**
|
||||
* The dependencies to resolve.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private Dependency[] dependencies;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoFailureException If the artifact file has not been set.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -95,10 +94,8 @@ public class BuildRemotePomMojo
|
|||
|
||||
if ( dependencies != null )
|
||||
{
|
||||
for ( int i = 0; i < dependencies.length; i++ )
|
||||
for ( Dependency dependency : dependencies )
|
||||
{
|
||||
Dependency dependency = dependencies[i];
|
||||
|
||||
Artifact artifact =
|
||||
factory.createArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(),
|
||||
dependency.getVersion(), dependency.getType(),
|
||||
|
|
|
@ -19,6 +19,9 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -26,17 +29,13 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
/**
|
||||
* Requires a singleton component in various ways and dumps the ids to a properties file.
|
||||
*
|
||||
* @goal it
|
||||
* @phase initialize
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal it
|
||||
* @phase initialize
|
||||
*/
|
||||
public class ItMojo
|
||||
extends AbstractMojo
|
||||
|
@ -44,42 +43,42 @@ public class ItMojo
|
|||
|
||||
/**
|
||||
* The path to the output file.
|
||||
*
|
||||
*
|
||||
* @parameter property="touch.outputFile" default-value="target/comp.properties"
|
||||
*/
|
||||
private File outputFile;
|
||||
|
||||
/**
|
||||
* Component lookup without role hint.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private Component componentWithoutRoleHint;
|
||||
|
||||
/**
|
||||
* Component lookup with explicit role hint.
|
||||
*
|
||||
*
|
||||
* @component roleHint="default"
|
||||
*/
|
||||
private Component componentWithRoleHint;
|
||||
|
||||
/**
|
||||
* Component lookup via active map.
|
||||
*
|
||||
*
|
||||
* @component role="org.apache.maven.plugin.coreit.Component"
|
||||
*/
|
||||
private Map componentMap;
|
||||
|
||||
/**
|
||||
* Component lookup via active list.
|
||||
*
|
||||
*
|
||||
* @component role="org.apache.maven.plugin.coreit.Component"
|
||||
*/
|
||||
private List componentList;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -104,15 +103,10 @@ public class ItMojo
|
|||
try
|
||||
{
|
||||
outputFile.getParentFile().mkdirs();
|
||||
FileOutputStream os = new FileOutputStream( outputFile );
|
||||
try
|
||||
try ( FileOutputStream os = new FileOutputStream( outputFile ) )
|
||||
{
|
||||
props.store( os, "MAVEN-CORE-IT-LOG" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -34,13 +34,12 @@ import java.util.Locale;
|
|||
|
||||
/**
|
||||
* Generates the available/configured reports.
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal generate
|
||||
* @phase site
|
||||
* @requiresReports true
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
*/
|
||||
public class GenerateMojo
|
||||
extends AbstractMojo
|
||||
|
@ -48,28 +47,28 @@ public class GenerateMojo
|
|||
|
||||
/**
|
||||
* The path to the output directory of the site.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${project.reporting.outputDirectory}"
|
||||
*/
|
||||
private File outputDirectory;
|
||||
|
||||
/**
|
||||
* The language for the reports.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="en"
|
||||
*/
|
||||
private String language = "en";
|
||||
|
||||
/**
|
||||
* A flag whether to ignore errors from reports and continue the generation.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="false"
|
||||
*/
|
||||
private boolean ignoreErrors;
|
||||
|
||||
/**
|
||||
* The reports configured for the current build.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${reports}"
|
||||
* @required
|
||||
* @readonly
|
||||
|
@ -78,7 +77,7 @@ public class GenerateMojo
|
|||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -99,11 +98,11 @@ public class GenerateMojo
|
|||
}
|
||||
|
||||
};
|
||||
Sink sink = (Sink) Proxy.newProxyInstance( getClass().getClassLoader(), new Class[] { Sink.class }, handler );
|
||||
Sink sink = (Sink) Proxy.newProxyInstance( getClass().getClassLoader(), new Class[]{ Sink.class }, handler );
|
||||
|
||||
for ( int i = 0; i < reports.size(); i++ )
|
||||
for ( Object report1 : reports )
|
||||
{
|
||||
MavenReport report = (MavenReport) reports.get( i );
|
||||
MavenReport report = (MavenReport) report1;
|
||||
|
||||
if ( report.canGenerateReport() )
|
||||
{
|
||||
|
|
|
@ -19,6 +19,12 @@ package org.apache.maven.plugin.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.toolchain.ToolchainManagerPrivate;
|
||||
import org.apache.maven.toolchain.ToolchainPrivate;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -29,12 +35,6 @@ import java.util.Arrays;
|
|||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.toolchain.ToolchainManagerPrivate;
|
||||
import org.apache.maven.toolchain.ToolchainPrivate;
|
||||
|
||||
/**
|
||||
* @goal toolchain
|
||||
* @phase validate
|
||||
|
@ -50,7 +50,7 @@ public class CoreItMojo
|
|||
|
||||
/**
|
||||
* The current Maven session holding the selected toolchain.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${session}"
|
||||
* @required
|
||||
* @readonly
|
||||
|
@ -59,28 +59,28 @@ public class CoreItMojo
|
|||
|
||||
/**
|
||||
* The path to the output file for the properties.
|
||||
*
|
||||
*
|
||||
* @parameter property="toolchain.outputFile" default-value="${project.build.directory}/toolchains.properties"
|
||||
*/
|
||||
private File outputFile;
|
||||
|
||||
/**
|
||||
* The type identifier of the toolchain, e.g. "jdk".
|
||||
*
|
||||
*
|
||||
* @parameter property="toolchain.type"
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* The name of the tool, e.g. "javac".
|
||||
*
|
||||
*
|
||||
* @parameter property="toolchain.tool"
|
||||
*/
|
||||
private String tool;
|
||||
|
||||
/**
|
||||
* The zero-based index of the toolchain to select and store in the build context.
|
||||
*
|
||||
*
|
||||
* @parameter property="toolchain.selected"
|
||||
*/
|
||||
private int selected;
|
||||
|
@ -101,8 +101,8 @@ public class CoreItMojo
|
|||
}
|
||||
else
|
||||
{
|
||||
getLog().warn( "[MAVEN-CORE-IT-LOG] Toolchain #" + selected + " can't be selected, found only "
|
||||
+ tcs.length );
|
||||
getLog().warn(
|
||||
"[MAVEN-CORE-IT-LOG] Toolchain #" + selected + " can't be selected, found only " + tcs.length );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,28 +157,20 @@ public class CoreItMojo
|
|||
try
|
||||
{
|
||||
// try 2.x style API
|
||||
Method oldMethod = managerClass.getMethod( "getToolchainsForType", new Class[] { String.class } );
|
||||
Method oldMethod = managerClass.getMethod( "getToolchainsForType", new Class[]{ String.class } );
|
||||
|
||||
return (ToolchainPrivate[]) oldMethod.invoke( toolchainManager, new Object[] { type } );
|
||||
return (ToolchainPrivate[]) oldMethod.invoke( toolchainManager, new Object[]{ type } );
|
||||
}
|
||||
catch ( NoSuchMethodException e )
|
||||
{
|
||||
// try 3.x style API
|
||||
Method newMethod =
|
||||
managerClass.getMethod( "getToolchainsForType", new Class[] { String.class, MavenSession.class } );
|
||||
managerClass.getMethod( "getToolchainsForType", new Class[]{ String.class, MavenSession.class } );
|
||||
|
||||
return (ToolchainPrivate[]) newMethod.invoke( toolchainManager, new Object[] { type, session } );
|
||||
return (ToolchainPrivate[]) newMethod.invoke( toolchainManager, new Object[]{ type, session } );
|
||||
}
|
||||
}
|
||||
catch ( NoSuchMethodException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Incompatible toolchain API", e );
|
||||
}
|
||||
catch ( IllegalAccessException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Incompatible toolchain API", e );
|
||||
}
|
||||
catch ( InvocationTargetException e )
|
||||
catch ( NoSuchMethodException | InvocationTargetException | IllegalAccessException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Incompatible toolchain API", e );
|
||||
}
|
||||
|
|
|
@ -33,12 +33,11 @@ import java.util.Properties;
|
|||
|
||||
/**
|
||||
* Dumps the authentication info registered with the wagon manager for a server to a properties file.
|
||||
*
|
||||
* @goal dump-auth
|
||||
* @phase validate
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal dump-auth
|
||||
* @phase validate
|
||||
*/
|
||||
public class DumpAuthMojo
|
||||
extends AbstractMojo
|
||||
|
@ -46,7 +45,7 @@ public class DumpAuthMojo
|
|||
|
||||
/**
|
||||
* Project base directory used for manual path alignment.
|
||||
*
|
||||
*
|
||||
* @parameter default-value="${basedir}"
|
||||
* @readonly
|
||||
*/
|
||||
|
@ -54,28 +53,28 @@ public class DumpAuthMojo
|
|||
|
||||
/**
|
||||
* The Wagon manager used to retrieve authentication infos.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private WagonManager wagonManager;
|
||||
|
||||
/**
|
||||
* The path to the properties file used to dump the auth infos.
|
||||
*
|
||||
*
|
||||
* @parameter property="wagon.propertiesFile"
|
||||
*/
|
||||
private File propertiesFile;
|
||||
|
||||
/**
|
||||
* The set of server identifiers whose auth infos should be dumped.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String[] serverIds;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoFailureException If the output file could not be created.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -83,9 +82,8 @@ public class DumpAuthMojo
|
|||
{
|
||||
Properties authProperties = new Properties();
|
||||
|
||||
for ( int i = 0; i < serverIds.length; i++ )
|
||||
for ( String serverId : serverIds )
|
||||
{
|
||||
String serverId = serverIds[i];
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Getting authentication info for server " + serverId );
|
||||
|
||||
AuthenticationInfo authInfo = wagonManager.getAuthenticationInfo( serverId );
|
||||
|
|
|
@ -37,12 +37,11 @@ import java.util.Properties;
|
|||
/**
|
||||
* Loads resources from a class loader used to load a wagon provider. The wagon is merely used to access the extension
|
||||
* class loader it came from which is otherwise not accessible to a plugin.
|
||||
*
|
||||
* @goal load-resource
|
||||
* @phase validate
|
||||
*
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @version $Id$
|
||||
* @goal load-resource
|
||||
* @phase validate
|
||||
*/
|
||||
public class LoadResourceMojo
|
||||
extends AbstractMojo
|
||||
|
@ -50,14 +49,14 @@ public class LoadResourceMojo
|
|||
|
||||
/**
|
||||
* The Wagon manager used to retrieve wagon providers.
|
||||
*
|
||||
*
|
||||
* @component
|
||||
*/
|
||||
private WagonManager wagonManager;
|
||||
|
||||
/**
|
||||
* The path to the properties file used to track the results of the resource loading via the wagon's class loader.
|
||||
*
|
||||
*
|
||||
* @parameter property="wagon.wagonClassLoaderOutput"
|
||||
*/
|
||||
private File wagonClassLoaderOutput;
|
||||
|
@ -65,14 +64,14 @@ public class LoadResourceMojo
|
|||
/**
|
||||
* The role hint for the wagon provider to load. The class loader of this provider will be used to load the
|
||||
* resources.
|
||||
*
|
||||
*
|
||||
* @parameter property="wagon.wagonProtocol"
|
||||
*/
|
||||
private String wagonProtocol;
|
||||
|
||||
/**
|
||||
* The repository to load the wagon for, if applicable.
|
||||
*
|
||||
*
|
||||
* @parameter property="wagon.repositoryId"
|
||||
*/
|
||||
private String repositoryId;
|
||||
|
@ -82,14 +81,14 @@ public class LoadResourceMojo
|
|||
* loaded, the generated properties files will contain a key named <code>ARP</code> whose value gives the URL to the
|
||||
* resource. In addition, the keys <code>ARP.count</code>, <code>ARP.0</code>, <code>ARP.1</code> etc. will
|
||||
* enumerate all URLs matching the resource name.
|
||||
*
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String[] resourcePaths;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
*
|
||||
* @throws MojoFailureException If the attached file has not been set.
|
||||
*/
|
||||
public void execute()
|
||||
|
@ -123,18 +122,17 @@ public class LoadResourceMojo
|
|||
|
||||
if ( resourcePaths != null )
|
||||
{
|
||||
for ( int i = 0; i < resourcePaths.length; i++ )
|
||||
for ( String path : resourcePaths )
|
||||
{
|
||||
String path = resourcePaths[i];
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Loading resource " + path );
|
||||
|
||||
|
||||
URL url = classLoader.getResource( path );
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Loaded resource from " + url );
|
||||
if ( url != null )
|
||||
{
|
||||
loaderProperties.setProperty( path, url.toString() );
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
List urls = Collections.list( classLoader.getResources( path ) );
|
||||
|
|
|
@ -19,15 +19,6 @@ package org.apache.maven.wagon.providers.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.wagon.AbstractWagon;
|
||||
import org.apache.maven.wagon.ConnectionException;
|
||||
import org.apache.maven.wagon.InputData;
|
||||
|
@ -38,6 +29,15 @@ import org.apache.maven.wagon.authentication.AuthenticationException;
|
|||
import org.apache.maven.wagon.authorization.AuthorizationException;
|
||||
import org.apache.maven.wagon.resource.Resource;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Shamelessly copied from ScpExternalWagon in this same project...
|
||||
*
|
||||
|
@ -63,8 +63,8 @@ public class CoreItHttpWagon
|
|||
|
||||
if ( is == null )
|
||||
{
|
||||
throw new TransferFailedException( getRepository().getUrl()
|
||||
+ " - Could not open input stream for resource: '" + resource + "'" );
|
||||
throw new TransferFailedException(
|
||||
getRepository().getUrl() + " - Could not open input stream for resource: '" + resource + "'" );
|
||||
}
|
||||
|
||||
createParentDirectories( destination );
|
||||
|
@ -95,8 +95,8 @@ public class CoreItHttpWagon
|
|||
|
||||
if ( os == null )
|
||||
{
|
||||
throw new TransferFailedException( getRepository().getUrl()
|
||||
+ " - Could not open output stream for resource: '" + resource + "'" );
|
||||
throw new TransferFailedException(
|
||||
getRepository().getUrl() + " - Could not open output stream for resource: '" + resource + "'" );
|
||||
}
|
||||
|
||||
putTransfer( outputData.getResource(), source, os, true );
|
||||
|
@ -153,16 +153,11 @@ public class CoreItHttpWagon
|
|||
try
|
||||
{
|
||||
new File( "target" ).mkdirs();
|
||||
|
||||
OutputStream os = new FileOutputStream( "target/wagon.properties" );
|
||||
try
|
||||
|
||||
try ( OutputStream os = new FileOutputStream( "target/wagon.properties" ) )
|
||||
{
|
||||
props.store( os, "MAVEN-CORE-IT-WAGON" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -19,15 +19,6 @@ package org.apache.maven.wagon.providers.coreit;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.wagon.AbstractWagon;
|
||||
import org.apache.maven.wagon.ConnectionException;
|
||||
import org.apache.maven.wagon.InputData;
|
||||
|
@ -39,6 +30,15 @@ import org.apache.maven.wagon.authentication.AuthenticationInfo;
|
|||
import org.apache.maven.wagon.authorization.AuthorizationException;
|
||||
import org.apache.maven.wagon.resource.Resource;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Shamelessly copied from ScpExternalWagon in this same project...
|
||||
*
|
||||
|
@ -64,8 +64,8 @@ public class CoreItWagon
|
|||
|
||||
if ( is == null )
|
||||
{
|
||||
throw new TransferFailedException( getRepository().getUrl()
|
||||
+ " - Could not open input stream for resource: '" + resource + "'" );
|
||||
throw new TransferFailedException(
|
||||
getRepository().getUrl() + " - Could not open input stream for resource: '" + resource + "'" );
|
||||
}
|
||||
|
||||
createParentDirectories( destination );
|
||||
|
@ -96,8 +96,8 @@ public class CoreItWagon
|
|||
|
||||
if ( os == null )
|
||||
{
|
||||
throw new TransferFailedException( getRepository().getUrl()
|
||||
+ " - Could not open output stream for resource: '" + resource + "'" );
|
||||
throw new TransferFailedException(
|
||||
getRepository().getUrl() + " - Could not open output stream for resource: '" + resource + "'" );
|
||||
}
|
||||
|
||||
putTransfer( outputData.getResource(), source, os, true );
|
||||
|
@ -164,16 +164,11 @@ public class CoreItWagon
|
|||
{
|
||||
File file = new File( "target/wagon.properties" ).getAbsoluteFile();
|
||||
file.getParentFile().mkdirs();
|
||||
|
||||
OutputStream os = new FileOutputStream( file );
|
||||
try
|
||||
|
||||
try ( OutputStream os = new FileOutputStream( file ) )
|
||||
{
|
||||
props.store( os, "MAVEN-CORE-IT-WAGON" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -19,15 +19,6 @@ package org.apache.maven.wagon.providers.ssh.external;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.wagon.AbstractWagon;
|
||||
import org.apache.maven.wagon.ConnectionException;
|
||||
import org.apache.maven.wagon.InputData;
|
||||
|
@ -38,10 +29,19 @@ import org.apache.maven.wagon.authentication.AuthenticationException;
|
|||
import org.apache.maven.wagon.authorization.AuthorizationException;
|
||||
import org.apache.maven.wagon.resource.Resource;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* NOTE: Plexus will only pick this correctly if the Class package and name are the same as that in core. This is
|
||||
* because the core component descriptor is read, but the class is read from the latter JAR.
|
||||
*
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="scpexe" instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class ScpExternalWagon
|
||||
|
@ -64,8 +64,8 @@ public class ScpExternalWagon
|
|||
|
||||
if ( is == null )
|
||||
{
|
||||
throw new TransferFailedException( getRepository().getUrl()
|
||||
+ " - Could not open input stream for resource: '" + resource + "'" );
|
||||
throw new TransferFailedException(
|
||||
getRepository().getUrl() + " - Could not open input stream for resource: '" + resource + "'" );
|
||||
}
|
||||
|
||||
createParentDirectories( destination );
|
||||
|
@ -98,8 +98,8 @@ public class ScpExternalWagon
|
|||
|
||||
if ( os == null )
|
||||
{
|
||||
throw new TransferFailedException( getRepository().getUrl()
|
||||
+ " - Could not open output stream for resource: '" + resource + "'" );
|
||||
throw new TransferFailedException(
|
||||
getRepository().getUrl() + " - Could not open output stream for resource: '" + resource + "'" );
|
||||
}
|
||||
|
||||
putTransfer( outputData.getResource(), source, os, true );
|
||||
|
@ -145,15 +145,10 @@ public class ScpExternalWagon
|
|||
|
||||
try
|
||||
{
|
||||
OutputStream os = new FileOutputStream( new File( dir, "wagon.properties" ) );
|
||||
try
|
||||
try ( OutputStream os = new FileOutputStream( new File( dir, "wagon.properties" ) ) )
|
||||
{
|
||||
props.store( os, "MAVEN-CORE-IT-WAGON" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.it;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||
|
@ -34,8 +35,6 @@ import java.util.Locale;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Jason van Zyl
|
||||
* @author Kenney Westerhof
|
||||
|
@ -58,7 +57,7 @@ public abstract class AbstractMavenIntegrationTestCase
|
|||
* The zero-based column index where to print the test result.
|
||||
*/
|
||||
private static final int RESULT_COLUMN = 60;
|
||||
|
||||
|
||||
private boolean skip;
|
||||
|
||||
private static ArtifactVersion javaVersion;
|
||||
|
@ -99,13 +98,13 @@ public abstract class AbstractMavenIntegrationTestCase
|
|||
else
|
||||
{
|
||||
out.println( "WARNING: " + getITName() + ": version range '" + versionRange
|
||||
+ "' supplied but no Maven version - not skipping test." );
|
||||
+ "' supplied but no Maven version - not skipping test." );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Java version used to run this test.
|
||||
*
|
||||
*
|
||||
* @return The Java version, never <code>null</code>.
|
||||
*/
|
||||
private ArtifactVersion getJavaVersion()
|
||||
|
@ -126,7 +125,7 @@ public abstract class AbstractMavenIntegrationTestCase
|
|||
|
||||
/**
|
||||
* Gets the Maven version used to run this test.
|
||||
*
|
||||
*
|
||||
* @return The Maven version or <code>null</code> if unknown.
|
||||
*/
|
||||
private ArtifactVersion getMavenVersion()
|
||||
|
@ -190,7 +189,7 @@ public abstract class AbstractMavenIntegrationTestCase
|
|||
else
|
||||
{
|
||||
out.println( "WARNING: " + getITName() + ": version range '" + versionRange
|
||||
+ "' supplied but no Maven version found - returning true for match check." );
|
||||
+ "' supplied but no Maven version found - returning true for match check." );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -243,9 +242,9 @@ public abstract class AbstractMavenIntegrationTestCase
|
|||
* Guards the execution of a test case by checking that the current Java version matches the specified version
|
||||
* range. If the check fails, an exception will be thrown which aborts the current test and marks it as skipped. One
|
||||
* would usually call this method right at the start of a test method.
|
||||
*
|
||||
*
|
||||
* @param versionRange The version range that specifies the acceptable Java versions for the test, must not be
|
||||
* <code>null</code>.
|
||||
* <code>null</code>.
|
||||
*/
|
||||
protected void requiresJavaVersion( String versionRange )
|
||||
{
|
||||
|
@ -270,9 +269,9 @@ public abstract class AbstractMavenIntegrationTestCase
|
|||
* Guards the execution of a test case by checking that the current Maven version matches the specified version
|
||||
* range. If the check fails, an exception will be thrown which aborts the current test and marks it as skipped. One
|
||||
* would usually call this method right at the start of a test method.
|
||||
*
|
||||
*
|
||||
* @param versionRange The version range that specifies the acceptable Maven versions for the test, must not be
|
||||
* <code>null</code>.
|
||||
* <code>null</code>.
|
||||
*/
|
||||
protected void requiresMavenVersion( String versionRange )
|
||||
{
|
||||
|
@ -297,7 +296,7 @@ public abstract class AbstractMavenIntegrationTestCase
|
|||
else
|
||||
{
|
||||
out.println( "WARNING: " + getITName() + ": version range '" + versionRange
|
||||
+ "' supplied but no Maven version found - not skipping test." );
|
||||
+ "' supplied but no Maven version found - not skipping test." );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -358,7 +357,7 @@ public abstract class AbstractMavenIntegrationTestCase
|
|||
|
||||
private String pad( int chars )
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer( 128 );
|
||||
StringBuilder buffer = new StringBuilder( 128 );
|
||||
for ( int i = 0; i < chars; i++ )
|
||||
{
|
||||
buffer.append( '.' );
|
||||
|
@ -449,7 +448,7 @@ public abstract class AbstractMavenIntegrationTestCase
|
|||
// Make is easier to run ITs from m2e in Maven IT mode without having to set any additional
|
||||
// properties.
|
||||
//
|
||||
settingsFile = new File( "target/test-classes", settingsFile.getPath() );
|
||||
settingsFile = new File( "target/test-classes", settingsFile.getPath() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue