Hi,
I had an error using mvn release:prepare after I had created a
src/main/conf directory under SubVersion, then renamed it
src/main/config to match the Maven 2 convention. I'm not sure if I'm not
following a Maven or SubVersion convention, or if this is a bug.
The workaround, noted in the following perl script loses the revision
history. The rest of this post is a perl script to replicate the problem
for a unix-like system. The header comment provides a number of details.
(I'm hoping line wrap doesn't mess this up ;-) Run this script in clean
disposable directory.
If anyone has a suggestion on avoiding the error, please post.
Thanks,
Ken
=== start of testMvnRelease.pl ===
#!/usr/bin/perl -w
##
## File: testMvnRelease.pl
##
## I had an error using mvn release:prepare after I had
## created a src/main/conf directory under SubVersion,
## then renamed it src/main/config to match the Maven 2
## convention. I'm not sure if I'm not following a Maven
## or SubVersion convention, or if this is a bug.
##
## I'm seeing this error:
##
## [INFO]
------------------------------------------------------------------------
## [ERROR] BUILD FAILURE
## [INFO]
------------------------------------------------------------------------
## [INFO] Unable to tag SCM
## Provider message:
## The svn tag command failed.
## Command output:
## svn: Commit failed (details follow):
## svn: Directory
'/extra/data/src/java/testMvnRelease/myProject/trunk/target/.svn'
## containing working copy admin area is missing
##
## My workaround was to create a copy of the project,
## wipe out all the revision history (.svn directories),
## and enter it into SubVersion as a new project as if the
## configuration directory had been named src/main/config
## from the start. Is there a better way to correct this
## category of error without losing the revision history?
##
## This script is a self-contained way to explore reproducing
## this behavior. There's a lot of setup, so I wanted to make
## it easy for others to see what I'm doing.
##
## Versions: Maven version: 2.0.9
## Java version: 1.6.0_03
## OS name: "linux" version: "2.6.18-92.1.10.el5" arch: "amd64"
Family: "unix"
## svn, version 1.4.2 (r22196)
##
## For reference I'm going by:
## http://maven.apache.org/plugins/maven-release-plugin/
##
## Summary of the standard Maven directory layout:
## myProject
## +- trunk
## +- src
## +- main
## +- config <-- area of concern
## +- java
##
## If you don't have perl, but are using a unix-like system,
## then the commands between backticks can be executed on the comand
## line. For this reason I've mimmicked the command line, e.g. using
## the system "rm" rather than the perl built-in "unlink" command.
## The chdir commands are used in Perl since the 'cd' commands
## would otherwise be transient. To excecute outside Perl, the "chdir"
## commands should be converted as
## chdir 'aProject' --> cd aProject
## Cleanup code for subsequent runs.
## Not needed the first time through.
if (-e 'aProject') {
## existing directory is removed recursively (-r)
print `rm -r aProject`;
}
if (-e 'myProject') {
## use force (-f) option to override any svn permissions
print `rm -rf myProject`;
}
if (-e '/tmp/repos') {
print `rm -rf /tmp/repos`;
}
## Create the standard maven project
print "Create a maven project\n";
print `mkdir aProject`;
chdir 'aProject';
print `mvn archetype:create -DgroupId=com.mycompany.app
-DartifactId=my-app`;
## There should be no errors. Compile and run to test.
## The following commands should work
chdir 'my-app';
print `mvn package`;
print `java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App`;
## Standard project prints "Hello World!" Pause 3 seconds to see result
print `sleep 3`;
## create a directory with wrong name "conf", then correct it later
print `mkdir src/main/conf`;
## create a config file
open CONF, ">src/main/conf/myconf.xml"
or die "couldn't create config file\n";
print CONF '<?xml version="1.0" encoding="UTF-8"?>
<myconf>
<element attr="a" />
</myconf>
';
close CONF;
## Add project to SubVersion version control
## Go back up two directory levels
chdir '../..';
## change my-app to trunk (a subversion convention)
print `mv aProject/my-app aProject/trunk`;
## create a new (disposable) repository on local disk
print `svnadmin create /tmp/repos`;
## Put aProject under version control as myProject
print `svn import aProject file:///tmp/repos/myProject -m "initial import"`;
## Now pull out a version-controlled copy of the project: myProject
## (aProject is not needed and ignored from now on)
print `svn checkout file:///tmp/repos/myProject myProject`;
## Change src/main/conf to src/main/config to match the standard
## maven directory naming convention
chdir 'myProject/trunk';
print `svn move src/main/conf src/main/config`;
print `svn status`;
print `svn commit -m "comply with mvn convention, conf renamed to config"`;
## Add scm information to pom.xml -- required for release plugin
open POM, "pom.xml" or die "Couldn't open pom.xml for reading";
@pomlines = <POM>; ## Read the whole file.
close POM;
## Write a new pom.xml
open POM, ">pom.xml" or die "Couldn't open pom.xml for modification";
foreach $line (@pomlines) {
print POM $line;
## if this is the "url" line, add the scm info right after it
if ($line =~ m!</url>!) {
## Without Perl you would add the following with a text editor
## after the "<url>...</url>" section.
print POM ' <scm>
<connection>scm:svn:file:///tmp/repos/myProject/trunk</connection>
<developerConnection>scm:svn:file:///tmp/repos/myProject/trunk</developerConnection>
</scm>
';
}
}
close POM;
## commit change to pom.xml
print `svn commit -m "added scm to pom.xml"`;
## Now we are set up to see the mvn release:prepare error
print "#####" x 10;
print "\nChange directory to myProject/trunk and interactively issue
the 'mvn release:prepare' command (press return to accept defaults).
Use the following two commands:
cd myProject/trunk
mvn release:prepare\n";
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]