o doing the pom.xml thing

PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162739 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2004-06-09 03:10:50 +00:00
parent 62659b716c
commit 60af082ea2
17 changed files with 74 additions and 51 deletions

View File

@ -6,6 +6,8 @@
# @author <a href="mailto:emmanuel@venisse.net">Emmanuel Venisse</a>
# -----------------------------------------------------------------------------
POM=pom.xml
downloadMBootDependencies()
{
findAndSetMavenRepoLocal
@ -189,16 +191,16 @@ buildMavenProject()
fi
# Look for source directory in project.xml
sourceDirectory=`grep sourceDirectory project.xml | sed -e 's/^*//;s/<sourceDirectory>//;s/<\/sourceDirectory>//;s/\${basedir}\///'`
# Look for source directory in pom.xml
sourceDirectory=`grep sourceDirectory ${POM} | sed -e 's/^*//;s/<sourceDirectory>//;s/<\/sourceDirectory>//;s/\${basedir}\///'`
[ -z $sourceDirectory ] && sourceDirectory=src/main/java
buildDir=target
buildDest=target/classes
# Look for unit test source directory in project.xml
unitTestSourceDirectory=`grep unitTestSourceDirectory project.xml | sed -e 's/^*//;s/<unitTestSourceDirectory>//;s/<\/unitTestSourceDirectory>//;s/\${basedir}\///'`
# Look for unit test source directory in pom.xml
unitTestSourceDirectory=`grep unitTestSourceDirectory ${POM} | sed -e 's/^*//;s/<unitTestSourceDirectory>//;s/<\/unitTestSourceDirectory>//;s/\${basedir}\///'`
[ -z $unitTestSourceDirectory ] && unitTestSourceDirectory=src/test/java
@ -259,7 +261,7 @@ buildMavenProject()
if [ "$2" = "default" ]
then
jarName=`getJarName project.xml`
jarName=`getJarName ${POM}`
else
jarName=$2
fi
@ -306,7 +308,7 @@ installPom()
groupId=`getGroupId`
pomName=`getPomName project.xml`
pomName=`getPomName ${POM}`
dir=${repoLocal}/${groupId}/poms
@ -314,12 +316,12 @@ installPom()
mkdir -p ${dir}
cp project.xml ${dir}/${pomName}
cp ${POM} ${dir}/${pomName}
}
getJarName()
{
# $1 == project.xml
# $1 == pom.xml
version=`cat $1 | tr '\n' ' ' | sed 's#<versions>.*</versions>##' | sed 's#<dependencies>.*</dependencies>##' | grep '<version>' | sed -e 's#^.*<version>##;s#</version>.*$##'`
@ -364,7 +366,7 @@ getPomName()
getGroupId()
{
groupId=`cat project.xml | tr '\n' ' ' | sed 's#<dependencies>.*</dependencies>##' | grep '<groupId>' | sed -e 's#^.*<groupId>##;s#</groupId>.*$##'`
groupId=`cat ${POM} | tr '\n' ' ' | sed 's#<dependencies>.*</dependencies>##' | grep '<groupId>' | sed -e 's#^.*<groupId>##;s#</groupId>.*$##'`
echo $groupId
}

View File

@ -2,6 +2,8 @@
VERSION=1.0
POM=pom.xml
usage ()
{
echo "usage: `basename $0` [--dir=<directory>] [--jar=<name>] [--install] [--pom-install] [-v] [--leave-boot-files] [--version] [--help]" >&2
@ -64,6 +66,6 @@ export MBOOT_HOME=`dirname $0`
[ ! -d $dir ] && echo "Specified directory doesn't exist!" && exit
[ ! -f $dir/project.xml ] && echo "No project.xml in specified directory!" && exit
[ ! -f $dir/${POM} ] && echo "No ${POM} in specified directory!" && exit
buildMavenProject $dir $jar $install $pomInstall $leaveBootFiles

View File

@ -51,9 +51,9 @@ public void execute( String[] args )
bootstrapPomParser = new BootstrapPomParser();
if( ! bootstrapPomParser.parse( new File( "project.xml" ) ) )
if( ! bootstrapPomParser.parse( new File( "pom.xml" ) ) )
{
System.err.println( "Could not parse project.xml" );
System.err.println( "Could not parse pom.xml" );
System.exit( 1 );
}
@ -520,7 +520,7 @@ public void endElement( String uri, String localName, String rawName )
BootstrapPomParser p = new BootstrapPomParser();
if ( ! p.parse( f ) )
throw new SAXException( "Could not parse parent project.xml" );
throw new SAXException( "Could not parse parent pom.xml" );
dependencies.addAll( p.getDependencies() );

21
maven-meeper/pom.xml Normal file
View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<parent>
<groupId>maven</groupId>
<artifactId>maven-component</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<name>Maven Meper</name>
<groupId>maven</groupId>
<artifactId>maven-meeper</artifactId>
<version>0.1-SNAPSHOT</version>
<description></description>
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -1,10 +1,7 @@
#!/bin/sh
# Deploy JAR to the repository
# $1 : artifact to copy
# $2 : project id
BUNDLE=$1
VERSION=$2
[ "${BUNDLE}" = "" ] && echo && echo "You must specify a bundle!" && echo && exit
@ -27,11 +24,16 @@ cp $BUNDLE $WORKDIR
[ ! -f ${POM} ] && echo && echo "Cannot deploy without the project.xml file!" && echo && exit
version=`cat ${POM} | tr '\n' ' ' | sed 's#<versions>.*</versions>##' | sed 's#<dependencies>.*</dependencies>##' | grep '<version>' | sed -e 's#^.*<version>##;s#</version>.*$##'`
if [ -z $version ]
if [ ! -z $VERSION ]
then
version=`grep currentVersion ${POM} | sed -e 's/^ *//;s/<currentVersion>//;s/<\/currentVersion>//'`
version=$VERSION
else
version=`cat ${POM} | tr '\n' ' ' | sed 's#<versions>.*</versions>##' | sed 's#<dependencies>.*</dependencies>##' | grep '<version>' | sed -e 's#^.*<version>##;s#</version>.*$##'`
if [ -z $version ]
then
version=`grep currentVersion ${POM} | sed -e 's/^ *//;s/<currentVersion>//;s/<\/currentVersion>//'`
fi
fi
artifactId=`cat ${POM} | tr '\n' ' ' | sed 's#<dependencies>.*</dependencies>##' | grep '<artifactId>' | sed -e 's#^.*<artifactId>##;s#</artifactId>.*$##'`

View File

@ -19,19 +19,16 @@
import java.io.File;
/**
* @author <a href="mailto:evenisse@maven.org">Emmanuel Venisse</a>
* @version $Id$
* @maven.plugin.id clean
* @maven.plugin.description A maven2 plugin which cleans the build
*
* @parameter failedOnError String true validator description
* @parameter outputDirectory String true validator description
*
* @goal.name clean
* @goal.clean.description Goal which cleans the build
* @goal.clean.parameter failedOnError false
* @goal.clean.parameter outputDirectory #maven.build.dir
*
* @author <a href="mailto:evenisse@maven.org">Emmanuel Venisse</a>
* @version $Id$
*/
public class CleanPlugin
extends AbstractPlugin
@ -40,23 +37,22 @@ public class CleanPlugin
private String outputDirectory;
private boolean failedOnError;
private boolean failedOnError;
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
throws Exception
{
outputDirectory = (String) request.getParameter( "outputDirectory" );
failedOnError = Boolean.valueOf(
(String)request.getParameter( "failedOnError" )).booleanValue();
failedOnError = Boolean.valueOf( (String) request.getParameter( "failedOnError" ) ).booleanValue();
if ( outputDirectory != null )
{
File dir = new File( outputDirectory );
if ( dir.exists() && dir.isDirectory() )
{
log("Deleting directory " + dir.getAbsolutePath());
log( "Deleting directory " + dir.getAbsolutePath() );
removeDir( dir );
}
}
@ -67,20 +63,20 @@ public void execute( PluginExecutionRequest request, PluginExecutionResponse res
* Others possible. If the delete does not work, call System.gc(),
* wait a little and try again.
*/
private boolean delete(File f)
private boolean delete( File f )
{
if (!f.delete())
if ( !f.delete() )
{
if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1)
if ( System.getProperty( "os.name" ).toLowerCase().indexOf( "windows" ) > -1 )
{
System.gc();
}
try
{
Thread.sleep(DELETE_RETRY_SLEEP_MILLIS);
Thread.sleep( DELETE_RETRY_SLEEP_MILLIS );
return f.delete();
}
catch (InterruptedException ex)
catch ( InterruptedException ex )
{
return f.delete();
}
@ -93,55 +89,55 @@ private boolean delete(File f)
*
* @param d the directory to delete
*/
protected void removeDir(File d) throws Exception
protected void removeDir( File d ) throws Exception
{
String[] list = d.list();
if (list == null)
if ( list == null )
{
list = new String[0];
}
for (int i = 0; i < list.length; i++)
for ( int i = 0; i < list.length; i++ )
{
String s = list[i];
File f = new File(d, s);
if (f.isDirectory())
File f = new File( d, s );
if ( f.isDirectory() )
{
removeDir(f);
removeDir( f );
}
else
{
//log("Deleting " + f.getAbsolutePath());
if (!delete(f))
if ( !delete( f ) )
{
String message = "Unable to delete file "
+ f.getAbsolutePath();
if (failedOnError)
if ( failedOnError )
{
throw new Exception(message);
throw new Exception( message );
}
else
{
log(message);
log( message );
}
}
}
}
//log("Deleting directory " + d.getAbsolutePath());
if (!delete(d))
if ( !delete( d ) )
{
String message = "Unable to delete directory "
+ d.getAbsolutePath();
if (failedOnError)
if ( failedOnError )
{
throw new Exception(message);
throw new Exception( message );
}
else
{
log(message);
log( message );
}
}
}
private void log( String message )
{
System.out.println( message );