mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-05 06:09:12 +01:00
remove scm-maven-plugin, because it is moved to a separate repository
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
|
||||
<modules>
|
||||
<module>scm-plugin-archetype</module>
|
||||
<module>scm-maven-plugin</module>
|
||||
<module>scm-annotation-processor</module>
|
||||
</modules>
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>scm-maven-plugins</artifactId>
|
||||
<groupId>sonia.scm.maven</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>sonia.scm.maven</groupId>
|
||||
<artifactId>scm-maven-plugin</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<name>scm-maven-plugin</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>2.8</version>
|
||||
<configuration>
|
||||
<goalPrefix>scmp</goalPrefix>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>${mavenVersion}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<version>${mavenVersion}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-project</artifactId>
|
||||
<version>${mavenVersion}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
<version>${mavenVersion}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
<version>1.5.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<mavenVersion>2.0.6</mavenVersion>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -1,473 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.installer.ArtifactInstallationException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
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.project.MavenProject;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public abstract class AbstractBaseScmMojo extends AbstractScmMojo
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String PROPERTY_SCM_HOME = "scm.home";
|
||||
|
||||
/** Field description */
|
||||
private static final String FILE_CLASSPATH = "classpath.xml";
|
||||
|
||||
/** Field description */
|
||||
private static final String RESOURCE_DEPENDENCY_LIST =
|
||||
"WEB-INF/classes/config/dependencies.list";
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param warFile
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
protected List<String> createExcludeList(File warFile)
|
||||
throws MojoExecutionException
|
||||
{
|
||||
List<String> excludeList = new ArrayList<String>();
|
||||
InputStream input = null;
|
||||
|
||||
JarFile file = null;
|
||||
|
||||
try
|
||||
{
|
||||
file = new JarFile(warFile);
|
||||
|
||||
JarEntry entry = file.getJarEntry(RESOURCE_DEPENDENCY_LIST);
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
throw new MojoExecutionException("could not find dependency list");
|
||||
}
|
||||
|
||||
input = file.getInputStream(entry);
|
||||
|
||||
Scanner scanner = null;
|
||||
|
||||
try
|
||||
{
|
||||
scanner = new Scanner(input);
|
||||
|
||||
while (scanner.hasNextLine())
|
||||
{
|
||||
parseLine(excludeList, scanner.nextLine());
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Util.close(scanner);
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not read dependency file", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(input);
|
||||
Util.close(getLog(), file);
|
||||
}
|
||||
|
||||
return excludeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param excludeList
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
protected void installArtifacts(List<String> excludeList)
|
||||
throws MojoExecutionException
|
||||
{
|
||||
File pluginDirectory = new File(scmHome, "plugins");
|
||||
|
||||
installArtifacts(excludeList, pluginDirectory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param excludeList
|
||||
* @param pluginDirectory
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
protected void installArtifacts(List<String> excludeList,
|
||||
File pluginDirectory)
|
||||
throws MojoExecutionException
|
||||
{
|
||||
|
||||
if (!pluginDirectory.exists() &&!pluginDirectory.mkdirs())
|
||||
{
|
||||
throw new MojoExecutionException(
|
||||
"could not create plugin directory ".concat(pluginDirectory.getPath()));
|
||||
}
|
||||
|
||||
String repositoryUrl = "file://".concat(pluginDirectory.getAbsolutePath());
|
||||
ArtifactRepositoryLayout layout =
|
||||
availableRepositoryLayouts.get(repositoryLayout);
|
||||
|
||||
if (layout == null)
|
||||
{
|
||||
throw new MojoExecutionException(
|
||||
"could not find repository layout ".concat(repositoryLayout));
|
||||
}
|
||||
|
||||
ArtifactRepository pluginRepository =
|
||||
artifactRepositoryFactory.createDeploymentArtifactRepository(
|
||||
"scm-run-plugin", repositoryUrl, layout, true);
|
||||
List<String> classpath = new ArrayList<String>();
|
||||
String pluginDirectoryPath = pluginDirectory.getAbsolutePath();
|
||||
|
||||
installArtifact(excludeList, pluginDirectoryPath, classpath,
|
||||
pluginRepository, getPluginArtifact());
|
||||
|
||||
if (artifacts != null)
|
||||
{
|
||||
for (Artifact artifact : artifacts)
|
||||
{
|
||||
installArtifact(excludeList, pluginDirectoryPath, classpath,
|
||||
pluginRepository, artifact);
|
||||
}
|
||||
}
|
||||
|
||||
File classpathFile = new File(pluginDirectory, FILE_CLASSPATH);
|
||||
|
||||
if (classpathFile.exists())
|
||||
{
|
||||
readClasspathFile(classpath, classpathFile);
|
||||
}
|
||||
|
||||
writeClasspathFile(classpath, classpathFile);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param artifact
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected String getId(Artifact artifact)
|
||||
{
|
||||
return artifact.getGroupId().concat(":").concat(artifact.getArtifactId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected Artifact getPluginArtifact()
|
||||
{
|
||||
if (projectArtifact.getFile() == null)
|
||||
{
|
||||
File file = new File(project.getBuild().getDirectory(),
|
||||
project.getBuild().getFinalName().concat(".jar"));
|
||||
|
||||
projectArtifact.setFile(file);
|
||||
}
|
||||
|
||||
return projectArtifact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
protected File getWebApplicationArchive() throws MojoExecutionException
|
||||
{
|
||||
File warFile = null;
|
||||
|
||||
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
|
||||
{
|
||||
artifactResolver.resolve(artifact, remoteRepositories, localRepository);
|
||||
warFile = artifact.getFile();
|
||||
|
||||
if (!warFile.exists())
|
||||
{
|
||||
throw new MojoExecutionException("could not find webapp artifact file");
|
||||
}
|
||||
}
|
||||
catch (ArtifactNotFoundException ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not find artifact", ex);
|
||||
}
|
||||
catch (ArtifactResolutionException ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not fetch war-file", ex);
|
||||
}
|
||||
|
||||
return warFile;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param pluginDirectoryPath
|
||||
* @param classpath
|
||||
* @param source
|
||||
* @param artifact
|
||||
* @param localRepository
|
||||
*
|
||||
* @throws ArtifactInstallationException
|
||||
*/
|
||||
private void install(String pluginDirectoryPath, List<String> classpath,
|
||||
File source, Artifact artifact, ArtifactRepository localRepository)
|
||||
throws ArtifactInstallationException
|
||||
{
|
||||
try
|
||||
{
|
||||
String localPath = localRepository.pathOf(artifact);
|
||||
File destination = new File(localRepository.getBasedir(), localPath);
|
||||
|
||||
if (!destination.getParentFile().exists())
|
||||
{
|
||||
destination.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
getLog().info("Installing artifact " + source.getPath() + " to "
|
||||
+ destination);
|
||||
FileUtils.copyFile(source, destination);
|
||||
|
||||
String relativePath =
|
||||
destination.getAbsolutePath().substring(pluginDirectoryPath.length());
|
||||
|
||||
classpath.add(relativePath);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new ArtifactInstallationException("Error installing artifact: "
|
||||
+ e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param excludeList
|
||||
* @param pluginDirectoryPath
|
||||
* @param classpath
|
||||
* @param pluginRepository
|
||||
* @param artifact
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
private void installArtifact(List<String> excludeList,
|
||||
String pluginDirectoryPath, List<String> classpath,
|
||||
ArtifactRepository pluginRepository, Artifact artifact)
|
||||
throws MojoExecutionException
|
||||
{
|
||||
String id = getId(artifact);
|
||||
|
||||
if (!excludeList.contains(id))
|
||||
{
|
||||
if (artifact.getFile() != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
// See: http://mail-archives.apache.org/mod_mbox/maven-dev/200511.mbox/%3c437288F4.4080003@apache.org%3e
|
||||
artifact.isSnapshot();
|
||||
install(pluginDirectoryPath, classpath, artifact.getFile(), artifact,
|
||||
pluginRepository);
|
||||
}
|
||||
catch (ArtifactInstallationException e)
|
||||
{
|
||||
throw new MojoExecutionException("Failed to copy artifact.", e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new MojoExecutionException(
|
||||
"could not find file for ".concat(artifact.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param excludeList
|
||||
* @param line
|
||||
*/
|
||||
private void parseLine(List<String> excludeList, String line)
|
||||
{
|
||||
line = line.trim();
|
||||
|
||||
if (StringUtils.isNotEmpty(line))
|
||||
{
|
||||
String[] parts = line.split(":");
|
||||
|
||||
if (parts.length >= 2)
|
||||
{
|
||||
excludeList.add(parts[0].concat(":").concat(parts[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param classpath
|
||||
* @param classpathFile
|
||||
*/
|
||||
private void readClasspathFile(List<String> classpath, File classpathFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
JAXBContext context = JAXBContext.newInstance(Classpath.class);
|
||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||
Classpath c = (Classpath) unmarshaller.unmarshal(classpathFile);
|
||||
|
||||
classpath.addAll(c.getClasspathElements());
|
||||
}
|
||||
catch (JAXBException ex)
|
||||
{
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param classpath
|
||||
* @param classpathFile
|
||||
*/
|
||||
private void writeClasspathFile(List<String> classpath, File classpathFile)
|
||||
{
|
||||
Classpath c = new Classpath();
|
||||
|
||||
c.setClasspathElements(classpath);
|
||||
|
||||
try
|
||||
{
|
||||
JAXBContext context = JAXBContext.newInstance(Classpath.class);
|
||||
Marshaller marshaller = context.createMarshaller();
|
||||
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||
marshaller.marshal(c, classpathFile);
|
||||
}
|
||||
catch (JAXBException ex)
|
||||
{
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,407 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public abstract class AbstractScmMojo extends AbstractMojo
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ArtifactFactory getArtifactFactory()
|
||||
{
|
||||
return artifactFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ArtifactRepositoryFactory getArtifactRepositoryFactory()
|
||||
{
|
||||
return artifactRepositoryFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ArtifactResolver getArtifactResolver()
|
||||
{
|
||||
return artifactResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<Artifact> getArtifacts()
|
||||
{
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, ArtifactRepositoryLayout> getAvailableRepositoryLayouts()
|
||||
{
|
||||
return availableRepositoryLayouts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ArtifactRepository getLocalRepository()
|
||||
{
|
||||
return localRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public MavenProject getProject()
|
||||
{
|
||||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Artifact getProjectArtifact()
|
||||
{
|
||||
return projectArtifact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List getRemoteRepositories()
|
||||
{
|
||||
return remoteRepositories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getRepositoryLayout()
|
||||
{
|
||||
return repositoryLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getScmHome()
|
||||
{
|
||||
return scmHome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WebApplication getWebApplication()
|
||||
{
|
||||
return webApplication;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param artifactFactory
|
||||
*/
|
||||
public void setArtifactFactory(ArtifactFactory artifactFactory)
|
||||
{
|
||||
this.artifactFactory = artifactFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param artifactRepositoryFactory
|
||||
*/
|
||||
public void setArtifactRepositoryFactory(
|
||||
ArtifactRepositoryFactory artifactRepositoryFactory)
|
||||
{
|
||||
this.artifactRepositoryFactory = artifactRepositoryFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param artifactResolver
|
||||
*/
|
||||
public void setArtifactResolver(ArtifactResolver artifactResolver)
|
||||
{
|
||||
this.artifactResolver = artifactResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param artifacts
|
||||
*/
|
||||
public void setArtifacts(Set<Artifact> artifacts)
|
||||
{
|
||||
this.artifacts = artifacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param availableRepositoryLayouts
|
||||
*/
|
||||
public void setAvailableRepositoryLayouts(Map<String,
|
||||
ArtifactRepositoryLayout> availableRepositoryLayouts)
|
||||
{
|
||||
this.availableRepositoryLayouts = availableRepositoryLayouts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param localRepository
|
||||
*/
|
||||
public void setLocalRepository(ArtifactRepository localRepository)
|
||||
{
|
||||
this.localRepository = localRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param project
|
||||
*/
|
||||
public void setProject(MavenProject project)
|
||||
{
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param projectArtifact
|
||||
*/
|
||||
public void setProjectArtifact(Artifact projectArtifact)
|
||||
{
|
||||
this.projectArtifact = projectArtifact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param remoteRepositories
|
||||
*/
|
||||
public void setRemoteRepositories(List remoteRepositories)
|
||||
{
|
||||
this.remoteRepositories = remoteRepositories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repositoryLayout
|
||||
*/
|
||||
public void setRepositoryLayout(String repositoryLayout)
|
||||
{
|
||||
this.repositoryLayout = repositoryLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param scmHome
|
||||
*/
|
||||
public void setScmHome(String scmHome)
|
||||
{
|
||||
this.scmHome = scmHome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param webApplication
|
||||
*/
|
||||
public void setWebApplication(WebApplication webApplication)
|
||||
{
|
||||
this.webApplication = webApplication;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Used to look up Artifacts in the remote repository.
|
||||
*
|
||||
* @component role="org.apache.maven.artifact.factory.ArtifactFactory"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
protected ArtifactFactory artifactFactory;
|
||||
|
||||
/**
|
||||
* @component
|
||||
*/
|
||||
protected ArtifactRepositoryFactory artifactRepositoryFactory;
|
||||
|
||||
/**
|
||||
* Used to look up Artifacts in the remote repository.
|
||||
*
|
||||
* @component role="org.apache.maven.artifact.resolver.ArtifactResolver"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
protected ArtifactResolver artifactResolver;
|
||||
|
||||
/**
|
||||
* @readonly
|
||||
* @parameter expression="${project.artifacts}"
|
||||
*/
|
||||
protected Set<Artifact> artifacts;
|
||||
|
||||
/**
|
||||
* @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
|
||||
*/
|
||||
protected Map<String, ArtifactRepositoryLayout> availableRepositoryLayouts;
|
||||
|
||||
/**
|
||||
* @readonly
|
||||
* @parameter expression="${localRepository}"
|
||||
*/
|
||||
protected ArtifactRepository localRepository;
|
||||
|
||||
/**
|
||||
* The maven project in question.
|
||||
* @parameter expression="${project}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
protected MavenProject project;
|
||||
|
||||
/**
|
||||
* @readonly
|
||||
* @parameter expression="${project.artifact}"
|
||||
*/
|
||||
protected Artifact projectArtifact;
|
||||
|
||||
/**
|
||||
* List of Remote Repositories used by the resolver
|
||||
*
|
||||
* @parameter expression="${project.remoteArtifactRepositories}"
|
||||
* @readonly
|
||||
* @required
|
||||
*/
|
||||
protected List remoteRepositories;
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
protected String repositoryLayout = "default";
|
||||
|
||||
/**
|
||||
* @parameter expression="${scmHome}" default-value="${project.build.directory}/scm-home"
|
||||
*/
|
||||
protected String scmHome;
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
protected WebApplication webApplication = new WebApplication();
|
||||
}
|
||||
@@ -1,428 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @goal append-dependencies
|
||||
* @phase process-classes
|
||||
* @requiresDependencyResolution compile+runtime
|
||||
*/
|
||||
public class AppendDependenciesMojo extends AbstractMojo
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final String ELEMENT_ARTIFACTID = "artifactId";
|
||||
|
||||
/** Field description */
|
||||
private static final String ELEMENT_DEPENDENCIES = "dependencies";
|
||||
|
||||
/** Field description */
|
||||
private static final String ELEMENT_DEPENDENCY = "dependency";
|
||||
|
||||
/** Field description */
|
||||
private static final String ELEMENT_GROUPID = "groupId";
|
||||
|
||||
/** Field description */
|
||||
private static final String ELEMENT_INFORMATION = "information";
|
||||
|
||||
/** Field description */
|
||||
private static final String PLUGIN_DESCRIPTOR = "META-INF/scm/plugin.xml";
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
* @throws MojoFailureException
|
||||
*/
|
||||
public void doExecute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
|
||||
try
|
||||
{
|
||||
ClassLoader classLoader = ClassLoaders.createRuntimeClassLoader(project);
|
||||
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
appendDependencies(classLoader);
|
||||
}
|
||||
catch (ParserConfigurationException ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not parse plugin descriptor", ex);
|
||||
}
|
||||
catch (SAXException ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not parse plugin descriptor", ex);
|
||||
}
|
||||
catch (DependencyResolutionRequiredException ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not setup classloader", ex);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not setup classloader", ex);
|
||||
}
|
||||
catch (TransformerException ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not write plugin.xml", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Thread.currentThread().setContextClassLoader(oldClassLoader);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
* @throws MojoFailureException
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
if (descriptor.exists())
|
||||
{
|
||||
doExecute();
|
||||
}
|
||||
else
|
||||
{
|
||||
getLog().warn(
|
||||
"no plugin descriptor found, skipping append-dependencies goal");
|
||||
}
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public File getDescriptor()
|
||||
{
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public MavenProject getProject()
|
||||
{
|
||||
return project;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param descriptor
|
||||
*/
|
||||
public void setDescriptor(File descriptor)
|
||||
{
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param project
|
||||
*/
|
||||
public void setProject(MavenProject project)
|
||||
{
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param classLoader
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws ParserConfigurationException
|
||||
* @throws SAXException
|
||||
* @throws TransformerException
|
||||
*/
|
||||
private void appendDependencies(ClassLoader classLoader)
|
||||
throws IOException, ParserConfigurationException, SAXException,
|
||||
TransformerException
|
||||
{
|
||||
Set<String> dependencies = new HashSet<String>();
|
||||
Enumeration<URL> descriptors = classLoader.getResources(PLUGIN_DESCRIPTOR);
|
||||
|
||||
while (descriptors.hasMoreElements())
|
||||
{
|
||||
URL url = descriptors.nextElement();
|
||||
|
||||
appendDependency(dependencies, url);
|
||||
}
|
||||
|
||||
if (dependencies.isEmpty())
|
||||
{
|
||||
getLog().info("no plugin dependencies found");
|
||||
}
|
||||
else
|
||||
{
|
||||
getLog().info("update plugin descriptor");
|
||||
rewritePluginDescriptor(dependencies);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param dependencies
|
||||
* @param url
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws ParserConfigurationException
|
||||
* @throws SAXException
|
||||
*/
|
||||
private void appendDependency(Set<String> dependencies, URL url)
|
||||
throws ParserConfigurationException, SAXException, IOException
|
||||
{
|
||||
DocumentBuilder builder =
|
||||
DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
InputStream is = null;
|
||||
|
||||
try
|
||||
{
|
||||
is = url.openStream();
|
||||
|
||||
Document doc = builder.parse(is);
|
||||
|
||||
String pluginid = parseDescriptor(doc);
|
||||
|
||||
if (!pluginid.equals(
|
||||
project.getGroupId().concat(":").concat(project.getArtifactId())))
|
||||
{
|
||||
dependencies.add(pluginid);
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (is != null)
|
||||
{
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param doc
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String parseDescriptor(Document doc)
|
||||
{
|
||||
String id = null;
|
||||
NodeList nodeList = doc.getElementsByTagName(ELEMENT_INFORMATION);
|
||||
|
||||
for (int i = 0; i < nodeList.getLength(); i++)
|
||||
{
|
||||
Node node = nodeList.item(i);
|
||||
|
||||
if (isElement(node, ELEMENT_INFORMATION))
|
||||
{
|
||||
id = parseInformationNode(node);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param informationNode
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String parseInformationNode(Node informationNode)
|
||||
{
|
||||
String groupid = null;
|
||||
String artifactid = null;
|
||||
NodeList nodeList = informationNode.getChildNodes();
|
||||
|
||||
for (int i = 0; i < nodeList.getLength(); i++)
|
||||
{
|
||||
Node node = nodeList.item(i);
|
||||
|
||||
if (isElement(node, ELEMENT_GROUPID))
|
||||
{
|
||||
groupid = node.getTextContent();
|
||||
}
|
||||
else if (isElement(node, ELEMENT_ARTIFACTID))
|
||||
{
|
||||
artifactid = node.getTextContent();
|
||||
}
|
||||
}
|
||||
|
||||
if ((groupid == null) || (artifactid == null))
|
||||
{
|
||||
throw new RuntimeException(
|
||||
"descriptor does not contain groupid or artifactid");
|
||||
}
|
||||
|
||||
return groupid.concat(":").concat(artifactid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param dependencies
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws ParserConfigurationException
|
||||
* @throws SAXException
|
||||
* @throws TransformerConfigurationException
|
||||
* @throws TransformerException
|
||||
*/
|
||||
private void rewritePluginDescriptor(Set<String> dependencies)
|
||||
throws SAXException, IOException, ParserConfigurationException,
|
||||
TransformerConfigurationException, TransformerException
|
||||
{
|
||||
DocumentBuilder builder =
|
||||
DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Document doc = builder.parse(descriptor);
|
||||
Element dependenciesEl = doc.createElement(ELEMENT_DEPENDENCIES);
|
||||
|
||||
doc.getDocumentElement().appendChild(dependenciesEl);
|
||||
|
||||
for (String pluginid : dependencies)
|
||||
{
|
||||
Element dependencyEl = doc.createElement(ELEMENT_DEPENDENCY);
|
||||
|
||||
dependencyEl.setTextContent(pluginid);
|
||||
dependenciesEl.appendChild(dependencyEl);
|
||||
}
|
||||
|
||||
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
||||
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.transform(new DOMSource(doc), new StreamResult(descriptor));
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param node
|
||||
* @param name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isElement(Node node, String name)
|
||||
{
|
||||
return (node.getNodeType() == Node.ELEMENT_NODE)
|
||||
&& name.equals(node.getNodeName());
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @parameter default-value="${project.build.directory}/classes/META-INF/scm/plugin.xml"
|
||||
*/
|
||||
private File descriptor;
|
||||
|
||||
/**
|
||||
* The maven project in question.
|
||||
* @parameter expression="${project}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
private MavenProject project;
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public final class ClassLoaders
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private ClassLoaders() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param project
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws DependencyResolutionRequiredException
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ClassLoader createRuntimeClassLoader(MavenProject project)
|
||||
throws DependencyResolutionRequiredException, MalformedURLException
|
||||
{
|
||||
Set<URL> urls = new HashSet<>();
|
||||
|
||||
append(urls, project.getRuntimeClasspathElements());
|
||||
append(urls, project.getCompileClasspathElements());
|
||||
|
||||
return URLClassLoader.newInstance(urls.toArray(new URL[urls.size()]),
|
||||
Thread.currentThread().getContextClassLoader());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param urls
|
||||
* @param elements
|
||||
*
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
private static void append(Set<URL> urls, List<String> elements)
|
||||
throws MalformedURLException
|
||||
{
|
||||
for (String element : elements)
|
||||
{
|
||||
urls.add(new File(element).toURI().toURL());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@XmlRootElement(name = "classpath")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Classpath
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<String> getClasspathElements()
|
||||
{
|
||||
return classpathElements;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param classpathElements
|
||||
*/
|
||||
public void setClasspathElements(List<String> classpathElements)
|
||||
{
|
||||
this.classpathElements = classpathElements;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name = "path")
|
||||
private List<String> classpathElements = new ArrayList<String>();
|
||||
}
|
||||
@@ -1,352 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @goal fix-descriptor
|
||||
* @phase process-resources
|
||||
*/
|
||||
public class FixDescriptorMojo extends AbstractMojo
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
* @throws MojoFailureException
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
if (descriptor.exists() && descriptor.isFile())
|
||||
{
|
||||
Document document = createDocument(descriptor);
|
||||
|
||||
fixDescriptor(document);
|
||||
writeDocument(document);
|
||||
}
|
||||
else
|
||||
{
|
||||
getLog().warn("no plugin descriptor found, skipping fix-descriptor goal");
|
||||
}
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public File getDescriptor()
|
||||
{
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public MavenProject getProject()
|
||||
{
|
||||
return project;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param descriptor
|
||||
*/
|
||||
public void setDescriptor(File descriptor)
|
||||
{
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param project
|
||||
*/
|
||||
public void setProject(MavenProject project)
|
||||
{
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param document
|
||||
* @param parent
|
||||
* @param name
|
||||
* @param value
|
||||
*/
|
||||
private void appendNode(Document document, Node parent, String name,
|
||||
String value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
Element node = document.createElement(name);
|
||||
|
||||
node.setTextContent(value);
|
||||
parent.appendChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param descriptor
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
private Document createDocument(File descriptor) throws MojoExecutionException
|
||||
{
|
||||
Document document = null;
|
||||
|
||||
try
|
||||
{
|
||||
document =
|
||||
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(
|
||||
descriptor);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not parse plugin descriptor");
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param document
|
||||
*/
|
||||
private void fixDescriptor(Document document)
|
||||
{
|
||||
Element rootElement = document.getDocumentElement();
|
||||
NodeList informationNodeList =
|
||||
rootElement.getElementsByTagName("information");
|
||||
Node informationNode = null;
|
||||
|
||||
for (int i = 0; i < informationNodeList.getLength(); i++)
|
||||
{
|
||||
Node node = informationNodeList.item(i);
|
||||
|
||||
if ("information".equals(node.getNodeName()))
|
||||
{
|
||||
informationNode = node;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (informationNode == null)
|
||||
{
|
||||
informationNode = document.createElement("information");
|
||||
rootElement.appendChild(informationNode);
|
||||
}
|
||||
|
||||
fixDescriptorInformations(document, informationNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param document
|
||||
* @param informationNode
|
||||
*/
|
||||
private void fixDescriptorInformations(Document document,
|
||||
Node informationNode)
|
||||
{
|
||||
boolean groupId = false;
|
||||
boolean artifactId = false;
|
||||
boolean version = false;
|
||||
boolean name = false;
|
||||
boolean url = false;
|
||||
boolean description = false;
|
||||
boolean author = false;
|
||||
NodeList children = informationNode.getChildNodes();
|
||||
|
||||
for (int i = 0; i < children.getLength(); i++)
|
||||
{
|
||||
Node node = children.item(i);
|
||||
String nodeName = node.getNodeName();
|
||||
|
||||
if ("groupId".equals(nodeName))
|
||||
{
|
||||
groupId = true;
|
||||
}
|
||||
else if ("artifactId".equals(nodeName))
|
||||
{
|
||||
artifactId = true;
|
||||
}
|
||||
else if ("version".equals(nodeName))
|
||||
{
|
||||
version = true;
|
||||
}
|
||||
else if ("name".equals(nodeName))
|
||||
{
|
||||
name = true;
|
||||
}
|
||||
else if ("url".equals(nodeName))
|
||||
{
|
||||
url = true;
|
||||
}
|
||||
else if ("description".equals(nodeName))
|
||||
{
|
||||
description = true;
|
||||
}
|
||||
else if ("author".equals(nodeName))
|
||||
{
|
||||
author = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!groupId)
|
||||
{
|
||||
appendNode(document, informationNode, "groupId", project.getGroupId());
|
||||
}
|
||||
|
||||
if (!artifactId)
|
||||
{
|
||||
appendNode(document, informationNode, "artifactId",
|
||||
project.getArtifactId());
|
||||
}
|
||||
|
||||
if (!version)
|
||||
{
|
||||
appendNode(document, informationNode, "version", project.getVersion());
|
||||
}
|
||||
|
||||
if (!name)
|
||||
{
|
||||
appendNode(document, informationNode, "name", project.getName());
|
||||
}
|
||||
|
||||
if (!url)
|
||||
{
|
||||
appendNode(document, informationNode, "url", project.getUrl());
|
||||
}
|
||||
|
||||
if (!description)
|
||||
{
|
||||
appendNode(document, informationNode, "description",
|
||||
project.getDescription());
|
||||
}
|
||||
|
||||
// TODO handle author node
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param document
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
private void writeDocument(Document document) throws MojoExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
Transformer transformer =
|
||||
TransformerFactory.newInstance().newTransformer();
|
||||
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.transform(new DOMSource(document),
|
||||
new StreamResult(descriptor));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not write plugin descriptor");
|
||||
}
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @parameter default-value="${project.build.directory}/classes/META-INF/scm/plugin.xml"
|
||||
*/
|
||||
private File descriptor;
|
||||
|
||||
/**
|
||||
* The maven project in question.
|
||||
* @parameter expression="${project}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
private MavenProject project;
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @goal install
|
||||
* @requiresDependencyResolution runtime
|
||||
* @execute phase="package"
|
||||
*/
|
||||
public class InstallMojo extends AbstractBaseScmMojo
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
* @throws MojoFailureException
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
File warFile = getWebApplicationArchive();
|
||||
List<String> excludeList = createExcludeList(warFile);
|
||||
|
||||
installArtifacts(excludeList);
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class JettyStopMonitorThread extends Thread
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String ADDRESS_LOCALHOST = "127.0.0.1";
|
||||
|
||||
/** Field description */
|
||||
public static final String NAME = "JettyStopMonitor";
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param server
|
||||
* @param stopPort
|
||||
* @param stopKey
|
||||
*/
|
||||
public JettyStopMonitorThread(Server server, int stopPort, String stopKey)
|
||||
{
|
||||
this.server = server;
|
||||
this.stopKey = stopKey;
|
||||
setDaemon(true);
|
||||
setName(NAME);
|
||||
|
||||
try
|
||||
{
|
||||
socket = new ServerSocket(stopPort, 1,
|
||||
InetAddress.getByName(ADDRESS_LOCALHOST));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
BufferedReader reader = null;
|
||||
Socket accept = null;
|
||||
|
||||
try
|
||||
{
|
||||
accept = socket.accept();
|
||||
reader =
|
||||
new BufferedReader(new InputStreamReader(accept.getInputStream()));
|
||||
|
||||
String line = reader.readLine();
|
||||
|
||||
if (stopKey.equals(line))
|
||||
{
|
||||
server.stop();
|
||||
socket.close();
|
||||
}
|
||||
|
||||
accept.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(reader);
|
||||
}
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private Server server;
|
||||
|
||||
/** Field description */
|
||||
private ServerSocket socket;
|
||||
|
||||
/** Field description */
|
||||
private String stopKey;
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.component.LifeCycle.Listener;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.awt.Desktop;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class OpenBrowserListener implements Listener
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param log
|
||||
* @param port
|
||||
* @param contextPath
|
||||
*/
|
||||
public OpenBrowserListener(Log log, int port, String contextPath)
|
||||
{
|
||||
this.log = log;
|
||||
this.port = port;
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param event
|
||||
* @param cause
|
||||
*/
|
||||
@Override
|
||||
public void lifeCycleFailure(LifeCycle event, Throwable cause)
|
||||
{
|
||||
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Override
|
||||
public void lifeCycleStarted(LifeCycle event)
|
||||
{
|
||||
new Thread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
|
||||
desktop.browse(new URI("http://localhost:" + port + contextPath));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.warn(ex);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Override
|
||||
public void lifeCycleStarting(LifeCycle event)
|
||||
{
|
||||
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Override
|
||||
public void lifeCycleStopped(LifeCycle event)
|
||||
{
|
||||
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Override
|
||||
public void lifeCycleStopping(LifeCycle event)
|
||||
{
|
||||
|
||||
// do nothing
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private String contextPath;
|
||||
|
||||
/** Field description */
|
||||
private Log log;
|
||||
|
||||
/** Field description */
|
||||
private int port;
|
||||
}
|
||||
@@ -1,429 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.deployer.ArtifactDeployer;
|
||||
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
* @goal package
|
||||
* @requiresDependencyResolution runtime
|
||||
* @execute phase="package"
|
||||
*/
|
||||
public class PackageMojo extends AbstractBaseScmMojo
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
* @throws MojoFailureException
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
File warFile = getWebApplicationArchive();
|
||||
List<String> excludeList = createExcludeList(warFile);
|
||||
|
||||
deployToDirectory(excludeList);
|
||||
copyDescriptor();
|
||||
createPackage();
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ArtifactDeployer getDeployer()
|
||||
{
|
||||
return deployer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public File getDescriptor()
|
||||
{
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public File getPackageDirectory()
|
||||
{
|
||||
return packageDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public File getPackageFile()
|
||||
{
|
||||
return packageFile;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param deployer
|
||||
*/
|
||||
public void setDeployer(ArtifactDeployer deployer)
|
||||
{
|
||||
this.deployer = deployer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param descriptor
|
||||
*/
|
||||
public void setDescriptor(File descriptor)
|
||||
{
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param packageDirectory
|
||||
*/
|
||||
public void setPackageDirectory(File packageDirectory)
|
||||
{
|
||||
this.packageDirectory = packageDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param packageFile
|
||||
*/
|
||||
public void setPackageFile(File packageFile)
|
||||
{
|
||||
this.packageFile = packageFile;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param zout
|
||||
* @param baseDirectory
|
||||
* @param baseDirectoryLength
|
||||
* @param file
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void appendFile(ZipOutputStream zout, int baseDirectoryLength,
|
||||
File file)
|
||||
throws IOException
|
||||
{
|
||||
if (file.isDirectory())
|
||||
{
|
||||
for (File f : file.listFiles())
|
||||
{
|
||||
appendFile(zout, baseDirectoryLength, f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
InputStream input = null;
|
||||
ZipEntry entry =
|
||||
new ZipEntry(file.getAbsolutePath().substring(baseDirectoryLength));
|
||||
|
||||
try
|
||||
{
|
||||
input = new FileInputStream(file);
|
||||
|
||||
zout.putNextEntry(entry);
|
||||
IOUtils.copy(input, zout);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
IOUtils.closeQuietly(input);
|
||||
}
|
||||
|
||||
zout.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
private void copyDescriptor() throws MojoExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
File packageDescriptorFile = new File(packageDirectory, "plugin.xml");
|
||||
|
||||
FileUtils.copyFile(descriptor, packageDescriptorFile);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not copy descriptor", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
private void createPackage() throws MojoExecutionException
|
||||
{
|
||||
|
||||
ZipOutputStream zout = null;
|
||||
|
||||
try
|
||||
{
|
||||
zout = new ZipOutputStream(new FileOutputStream(packageFile));
|
||||
appendFile(zout, packageDirectory.getAbsolutePath().length() + 1,
|
||||
packageDirectory);
|
||||
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not create package", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(zout);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param excludeList
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
private void deployToDirectory(List<String> excludeList)
|
||||
throws MojoExecutionException
|
||||
{
|
||||
|
||||
Artifact pluginArtifact = getPluginArtifact();
|
||||
|
||||
try
|
||||
{
|
||||
ArtifactRepository deploymentRepository = getDeploymentRepository();
|
||||
ArtifactMetadata metadata = new ProjectArtifactMetadata(pluginArtifact,
|
||||
pomFile);
|
||||
|
||||
pluginArtifact.addMetadata(metadata);
|
||||
|
||||
deployToDirectory(excludeList, deploymentRepository, pluginArtifact,
|
||||
false);
|
||||
|
||||
for (Artifact artifact : artifacts)
|
||||
{
|
||||
deployToDirectory(excludeList, deploymentRepository, artifact, true);
|
||||
}
|
||||
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not create deloy repository", ex);
|
||||
}
|
||||
catch (ArtifactDeploymentException ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not create deloy artifcat", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param excludeList
|
||||
* @param deploymentRepository
|
||||
* @param artifact
|
||||
* @param resolveMetadata
|
||||
*
|
||||
* @throws ArtifactDeploymentException
|
||||
*/
|
||||
private void deployToDirectory(List<String> excludeList,
|
||||
ArtifactRepository deploymentRepository, Artifact artifact,
|
||||
boolean resolveMetadata)
|
||||
throws ArtifactDeploymentException
|
||||
{
|
||||
String id = getId(artifact);
|
||||
|
||||
if (!excludeList.contains(id))
|
||||
{
|
||||
artifact.isSnapshot();
|
||||
|
||||
if (resolveMetadata)
|
||||
{
|
||||
String path = localRepository.pathOf(artifact);
|
||||
int lastIndex = path.lastIndexOf('.');
|
||||
|
||||
if (lastIndex > 0)
|
||||
{
|
||||
path = path.substring(0, lastIndex).concat(".pom");
|
||||
|
||||
File pom = new File(localRepository.getBasedir(), path);
|
||||
|
||||
if (pom.exists())
|
||||
{
|
||||
ArtifactMetadata metadata = new ProjectArtifactMetadata(artifact,
|
||||
pom);
|
||||
|
||||
artifact.addMetadata(metadata);
|
||||
}
|
||||
else
|
||||
{
|
||||
getLog().warn("could not find pom at ".concat(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File file = artifact.getFile();
|
||||
|
||||
deployer.deploy(file, artifact, deploymentRepository, localRepository);
|
||||
}
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
private ArtifactRepository getDeploymentRepository()
|
||||
throws IOException, MojoExecutionException
|
||||
{
|
||||
|
||||
ArtifactRepositoryLayout artifactRepositoryLayout =
|
||||
availableRepositoryLayouts.get(repositoryLayout);
|
||||
|
||||
if (artifactRepositoryLayout == null)
|
||||
{
|
||||
throw new MojoExecutionException(
|
||||
"could not find repository layout ".concat(repositoryLayout));
|
||||
}
|
||||
|
||||
return artifactRepositoryFactory.createDeploymentArtifactRepository(
|
||||
"package.repository",
|
||||
"file://".concat(packageDirectory.getAbsolutePath()),
|
||||
artifactRepositoryLayout, true);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @component
|
||||
*/
|
||||
private ArtifactDeployer deployer;
|
||||
|
||||
/**
|
||||
* @parameter default-value="${project.build.directory}/classes/META-INF/scm/plugin.xml"
|
||||
*/
|
||||
private File descriptor;
|
||||
|
||||
/**
|
||||
* @parameter expression="${packageDirectory}" default-value="${project.build.directory}/${project.artifactId}-${project.version}-package"
|
||||
*/
|
||||
private File packageDirectory;
|
||||
|
||||
/**
|
||||
* @parameter expression="${packageFile}" default-value="${project.build.directory}/${project.artifactId}-${project.version}.scmp"
|
||||
*/
|
||||
private File packageFile;
|
||||
|
||||
/**
|
||||
* @parameter default-value="${project.file}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
private File pomFile;
|
||||
}
|
||||
@@ -1,376 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.awt.Desktop;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @goal run
|
||||
* @requiresDependencyResolution runtime
|
||||
* @execute phase="package"
|
||||
*/
|
||||
public class RunMojo extends AbstractBaseScmMojo
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final int HEADERBUFFERSIZE = 16384;
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
* @throws MojoFailureException
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
File warFile = getWebApplicationArchive();
|
||||
List<String> excludeList = createExcludeList(warFile);
|
||||
|
||||
installArtifacts(excludeList);
|
||||
runServletContainer(warFile);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getContextPath()
|
||||
{
|
||||
return contextPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getLoggingConfiguration()
|
||||
{
|
||||
return loggingConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getPort()
|
||||
{
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getStage()
|
||||
{
|
||||
return stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getStopKey()
|
||||
{
|
||||
return stopKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getStopPort()
|
||||
{
|
||||
return stopPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isBackgroud()
|
||||
{
|
||||
return backgroud;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isOpenBrowser()
|
||||
{
|
||||
return openBrowser;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param backgroud
|
||||
*/
|
||||
public void setBackgroud(boolean backgroud)
|
||||
{
|
||||
this.backgroud = backgroud;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param contextPath
|
||||
*/
|
||||
public void setContextPath(String contextPath)
|
||||
{
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param loggingConfiguration
|
||||
*/
|
||||
public void setLoggingConfiguration(String loggingConfiguration)
|
||||
{
|
||||
this.loggingConfiguration = loggingConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param openBrowser
|
||||
*/
|
||||
public void setOpenBrowser(boolean openBrowser)
|
||||
{
|
||||
this.openBrowser = openBrowser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
*/
|
||||
public void setPort(int port)
|
||||
{
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param stage
|
||||
*/
|
||||
public void setStage(String stage)
|
||||
{
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param stopKey
|
||||
*/
|
||||
public void setStopKey(String stopKey)
|
||||
{
|
||||
this.stopKey = stopKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param stopPort
|
||||
*/
|
||||
public void setStopPort(int stopPort)
|
||||
{
|
||||
this.stopPort = stopPort;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param warFile
|
||||
*
|
||||
* @throws MojoFailureException
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
private void runServletContainer(File warFile) throws MojoExecutionException
|
||||
{
|
||||
getLog().info("start servletcontainer at port " + port);
|
||||
|
||||
try
|
||||
{
|
||||
System.setProperty("scm.home", scmHome);
|
||||
System.setProperty("scm.stage", stage);
|
||||
System.out.println("SET STAGE " + stage);
|
||||
|
||||
if (loggingConfiguration == null)
|
||||
{
|
||||
loggingConfiguration = loggginConfiguration;
|
||||
}
|
||||
|
||||
// enable debug logging
|
||||
System.setProperty("logback.configurationFile", loggingConfiguration);
|
||||
|
||||
Server server = new Server();
|
||||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
|
||||
connector.setRequestHeaderSize(HEADERBUFFERSIZE);
|
||||
|
||||
if (openBrowser && Desktop.isDesktopSupported())
|
||||
{
|
||||
connector.addLifeCycleListener(new OpenBrowserListener(getLog(), port,
|
||||
contextPath));
|
||||
}
|
||||
|
||||
connector.setPort(port);
|
||||
server.addConnector(connector);
|
||||
|
||||
WebAppContext warContext = new WebAppContext();
|
||||
|
||||
warContext.setContextPath(contextPath);
|
||||
warContext.setExtractWAR(true);
|
||||
warContext.setWar(warFile.getAbsolutePath());
|
||||
server.setHandler(warContext);
|
||||
new JettyStopMonitorThread(server, stopPort, stopKey).start();
|
||||
server.start();
|
||||
|
||||
if (!backgroud)
|
||||
{
|
||||
server.join();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new MojoExecutionException("could not start servletcontainer", ex);
|
||||
}
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
private boolean backgroud = false;
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
private String contextPath = "/scm";
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
private String loggginConfiguration;
|
||||
|
||||
/**
|
||||
* @parameter expression="${loggingConfiguration}" default-value="/logback.default.xml"
|
||||
*/
|
||||
private String loggingConfiguration;
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
private int port = 8081;
|
||||
|
||||
/**
|
||||
* @parameter expression="${scm.stage}" default-value="DEVELOPMENT"
|
||||
*/
|
||||
private String stage = "DEVELOPMENT";
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
private String stopKey = "stop";
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
private int stopPort = 8085;
|
||||
|
||||
/**
|
||||
* @parameter expression="${openBrowser}" default-value="true"
|
||||
*/
|
||||
private boolean openBrowser = true;
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
* @goal stop
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class StopMojo extends AbstractMojo
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String ADDRESS_LOCALHOST = "127.0.0.1";
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws MojoExecutionException
|
||||
* @throws MojoFailureException
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
Socket socket = null;
|
||||
PrintWriter writer = null;
|
||||
|
||||
try
|
||||
{
|
||||
socket = new Socket(InetAddress.getByName(ADDRESS_LOCALHOST), stopPort);
|
||||
writer = new PrintWriter(socket.getOutputStream());
|
||||
writer.println(stopKey);
|
||||
writer.flush();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
getLog().warn("could not stop jetty", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(writer);
|
||||
|
||||
if (socket != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
socket.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
|
||||
// ignore ex
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getStopKey()
|
||||
{
|
||||
return stopKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getStopPort()
|
||||
{
|
||||
return stopPort;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param stopKey
|
||||
*/
|
||||
public void setStopKey(String stopKey)
|
||||
{
|
||||
this.stopKey = stopKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param stopPort
|
||||
*/
|
||||
public void setStopPort(int stopPort)
|
||||
{
|
||||
this.stopPort = stopPort;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
private String stopKey = "stop";
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
private int stopPort = 8085;
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public final class Util
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private Util() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param log
|
||||
* @param file
|
||||
*/
|
||||
public static void close(Log log, ZipFile file)
|
||||
{
|
||||
if (file != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
file.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
log.warn("could not close zipfile", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param scanner
|
||||
*/
|
||||
public static void close(Scanner scanner)
|
||||
{
|
||||
if (scanner != null)
|
||||
{
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean isEmpty(String value)
|
||||
{
|
||||
return (value == null) || (value.trim().length() == 0);
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
Reference in New Issue
Block a user