mirror of https://github.com/apache/maven.git
o Refactored IT plugin
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@987333 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
36bb0bfe27
commit
3796ddabcd
|
@ -202,6 +202,12 @@ under the License.
|
||||||
<version>${itPluginVersion}</version>
|
<version>${itPluginVersion}</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
|
<artifactId>maven-it-plugin-project</artifactId>
|
||||||
|
<version>${itPluginVersion}</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.its.plugins</groupId>
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
<artifactId>maven-it-plugin-project-interpolation</artifactId>
|
<artifactId>maven-it-plugin-project-interpolation</artifactId>
|
||||||
|
|
|
@ -36,14 +36,14 @@ under the License.
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.its.plugins</groupId>
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
<artifactId>maven-it-plugin-artifact</artifactId>
|
<artifactId>maven-it-plugin-project</artifactId>
|
||||||
<version>2.1-SNAPSHOT</version>
|
<version>2.1-SNAPSHOT</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>test</id>
|
<id>test</id>
|
||||||
<phase>validate</phase>
|
<phase>validate</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>build-pom</goal>
|
<goal>remote-pom</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -37,14 +37,14 @@ under the License.
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.its.plugins</groupId>
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
<artifactId>maven-it-plugin-artifact</artifactId>
|
<artifactId>maven-it-plugin-project</artifactId>
|
||||||
<version>2.1-SNAPSHOT</version>
|
<version>2.1-SNAPSHOT</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>test</id>
|
<id>test</id>
|
||||||
<phase>validate</phase>
|
<phase>validate</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>build-pom</goal>
|
<goal>remote-pom</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<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/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>maven-it-plugins</artifactId>
|
||||||
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
|
<version>2.1-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>maven-it-plugin-project</artifactId>
|
||||||
|
<packaging>maven-plugin</packaging>
|
||||||
|
|
||||||
|
<name>Maven Integration Test Plugin :: Project</name>
|
||||||
|
<description>
|
||||||
|
A test plugin that can build Maven project instances from local/remote POMs.
|
||||||
|
</description>
|
||||||
|
<inceptionYear>2010</inceptionYear>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.test.skip>true</maven.test.skip>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-project</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-model</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-artifact</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,86 @@
|
||||||
|
package org.apache.maven.plugin.coreit;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
|
import org.apache.maven.project.MavenProject;
|
||||||
|
import org.apache.maven.project.MavenProjectBuilder;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Benjamin Bentmann
|
||||||
|
*/
|
||||||
|
public abstract class AbstractPomMojo
|
||||||
|
extends AbstractMojo
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The project builder.
|
||||||
|
*
|
||||||
|
* @component
|
||||||
|
*/
|
||||||
|
protected MavenProjectBuilder builder;
|
||||||
|
|
||||||
|
protected void dump( Properties props, String key, MavenProject project )
|
||||||
|
{
|
||||||
|
props.setProperty( key + "project.id", project.getId() );
|
||||||
|
if ( project.getName() != null )
|
||||||
|
{
|
||||||
|
props.setProperty( key + "project.name", project.getName() );
|
||||||
|
}
|
||||||
|
if ( project.getDescription() != null )
|
||||||
|
{
|
||||||
|
props.setProperty( key + "project.description", project.getDescription() );
|
||||||
|
}
|
||||||
|
if ( project.getArtifact() != null )
|
||||||
|
{
|
||||||
|
props.setProperty( key + "artifact.id", project.getArtifact().getId() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void store( Properties props, File file )
|
||||||
|
throws MojoExecutionException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
|
||||||
|
FileOutputStream os = new FileOutputStream( file );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
props.store( os, "[MAVEN-CORE-IT-LOG]" );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
os.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new MojoExecutionException( "Failed to dump POMs: " + e.getMessage(), e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -23,28 +23,23 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.model.Dependency;
|
import org.apache.maven.model.Dependency;
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.MavenProjectBuilder;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the remote POMs of user-specified artifacts. This mimics in part the Maven Remote Resources Plugin.
|
* Builds the remote POMs of user-specified artifacts. This mimics in part the Maven Remote Resources Plugin.
|
||||||
*
|
*
|
||||||
* @goal build-pom
|
* @goal remote-pom
|
||||||
*
|
*
|
||||||
* @author Benjamin Bentmann
|
* @author Benjamin Bentmann
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class BuildPomMojo
|
public class BuildRemotePomMojo
|
||||||
extends AbstractMojo
|
extends AbstractPomMojo
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,13 +67,6 @@ public class BuildPomMojo
|
||||||
*/
|
*/
|
||||||
private List remoteRepositories;
|
private List remoteRepositories;
|
||||||
|
|
||||||
/**
|
|
||||||
* The artifact resolver.
|
|
||||||
*
|
|
||||||
* @component
|
|
||||||
*/
|
|
||||||
private MavenProjectBuilder builder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The artifact factory.
|
* The artifact factory.
|
||||||
*
|
*
|
||||||
|
@ -99,7 +87,7 @@ public class BuildPomMojo
|
||||||
* @throws MojoFailureException If the artifact file has not been set.
|
* @throws MojoFailureException If the artifact file has not been set.
|
||||||
*/
|
*/
|
||||||
public void execute()
|
public void execute()
|
||||||
throws MojoExecutionException, MojoFailureException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
|
||||||
|
@ -122,20 +110,7 @@ public class BuildPomMojo
|
||||||
{
|
{
|
||||||
MavenProject project = builder.buildFromRepository( artifact, remoteRepositories, localRepository );
|
MavenProject project = builder.buildFromRepository( artifact, remoteRepositories, localRepository );
|
||||||
|
|
||||||
String key = artifact.getId() + ".";
|
dump( props, artifact.getId() + ".", project );
|
||||||
props.setProperty( key + "project.id", project.getId() );
|
|
||||||
if ( project.getName() != null )
|
|
||||||
{
|
|
||||||
props.setProperty( key + "project.name", project.getName() );
|
|
||||||
}
|
|
||||||
if ( project.getDescription() != null )
|
|
||||||
{
|
|
||||||
props.setProperty( key + "project.description", project.getDescription() );
|
|
||||||
}
|
|
||||||
if ( project.getArtifact() != null )
|
|
||||||
{
|
|
||||||
props.setProperty( key + "artifact.id", project.getArtifact().getId() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
|
@ -144,24 +119,7 @@ public class BuildPomMojo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
store( props, propertiesFile );
|
||||||
{
|
|
||||||
propertiesFile.getParentFile().mkdirs();
|
|
||||||
|
|
||||||
FileOutputStream os = new FileOutputStream( propertiesFile );
|
|
||||||
try
|
|
||||||
{
|
|
||||||
props.store( os, "[MAVEN-CORE-IT-LOG]" );
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
os.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new MojoExecutionException( "Failed to dump POMs: " + e.getMessage(), e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -55,6 +55,7 @@ under the License.
|
||||||
<module>maven-it-plugin-packaging</module>
|
<module>maven-it-plugin-packaging</module>
|
||||||
<module>maven-it-plugin-parameter-implementation</module>
|
<module>maven-it-plugin-parameter-implementation</module>
|
||||||
<module>maven-it-plugin-plugin-dependency</module>
|
<module>maven-it-plugin-plugin-dependency</module>
|
||||||
|
<module>maven-it-plugin-project</module>
|
||||||
<module>maven-it-plugin-project-interpolation</module>
|
<module>maven-it-plugin-project-interpolation</module>
|
||||||
<module>maven-it-plugin-setter</module>
|
<module>maven-it-plugin-setter</module>
|
||||||
<module>maven-it-plugin-singleton-component</module>
|
<module>maven-it-plugin-singleton-component</module>
|
||||||
|
|
Loading…
Reference in New Issue