improve configuration

This commit is contained in:
Sebastian Sdorra
2011-08-01 17:27:32 +02:00
parent 954d6e3fa4
commit 2379bafa02
3 changed files with 178 additions and 90 deletions

View File

@@ -45,7 +45,9 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
@@ -211,8 +213,29 @@ public abstract class AbstractBaseScmMojo extends AbstractScmMojo
protected File getWebApplicationArchive() throws MojoExecutionException
{
File warFile = null;
Artifact artifact = artifactFactory.createArtifact(groupId, artifactId,
version, "", type);
if (Util.isEmpty(webApplication.getVersion()))
{
String version = null;
MavenProject parent = project.getParent();
if (parent != null)
{
version = parent.getVersion();
}
else
{
version = project.getVersion();
}
webApplication.setVersion(version);
}
Artifact artifact =
artifactFactory.createArtifact(webApplication.getGroupId(),
webApplication.getArtifactId(),
webApplication.getVersion(), "",
webApplication.getType());
try
{

View File

@@ -68,17 +68,6 @@ public abstract class AbstractScmMojo extends AbstractMojo
return artifactFactory;
}
/**
* Method description
*
*
* @return
*/
public String getArtifactId()
{
return artifactId;
}
/**
* Method description
*
@@ -123,17 +112,6 @@ public abstract class AbstractScmMojo extends AbstractMojo
return availableRepositoryLayouts;
}
/**
* Method description
*
*
* @return
*/
public String getGroupId()
{
return groupId;
}
/**
* Method description
*
@@ -206,20 +184,9 @@ public abstract class AbstractScmMojo extends AbstractMojo
*
* @return
*/
public String getType()
public WebApplication getWebApplication()
{
return type;
}
/**
* Method description
*
*
* @return
*/
public String getVersion()
{
return version;
return webApplication;
}
//~--- set methods ----------------------------------------------------------
@@ -235,17 +202,6 @@ public abstract class AbstractScmMojo extends AbstractMojo
this.artifactFactory = artifactFactory;
}
/**
* Method description
*
*
* @param artifactId
*/
public void setArtifactId(String artifactId)
{
this.artifactId = artifactId;
}
/**
* Method description
*
@@ -292,17 +248,6 @@ public abstract class AbstractScmMojo extends AbstractMojo
this.availableRepositoryLayouts = availableRepositoryLayouts;
}
/**
* Method description
*
*
* @param groupId
*/
public void setGroupId(String groupId)
{
this.groupId = groupId;
}
/**
* Method description
*
@@ -373,22 +318,11 @@ public abstract class AbstractScmMojo extends AbstractMojo
* Method description
*
*
* @param type
* @param webApplication
*/
public void setType(String type)
public void setWebApplication(WebApplication webApplication)
{
this.type = type;
}
/**
* Method description
*
*
* @param version
*/
public void setVersion(String version)
{
this.version = version;
this.webApplication = webApplication;
}
//~--- fields ---------------------------------------------------------------
@@ -402,11 +336,6 @@ public abstract class AbstractScmMojo extends AbstractMojo
*/
protected ArtifactFactory artifactFactory;
/**
* @parameter
*/
protected String artifactId = "scm-webapp";
/**
* @component
*/
@@ -432,11 +361,6 @@ public abstract class AbstractScmMojo extends AbstractMojo
*/
protected Map<String, ArtifactRepositoryLayout> availableRepositoryLayouts;
/**
* @parameter
*/
protected String groupId = "sonia.scm";
/**
* @readonly
* @parameter expression="${localRepository}"
@@ -479,10 +403,5 @@ public abstract class AbstractScmMojo extends AbstractMojo
/**
* @parameter
*/
protected String type = "war";
/**
* @parameter expression="${project.parent.version}"
*/
protected String version;
protected WebApplication webApplication = new WebApplication();
}

View File

@@ -0,0 +1,146 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.maven;
/**
*
* @author Sebastian Sdorra
*/
public class WebApplication
{
/**
* Method description
*
*
* @return
*/
public String getArtifactId()
{
return artifactId;
}
/**
* Method description
*
*
* @return
*/
public String getGroupId()
{
return groupId;
}
/**
* Method description
*
*
* @return
*/
public String getType()
{
return type;
}
/**
* Method description
*
*
* @return
*/
public String getVersion()
{
return version;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param artifactId
*/
public void setArtifactId(String artifactId)
{
this.artifactId = artifactId;
}
/**
* Method description
*
*
* @param groupId
*/
public void setGroupId(String groupId)
{
this.groupId = groupId;
}
/**
* Method description
*
*
* @param type
*/
public void setType(String type)
{
this.type = type;
}
/**
* Method description
*
*
* @param version
*/
public void setVersion(String version)
{
this.version = version;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String artifactId = "scm-webapp";
/** Field description */
private String groupId = "sonia.scm";
/** Field description */
private String type = "war";
/** Field description */
private String version;
}