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,6 +11,14 @@ import java.util.Properties;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
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$
|
* @version $Id$
|
||||||
|
@ -19,23 +27,26 @@ public class Verifier
|
||||||
{
|
{
|
||||||
private String basedir;
|
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.basedir = basedir;
|
||||||
this.mavenRepoLocal = mavenRepoLocal;
|
this.homeDir = new File( homeDir );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public void verify()
|
public void verify() throws VerificationException
|
||||||
throws VerificationException
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
retrieveLocalRepo();
|
||||||
|
|
||||||
BufferedReader reader = new BufferedReader( new FileReader( new File( basedir, "expected-results.txt" ) ) );
|
BufferedReader reader = new BufferedReader( new FileReader( new File( basedir, "expected-results.txt" ) ) );
|
||||||
|
|
||||||
String line = "";
|
String line = "";
|
||||||
|
@ -53,10 +64,25 @@ public class Verifier
|
||||||
System.out.println( "-----------------------------------------------------------------------------------> OK" );
|
System.out.println( "-----------------------------------------------------------------------------------> OK" );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyExpectedResult( String line )
|
private void retrieveLocalRepo() throws Exception
|
||||||
throws VerificationException
|
|
||||||
{
|
{
|
||||||
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 )
|
if ( line.indexOf( "!/" ) > 0 )
|
||||||
{
|
{
|
||||||
|
@ -142,7 +168,6 @@ public class Verifier
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
|
@ -10,8 +10,8 @@ verifier=org.apache.maven.it.Verifier
|
||||||
|
|
||||||
integration_tests=`cat integration-tests.txt | egrep -v '^#'`
|
integration_tests=`cat integration-tests.txt | egrep -v '^#'`
|
||||||
|
|
||||||
# TODO: this is rubbish. Let's rewrite this in java
|
#If this doesn't have a value, we'll parse $HOME/.m2/pom.xml in the Verifier.
|
||||||
local_repo=`cat $HOME/.m2/pom.xml | tr '\n' ' ' | sed 's/^.*<local> *<repository>//' | sed 's#</repository> *</local>.*$##'`
|
local_repo=
|
||||||
|
|
||||||
for i in "$@"
|
for i in "$@"
|
||||||
do
|
do
|
||||||
|
@ -33,7 +33,13 @@ do
|
||||||
echo
|
echo
|
||||||
fi
|
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 ]
|
if [ -f postbuild.hook ]
|
||||||
then
|
then
|
||||||
|
@ -44,7 +50,8 @@ do
|
||||||
|
|
||||||
basedir=.
|
basedir=.
|
||||||
|
|
||||||
java -cp "$cp" $verifier "$basedir" "$local_repo"
|
java $jvm_opts -cp "$cp" $verifier "$basedir" "$HOME"
|
||||||
|
|
||||||
) > ${integration_test}-log.txt
|
) > ${integration_test}-log.txt
|
||||||
|
|
||||||
if [ "$?" = "0" ]
|
if [ "$?" = "0" ]
|
||||||
|
|
Loading…
Reference in New Issue