mirror of https://github.com/apache/maven.git
o Removed the parsing of ~/.m2/pom.xml using unix tools to extract the local repo
o Added the ability to specify -Dmaven.repo.local=xxx to the it shell script, and the Verifier class o Added to the Verifier class the ability to parse ~/.m2/pom.xml and retrieve the local repo location in the event ${maven.repo.local} is unspecified git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163029 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
528863b613
commit
984d4644ef
|
@ -11,36 +11,47 @@ import java.util.Properties;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.xml.utils.DOMBuilder;
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Verifier
|
||||
{
|
||||
private String basedir;
|
||||
|
||||
private String mavenRepoLocal;
|
||||
private File homeDir;
|
||||
|
||||
public Verifier( String basedir, String mavenRepoLocal )
|
||||
private String localRepo;
|
||||
|
||||
public Verifier( String basedir, String homeDir )
|
||||
{
|
||||
this.basedir = basedir;
|
||||
this.mavenRepoLocal = mavenRepoLocal;
|
||||
this.homeDir = new File( homeDir );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public void verify()
|
||||
throws VerificationException
|
||||
public void verify() throws VerificationException
|
||||
{
|
||||
try
|
||||
{
|
||||
retrieveLocalRepo();
|
||||
|
||||
BufferedReader reader = new BufferedReader( new FileReader( new File( basedir, "expected-results.txt" ) ) );
|
||||
|
||||
String line = "";
|
||||
|
||||
while ( ( line = reader.readLine() ) != null )
|
||||
while ( (line = reader.readLine()) != null )
|
||||
{
|
||||
verifyExpectedResult( line );
|
||||
}
|
||||
|
@ -50,13 +61,28 @@ public class Verifier
|
|||
throw new VerificationException( e );
|
||||
}
|
||||
|
||||
System.out.println( "-----------------------------------------------------------------------------------> OK" );
|
||||
System.out.println( "-----------------------------------------------------------------------------------> OK" );
|
||||
}
|
||||
|
||||
private void verifyExpectedResult( String line )
|
||||
throws VerificationException
|
||||
private void retrieveLocalRepo() throws Exception
|
||||
{
|
||||
line = replace( line, "${localRepository}", mavenRepoLocal );
|
||||
localRepo = System.getProperty( "maven.repo.local" );
|
||||
if ( localRepo == null )
|
||||
{
|
||||
// parse ~/.m2/pom.xml for it...
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
File pom = new File( homeDir, ".m2/pom.xml" );
|
||||
Document dom = builder.parse( pom );
|
||||
|
||||
localRepo = XPathAPI.selectSingleNode( dom, "/project/local/repository/text()" ).getNodeValue();
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyExpectedResult( String line ) throws VerificationException
|
||||
{
|
||||
line = replace( line, "${localRepository}", localRepo );
|
||||
|
||||
if ( line.indexOf( "!/" ) > 0 )
|
||||
{
|
||||
|
@ -128,7 +154,7 @@ public class Verifier
|
|||
|
||||
StringBuffer buf = new StringBuffer( text.length() );
|
||||
int start = 0, end = 0;
|
||||
while ( ( end = text.indexOf( repl, start ) ) != -1 )
|
||||
while ( (end = text.indexOf( repl, start )) != -1 )
|
||||
{
|
||||
buf.append( text.substring( start, end ) ).append( with );
|
||||
start = end + repl.length();
|
||||
|
@ -142,7 +168,6 @@ public class Verifier
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -164,4 +189,4 @@ public class Verifier
|
|||
|
||||
System.exit( 0 );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,8 +10,8 @@ verifier=org.apache.maven.it.Verifier
|
|||
|
||||
integration_tests=`cat integration-tests.txt | egrep -v '^#'`
|
||||
|
||||
# TODO: this is rubbish. Let's rewrite this in java
|
||||
local_repo=`cat $HOME/.m2/pom.xml | tr '\n' ' ' | sed 's/^.*<local> *<repository>//' | sed 's#</repository> *</local>.*$##'`
|
||||
#If this doesn't have a value, we'll parse $HOME/.m2/pom.xml in the Verifier.
|
||||
local_repo=
|
||||
|
||||
for i in "$@"
|
||||
do
|
||||
|
@ -33,7 +33,13 @@ do
|
|||
echo
|
||||
fi
|
||||
|
||||
m2 -Dmaven.repo.local="$local_repo" clean:clean `cat goals.txt`
|
||||
jvm_opts=
|
||||
if [ "$local_repo" != "" ]
|
||||
then
|
||||
jvm_opts="-Dmaven.repo.local=$local_repo"
|
||||
fi
|
||||
|
||||
m2 $jvm_opts clean:clean `cat goals.txt`
|
||||
|
||||
if [ -f postbuild.hook ]
|
||||
then
|
||||
|
@ -44,7 +50,8 @@ do
|
|||
|
||||
basedir=.
|
||||
|
||||
java -cp "$cp" $verifier "$basedir" "$local_repo"
|
||||
java $jvm_opts -cp "$cp" $verifier "$basedir" "$HOME"
|
||||
|
||||
) > ${integration_test}-log.txt
|
||||
|
||||
if [ "$?" = "0" ]
|
||||
|
|
Loading…
Reference in New Issue