Add POM configuration aliases for command-line settings
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@616159 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java
index 3e017a2..0a3f9ec 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java
@@ -39,14 +39,14 @@
/**
- * deploy the bundle to a remote site.
- * this goal is used when you compile a project with a pom file
+ * Deploy bundle metadata to remote OBR.
+ *
* @goal deploy
* @phase deploy
* @requiresDependencyResolution compile
+ *
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
-
public class ObrDeploy extends AbstractMojo
{
/**
@@ -60,7 +60,7 @@
/**
* name of the repository xml descriptor file.
*
- * @parameter expression="${repository-name}" default-value="repository.xml"
+ * @parameter expression="${repository-name}" default-value="repository.xml" alias="repository-name"
*/
private String m_repositoryName;
@@ -90,7 +90,7 @@
/**
* When true, ignore remote locking.
*
- * @parameter expression="${ignore-lock}"
+ * @parameter expression="${ignore-lock}" alias="ignore-lock"
*/
private boolean m_ignoreLock;
@@ -134,32 +134,7 @@
throw new MojoFailureException( "IOException" );
}
- if ( m_ignoreLock )
- {
- try
- {
- remoteFile.put( lockFile, m_repositoryName + ".lock" );
- }
- catch ( TransferFailedException e )
- {
- getLog().error( "Transfer failed" );
- e.printStackTrace();
- throw new MojoFailureException( "TransferFailedException" );
-
- }
- catch ( ResourceDoesNotExistException e )
- {
- throw new MojoFailureException( "ResourceDoesNotExistException" );
- }
- catch ( AuthorizationException e )
- {
- getLog().error( "Authorization failed" );
- e.printStackTrace();
- throw new MojoFailureException( "AuthorizationException" );
- }
-
- }
- else
+ if ( !m_ignoreLock )
{
int countError = 0;
while ( remoteFile.isLockedFile( remoteFile, m_repositoryName ) && countError < 2 )
@@ -172,22 +147,23 @@
}
catch ( InterruptedException e )
{
- getLog().warn( "Sleep interupted" );
+ getLog().warn( "Sleep interrupted" );
}
}
if ( countError == 2 )
{
getLog().error(
- "File: " + m_repositoryName + " is locked. Try -Dignore-lock=true if you want force uploading" );
+ "File: " + m_repositoryName + " is locked. Try -Dignore-lock=true if you want to force uploading" );
throw new MojoFailureException( "fileLocked" );
}
}
- // file is not locked, so we lock it now
try
{
+ // file is not locked, so we lock it now
remoteFile.put( lockFile, m_repositoryName + ".lock" );
+ lockFile.delete();
}
catch ( TransferFailedException e )
{
@@ -273,7 +249,6 @@
throw new MojoFailureException( "AuthorizationException" );
}
repoDescriptorFile.delete();
- lockFile.delete();
// we remove lockFile activation
lockFile = null;
@@ -289,6 +264,7 @@
try
{
remoteFile.put( lockFile, m_repositoryName + ".lock" );
+ lockFile.delete();
}
catch ( TransferFailedException e )
{
@@ -309,6 +285,5 @@
}
remoteFile.disconnect();
- lockFile.delete();
}
}
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java
index 88de437..4c7daf7 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java
@@ -39,10 +39,11 @@
/**
- * deploy the bundle to a ftp site.
- * this goal is used when you upload a jar file (in command line)
+ * Deploy bundle metadata to remote OBR (command-line goal).
+ *
* @goal deploy-file
* @phase deploy
+ *
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class ObrDeployFile extends AbstractMojo
@@ -58,7 +59,7 @@
/**
* name of the repository xml descriptor file.
*
- * @parameter expression="${repository-name}" default-value="repository.xml"
+ * @parameter expression="${repository-name}" default-value="repository.xml" alias="repository-name"
*/
private String m_repositoryName;
@@ -88,7 +89,7 @@
/**
* obr file define by the user.
*
- * @parameter expression="${obr-file}"
+ * @parameter expression="${obr-file}" alias="obr-file"
*
*/
private String m_obrFile;
@@ -96,7 +97,7 @@
/**
* When true, ignore remote locking.
*
- * @parameter expression="${ignore-lock}"
+ * @parameter expression="${ignore-lock}" alias="ignore-lock"
*/
private boolean m_ignoreLock;
@@ -120,8 +121,8 @@
File repoDescriptorFile = null;
+ // init the wagon connection
RemoteFileManager remoteFile = new RemoteFileManager( ar, m_wagonManager, m_settings, getLog() );
-
remoteFile.connect();
// create a non-empty file used to lock the repository descriptor file
@@ -140,32 +141,7 @@
throw new MojoFailureException( "IOException" );
}
- if ( m_ignoreLock )
- {
- try
- {
- remoteFile.put( lockFile, m_repositoryName + ".lock" );
- }
- catch ( TransferFailedException e )
- {
- getLog().error( "Transfer failed" );
- e.printStackTrace();
- throw new MojoFailureException( "TransferFailedException" );
-
- }
- catch ( ResourceDoesNotExistException e )
- {
- throw new MojoFailureException( "ResourceDoesNotExistException" );
- }
- catch ( AuthorizationException e )
- {
- getLog().error( "Authorization failed" );
- e.printStackTrace();
- throw new MojoFailureException( "AuthorizationException" );
- }
-
- }
- else
+ if ( !m_ignoreLock )
{
int countError = 0;
while ( remoteFile.isLockedFile( remoteFile, m_repositoryName ) && countError < 2 )
@@ -178,7 +154,7 @@
}
catch ( InterruptedException e )
{
- getLog().warn( "Sleep Interupted" );
+ getLog().warn( "Sleep interrupted" );
}
}
@@ -190,10 +166,11 @@
}
}
- // file is not locked, so we lock it now
try
{
+ // file is not locked, so we lock it now
remoteFile.put( lockFile, m_repositoryName + ".lock" );
+ lockFile.delete();
}
catch ( TransferFailedException e )
{
@@ -279,7 +256,6 @@
throw new MojoFailureException( "AuthorizationException" );
}
repoDescriptorFile.delete();
- lockFile.delete();
// we remove lockFile activation
lockFile = null;
@@ -295,6 +271,7 @@
try
{
remoteFile.put( lockFile, m_repositoryName + ".lock" );
+ lockFile.delete();
}
catch ( TransferFailedException e )
{
@@ -313,7 +290,7 @@
e.printStackTrace();
throw new MojoFailureException( "AuthorizationException" );
}
+
remoteFile.disconnect();
- lockFile.delete();
}
}
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstall.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstall.java
index 94ec296..10f6e51 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstall.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstall.java
@@ -29,11 +29,12 @@
/**
- * construct the repository.xml with a project Maven compiled
- *
+ * Install bundle metadata to local OBR.
+ *
* @goal install
* @phase install
* @requiresDependencyResolution compile
+ *
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class ObrInstall extends AbstractMojo
@@ -50,7 +51,7 @@
/**
* path to the repository.xml.
*
- * @parameter expression="${repository-path}"
+ * @parameter expression="${repository-path}" alias="repository-path"
*/
private String m_repositoryPath;
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstallFile.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstallFile.java
index 4811db9..09f9c2e 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstallFile.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstallFile.java
@@ -27,16 +27,16 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
/**
- * construct the repository.xml from a compiled bundle.
- * @description construct the repository.xml from a compiled bundle.
+ * Install bundle metadata to local OBR (command-line goal).
+ *
* @goal install-file
* @requiresProject false
* @phase install
+ *
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class ObrInstallFile extends AbstractMojo
@@ -60,7 +60,7 @@
/**
* path to the repository.xml.
*
- * @parameter expression="${repository-path}"
+ * @parameter expression="${repository-path}" alias="repository-path"
*/
private String m_repositoryPath;
@@ -95,29 +95,23 @@
/**
* OBR File.
* @description obr file define by the user
- * @parameter expression="${obr-file}"
+ * @parameter expression="${obr-file}" alias="obr-file"
*/
private String m_obrFile;
- /**
- * store user information in a project.
- */
- private MavenProject m_project;
-
/**
* main method for this goal.
* @implements org.apache.maven.plugin.Mojo.execute
* @throws MojoExecutionException if the plugin failed
- * @throws MojoFailureException if the plugin failed
*/
- public void execute() throws MojoExecutionException, MojoFailureException
+ public void execute() throws MojoExecutionException
{
- m_project = new MavenProject();
- m_project.setArtifactId( m_artifactId );
- m_project.setGroupId( m_groupId );
- m_project.setVersion( m_version );
- m_project.setPackaging( m_packaging );
+ MavenProject project = new MavenProject();
+ project.setArtifactId( m_artifactId );
+ project.setGroupId( m_groupId );
+ project.setVersion( m_version );
+ project.setPackaging( m_packaging );
if ( m_groupId == null )
{
@@ -157,14 +151,14 @@
if ( !new File( bundleJar ).exists() )
{
- getLog().error( "file doesn't exist: " + bundleJar );
+ getLog().error( "file not found in local repository: " + bundleJar );
return;
}
// use default configuration
Config userConfig = new Config();
- ObrUpdate update = new ObrUpdate( repoXml, obrXml, m_project, bundleJar, null, userConfig, getLog() );
+ ObrUpdate update = new ObrUpdate( repoXml, obrXml, project, bundleJar, null, userConfig, getLog() );
update.updateRepository();
}