You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2023/05/03 14:10:53 UTC
[maven-remote-resources-plugin] branch MRRESOURCES-127 created (now 58f363b)
This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a change to branch MRRESOURCES-127
in repository https://gitbox.apache.org/repos/asf/maven-remote-resources-plugin.git
at 58f363b [MRRESOURCES-127] Upgrade to parent POM 39 - reformat
This branch includes the following new commits:
new 7be0998 [MRRESOURCES-127] Upgrade to parent POM 39
new 58f363b [MRRESOURCES-127] Upgrade to parent POM 39 - reformat
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[maven-remote-resources-plugin] 01/02: [MRRESOURCES-127] Upgrade to parent POM 39
Posted by sj...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch MRRESOURCES-127
in repository https://gitbox.apache.org/repos/asf/maven-remote-resources-plugin.git
commit 7be0998a3adeed4330d2c538c66ea5f9db3e8e03
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Wed May 3 15:36:26 2023 +0200
[MRRESOURCES-127] Upgrade to parent POM 39
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 2a651dd..fd8639b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
- <version>37</version>
+ <version>39</version>
<relativePath />
</parent>
[maven-remote-resources-plugin] 02/02: [MRRESOURCES-127] Upgrade to parent POM 39 - reformat
Posted by sj...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch MRRESOURCES-127
in repository https://gitbox.apache.org/repos/asf/maven-remote-resources-plugin.git
commit 58f363babc7fd38228b06d889d38656cf12116b2
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Wed May 3 16:10:15 2023 +0200
[MRRESOURCES-127] Upgrade to parent POM 39 - reformat
---
pom.xml | 32 +-
.../remote/AbstractProcessRemoteResourcesMojo.java | 1012 ++++++++------------
.../AggregateProcessRemoteResourcesMojo.java | 34 +-
.../remote/BundleRemoteResourcesMojo.java | 98 +-
.../remote/ModelInheritanceAssembler.java | 558 +++++------
.../maven/plugin/resources/remote/ModelUtils.java | 239 ++---
.../remote/ProcessRemoteResourcesMojo.java | 22 +-
.../remote/RemoteResourcesClassLoader.java | 30 +-
.../resources/remote/RemoteResourcesMojoTest.java | 514 ++++------
.../plugin/resources/remote/it/AbstractIT.java | 10 +-
.../resources/remote/it/IT_BadDependencyPoms.java | 51 +-
.../remote/it/IT_CustomFilterDelimiter.java | 34 +-
.../remote/it/IT_FilterLocalOverride.java | 32 +-
.../resources/remote/it/IT_GenerateFromBundle.java | 32 +-
...IT_GenerateFromBundleWithTypeAndClassifier.java | 32 +-
.../remote/it/IT_GenerateFromOverride.java | 32 +-
.../remote/it/IT_GetDependencyProjects.java | 50 +-
.../remote/it/IT_RunOnlyAtExecutionRoot.java | 57 +-
.../remote/it/IT_SupplementalArtifact.java | 44 +-
.../remote/it/support/BootstrapInstaller.java | 21 +-
.../resources/remote/it/support/TestUtils.java | 53 +-
.../plugin/resources/remote/stub/ArtifactStub.java | 177 +---
.../remote/stub/MavenProjectBasicStub.java | 91 +-
.../remote/stub/MavenProjectBuildStub.java | 199 ++--
.../remote/stub/MavenProjectResourcesStub.java | 86 +-
.../plugin/resources/remote/stub/ModelStub.java | 39 +-
26 files changed, 1388 insertions(+), 2191 deletions(-)
diff --git a/pom.xml b/pom.xml
index fd8639b..d5e9098 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,4 @@
-<?xml version='1.0' encoding='UTF-8'?>
-
+<?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
@@ -18,7 +17,6 @@ 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -34,13 +32,11 @@ under the License.
<packaging>maven-plugin</packaging>
<name>Apache Maven Remote Resources Plugin</name>
- <description>
- Process resources packaged in JARs that have been deployed to
+ <description>Process resources packaged in JARs that have been deployed to
a remote repository. The primary use case being satisfied is the consistent
inclusion of common resources in a large set of projects. Maven projects at
Apache use this plug-in to satisfy licensing requirements at Apache where
- each project must include license and notice files for each release.
- </description>
+ each project must include license and notice files for each release.</description>
<prerequisites>
<maven>${mavenVersion}</maven>
@@ -49,8 +45,8 @@ under the License.
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-remote-resources-plugin.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-remote-resources-plugin.git</developerConnection>
- <url>https://github.com/apache/maven-remote-resources-plugin/tree/${project.scm.tag}</url>
<tag>HEAD</tag>
+ <url>https://github.com/apache/maven-remote-resources-plugin/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
<system>JIRA</system>
@@ -233,10 +229,10 @@ under the License.
<executions>
<execution>
<id>generate-xsd-site-remote-resources</id>
- <phase>pre-site</phase>
<goals>
<goal>xsd</goal>
</goals>
+ <phase>pre-site</phase>
<configuration>
<version>1.1.0</version>
<outputDirectory>${project.reporting.outputDirectory}/xsd</outputDirectory>
@@ -247,10 +243,10 @@ under the License.
</execution>
<execution>
<id>generate-xsd-site-supplemental-model</id>
- <phase>pre-site</phase>
<goals>
<goal>xsd</goal>
</goals>
+ <phase>pre-site</phase>
<configuration>
<version>1.0.0</version>
<outputDirectory>${project.reporting.outputDirectory}/xsd</outputDirectory>
@@ -261,10 +257,10 @@ under the License.
</execution>
<execution>
<id>site-docs-remote-resources</id>
- <phase>pre-site</phase>
<goals>
<goal>xdoc</goal>
</goals>
+ <phase>pre-site</phase>
<configuration>
<version>1.1.0</version>
<models>
@@ -274,10 +270,10 @@ under the License.
</execution>
<execution>
<id>site-docs-supplemental-models</id>
- <phase>pre-site</phase>
<goals>
<goal>xdoc</goal>
</goals>
+ <phase>pre-site</phase>
<configuration>
<version>1.0.0</version>
<models>
@@ -338,19 +334,21 @@ under the License.
<build>
<testResources>
<testResource>
- <directory>src/it/resources</directory>
<filtering>true</filtering>
+ <directory>src/it/resources</directory>
<excludes>
<exclude>custom-filter-delim/src/main/resources/**</exclude>
- <exclude>**/*.jar</exclude> <!-- maven-filtering chokes on JARs -->
+ <exclude>**/*.jar</exclude>
+ <!-- maven-filtering chokes on JARs -->
</excludes>
</testResource>
<testResource>
- <directory>src/it/resources</directory>
<filtering>false</filtering>
+ <directory>src/it/resources</directory>
<includes>
<include>custom-filter-delim/src/main/resources/**</include>
- <include>**/*.jar</include> <!-- maven-filtering chokes on JARs -->
+ <include>**/*.jar</include>
+ <!-- maven-filtering chokes on JARs -->
</includes>
</testResource>
</testResources>
@@ -383,10 +381,10 @@ under the License.
<executions>
<execution>
<id>install-descriptor</id>
- <phase>pre-integration-test</phase>
<goals>
<goal>install</goal>
</goals>
+ <phase>pre-integration-test</phase>
<configuration>
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
</configuration>
diff --git a/src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java b/src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java
index c814604..e42e81b 100644
--- a/src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java
+++ b/src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugin.resources.remote;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -123,9 +122,7 @@ import org.eclipse.aether.util.artifact.JavaScopes;
* This is a support abstract class, with two non-aggregating and aggregating implementations.
* </p>
*/
-public abstract class AbstractProcessRemoteResourcesMojo
- extends AbstractMojo
-{
+public abstract class AbstractProcessRemoteResourcesMojo extends AbstractMojo {
private static final String TEMPLATE_SUFFIX = ".vm";
/**
@@ -155,25 +152,25 @@ public abstract class AbstractProcessRemoteResourcesMojo
/**
* @since 1.1
*/
- @Parameter( defaultValue = "true" )
+ @Parameter(defaultValue = "true")
protected boolean useDefaultFilterDelimiters;
/**
* The character encoding scheme to be applied when filtering resources.
*/
- @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
+ @Parameter(property = "encoding", defaultValue = "${project.build.sourceEncoding}")
protected String encoding;
/**
* The directory where processed resources will be placed for packaging.
*/
- @Parameter( defaultValue = "${project.build.directory}/maven-shared-archive-resources" )
+ @Parameter(defaultValue = "${project.build.directory}/maven-shared-archive-resources")
private File outputDirectory;
/**
* The directory containing extra information appended to the generated resources.
*/
- @Parameter( defaultValue = "${basedir}/src/main/appended-resources" )
+ @Parameter(defaultValue = "${basedir}/src/main/appended-resources")
private File appendedResourcesDirectory;
/**
@@ -201,7 +198,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
* The resource bundles that will be retrieved and processed,
* expressed with <code>groupId:artifactId:version[:type[:classifier]]</code> format.
*/
- @Parameter( required = true )
+ @Parameter(required = true)
private List<String> resourceBundles;
/**
@@ -209,7 +206,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
*
* @since 1.0-alpha-5
*/
- @Parameter( property = "remoteresources.skip", defaultValue = "false" )
+ @Parameter(property = "remoteresources.skip", defaultValue = "false")
private boolean skip;
/**
@@ -217,7 +214,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
*
* @since 1.5
*/
- @Parameter( defaultValue = "true", property = "attachToMain" )
+ @Parameter(defaultValue = "true", property = "attachToMain")
private boolean attachToMain;
/**
@@ -225,7 +222,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
*
* @since 1.5
*/
- @Parameter( defaultValue = "true", property = "attachToTest" )
+ @Parameter(defaultValue = "true", property = "attachToTest")
private boolean attachToTest;
/**
@@ -249,7 +246,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
*
* @since 1.2
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
protected boolean includeProjectProperties = false;
/**
@@ -259,19 +256,19 @@ public abstract class AbstractProcessRemoteResourcesMojo
*
* @since 1.6
*/
- @Parameter( defaultValue = "5242880" )
+ @Parameter(defaultValue = "5242880")
protected int velocityFilterInMemoryThreshold = 5 * 1024 * 1024;
/**
* The Maven session.
*/
- @Parameter( defaultValue = "${session}", readonly = true, required = true )
+ @Parameter(defaultValue = "${session}", readonly = true, required = true)
protected MavenSession mavenSession;
/**
* The current project.
*/
- @Parameter( defaultValue = "${project}", readonly = true, required = true )
+ @Parameter(defaultValue = "${project}", readonly = true, required = true)
protected MavenProject project;
/**
@@ -279,7 +276,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
*
* @since 1.0
*/
- @Parameter( property = "includeScope", defaultValue = "runtime" )
+ @Parameter(property = "includeScope", defaultValue = "runtime")
protected String includeScope;
/**
@@ -287,7 +284,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
*
* @since 1.0
*/
- @Parameter( property = "excludeScope", defaultValue = "" )
+ @Parameter(property = "excludeScope", defaultValue = "")
protected String excludeScope;
/**
@@ -306,7 +303,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
*
* @since 1.0
*/
- @Parameter( property = "excludeArtifactIds", defaultValue = "" )
+ @Parameter(property = "excludeArtifactIds", defaultValue = "")
protected String excludeArtifactIds;
/**
@@ -314,7 +311,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
*
* @since 1.0
*/
- @Parameter( property = "includeArtifactIds", defaultValue = "" )
+ @Parameter(property = "includeArtifactIds", defaultValue = "")
protected String includeArtifactIds;
/**
@@ -322,7 +319,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
*
* @since 1.0
*/
- @Parameter( property = "excludeGroupIds", defaultValue = "" )
+ @Parameter(property = "excludeGroupIds", defaultValue = "")
protected String excludeGroupIds;
/**
@@ -330,7 +327,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
*
* @since 1.0
*/
- @Parameter( property = "includeGroupIds", defaultValue = "" )
+ @Parameter(property = "includeGroupIds", defaultValue = "")
protected String includeGroupIds;
/**
@@ -338,7 +335,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
*
* @since 1.0
*/
- @Parameter( property = "excludeTransitive", defaultValue = "false" )
+ @Parameter(property = "excludeTransitive", defaultValue = "false")
protected boolean excludeTransitive;
/**
@@ -346,7 +343,7 @@ public abstract class AbstractProcessRemoteResourcesMojo
* <code>yyyy-MM-dd'T'HH:mm:ssXXX</code> or as an int representing seconds since the epoch (like
* <a href="https://reproducible-builds.org/docs/source-date-epoch/">SOURCE_DATE_EPOCH</a>).
*/
- @Parameter( defaultValue = "${project.build.outputTimestamp}" )
+ @Parameter(defaultValue = "${project.build.outputTimestamp}")
private String outputTimestamp;
@Component
@@ -381,231 +378,186 @@ public abstract class AbstractProcessRemoteResourcesMojo
private VelocityEngine velocity;
@Override
- public void execute()
- throws MojoExecutionException
- {
- if ( skip )
- {
- getLog().info( "Skipping remote resources execution." );
+ public void execute() throws MojoExecutionException {
+ if (skip) {
+ getLog().info("Skipping remote resources execution.");
return;
}
- if ( StringUtils.isEmpty( encoding ) )
- {
- getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
- + ", i.e. build is platform dependent!" );
+ if (StringUtils.isEmpty(encoding)) {
+ getLog().warn("File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
+ + ", i.e. build is platform dependent!");
}
- if ( resolveScopes == null )
- {
- resolveScopes =
- new String[] {StringUtils.isEmpty( this.includeScope ) ? JavaScopes.TEST : this.includeScope};
+ if (resolveScopes == null) {
+ resolveScopes = new String[] {StringUtils.isEmpty(this.includeScope) ? JavaScopes.TEST : this.includeScope};
}
- if ( supplementalModels == null )
- {
- File sups = new File( appendedResourcesDirectory, "supplemental-models.xml" );
- if ( sups.exists() )
- {
- try
- {
+ if (supplementalModels == null) {
+ File sups = new File(appendedResourcesDirectory, "supplemental-models.xml");
+ if (sups.exists()) {
+ try {
supplementalModels = new String[] {sups.toURI().toURL().toString()};
- }
- catch ( MalformedURLException e )
- {
+ } catch (MalformedURLException e) {
// ignore
- getLog().debug( "URL issue with supplemental-models.xml: " + e );
+ getLog().debug("URL issue with supplemental-models.xml: " + e);
}
}
}
configureLocator();
- if ( includeProjectProperties )
- {
+ if (includeProjectProperties) {
final Properties projectProperties = project.getProperties();
- for ( Object key : projectProperties.keySet() )
- {
- properties.put( key.toString(), projectProperties.get( key ).toString() );
+ for (Object key : projectProperties.keySet()) {
+ properties.put(key.toString(), projectProperties.get(key).toString());
}
}
ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
- try
- {
+ try {
validate();
- List<File> resourceBundleArtifacts = downloadBundles( resourceBundles );
- supplementModels = loadSupplements( supplementalModels );
+ List<File> resourceBundleArtifacts = downloadBundles(resourceBundles);
+ supplementModels = loadSupplements(supplementalModels);
- ClassLoader classLoader = initalizeClassloader( resourceBundleArtifacts );
+ ClassLoader classLoader = initalizeClassloader(resourceBundleArtifacts);
- Thread.currentThread().setContextClassLoader( classLoader );
+ Thread.currentThread().setContextClassLoader(classLoader);
velocity = new VelocityEngine();
- velocity.setProperty( "resource.loaders", "classpath" );
- velocity.setProperty( "resource.loader.classpath.class", ClasspathResourceLoader.class.getName() );
+ velocity.setProperty("resource.loaders", "classpath");
+ velocity.setProperty("resource.loader.classpath.class", ClasspathResourceLoader.class.getName());
velocity.init();
- VelocityContext context = buildVelocityContext( properties );
+ VelocityContext context = buildVelocityContext(properties);
- processResourceBundles( classLoader, context );
+ processResourceBundles(classLoader, context);
- if ( outputDirectory.exists() )
- {
+ if (outputDirectory.exists()) {
// ----------------------------------------------------------------------------
// Push our newly generated resources directory into the MavenProject so that
// these resources can be picked up by the process-resources phase.
// ----------------------------------------------------------------------------
Resource resource = new Resource();
- resource.setDirectory( outputDirectory.getAbsolutePath() );
+ resource.setDirectory(outputDirectory.getAbsolutePath());
// MRRESOURCES-61 handle main and test resources separately
- if ( attachToMain )
- {
- project.getResources().add( resource );
+ if (attachToMain) {
+ project.getResources().add(resource);
}
- if ( attachToTest )
- {
- project.getTestResources().add( resource );
+ if (attachToTest) {
+ project.getTestResources().add(resource);
}
// ----------------------------------------------------------------------------
// Write out archiver dot file
// ----------------------------------------------------------------------------
- try
- {
- File dotFile = new File( project.getBuild().getDirectory(), ".plxarc" );
- FileUtils.mkdir( dotFile.getParentFile().getAbsolutePath() );
- FileUtils.fileWrite( dotFile.getAbsolutePath(), outputDirectory.getName() );
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Error creating dot file for archiving instructions.", e );
+ try {
+ File dotFile = new File(project.getBuild().getDirectory(), ".plxarc");
+ FileUtils.mkdir(dotFile.getParentFile().getAbsolutePath());
+ FileUtils.fileWrite(dotFile.getAbsolutePath(), outputDirectory.getName());
+ } catch (IOException e) {
+ throw new MojoExecutionException("Error creating dot file for archiving instructions.", e);
}
}
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( origLoader );
+ } finally {
+ Thread.currentThread().setContextClassLoader(origLoader);
}
}
- private void configureLocator()
- throws MojoExecutionException
- {
- if ( supplementalModelArtifacts != null && !supplementalModelArtifacts.isEmpty() )
- {
- List<File> artifacts = downloadBundles( supplementalModelArtifacts );
-
- for ( File artifact : artifacts )
- {
- if ( artifact.isDirectory() )
- {
- locator.addSearchPath( FileResourceLoader.ID, artifact.getAbsolutePath() );
- }
- else
- {
- try
- {
- locator.addSearchPath( "jar", "jar:" + artifact.toURI().toURL().toExternalForm() );
- }
- catch ( MalformedURLException e )
- {
- throw new MojoExecutionException( "Could not use jar " + artifact.getAbsolutePath(), e );
+ private void configureLocator() throws MojoExecutionException {
+ if (supplementalModelArtifacts != null && !supplementalModelArtifacts.isEmpty()) {
+ List<File> artifacts = downloadBundles(supplementalModelArtifacts);
+
+ for (File artifact : artifacts) {
+ if (artifact.isDirectory()) {
+ locator.addSearchPath(FileResourceLoader.ID, artifact.getAbsolutePath());
+ } else {
+ try {
+ locator.addSearchPath(
+ "jar", "jar:" + artifact.toURI().toURL().toExternalForm());
+ } catch (MalformedURLException e) {
+ throw new MojoExecutionException("Could not use jar " + artifact.getAbsolutePath(), e);
}
}
}
-
}
- locator.addSearchPath( FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath() );
- if ( appendedResourcesDirectory != null )
- {
- locator.addSearchPath( FileResourceLoader.ID, appendedResourcesDirectory.getAbsolutePath() );
+ locator.addSearchPath(
+ FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath());
+ if (appendedResourcesDirectory != null) {
+ locator.addSearchPath(FileResourceLoader.ID, appendedResourcesDirectory.getAbsolutePath());
}
- locator.addSearchPath( "url", "" );
- locator.setOutputDirectory( new File( project.getBuild().getDirectory() ) );
+ locator.addSearchPath("url", "");
+ locator.setOutputDirectory(new File(project.getBuild().getDirectory()));
}
- protected List<MavenProject> getProjects()
- {
+ protected List<MavenProject> getProjects() {
List<MavenProject> projects = new ArrayList<>();
// add filters in well known order, least specific to most specific
FilterArtifacts filter = new FilterArtifacts();
Set<Artifact> artifacts = new LinkedHashSet<>();
- artifacts.addAll( getAllDependencies() );
- if ( this.excludeTransitive )
- {
- filter.addFilter( new ProjectTransitivityFilter( getDirectDependencies(), true ) );
+ artifacts.addAll(getAllDependencies());
+ if (this.excludeTransitive) {
+ filter.addFilter(new ProjectTransitivityFilter(getDirectDependencies(), true));
}
- filter.addFilter( new ScopeFilter( this.includeScope, this.excludeScope ) );
- filter.addFilter( new GroupIdFilter( this.includeGroupIds, this.excludeGroupIds ) );
- filter.addFilter( new ArtifactIdFilter( this.includeArtifactIds, this.excludeArtifactIds ) );
+ filter.addFilter(new ScopeFilter(this.includeScope, this.excludeScope));
+ filter.addFilter(new GroupIdFilter(this.includeGroupIds, this.excludeGroupIds));
+ filter.addFilter(new ArtifactIdFilter(this.includeArtifactIds, this.excludeArtifactIds));
// perform filtering
- try
- {
- artifacts = filter.filter( artifacts );
- }
- catch ( ArtifactFilterException e )
- {
- throw new IllegalStateException( e.getMessage(), e );
+ try {
+ artifacts = filter.filter(artifacts);
+ } catch (ArtifactFilterException e) {
+ throw new IllegalStateException(e.getMessage(), e);
}
- getLog().debug( "PROJECTS: " + artifacts );
+ getLog().debug("PROJECTS: " + artifacts);
- for ( Artifact artifact : artifacts )
- {
- if ( artifact.isSnapshot() )
- {
- artifact.setVersion( artifact.getBaseVersion() );
+ for (Artifact artifact : artifacts) {
+ if (artifact.isSnapshot()) {
+ artifact.setVersion(artifact.getBaseVersion());
}
- getLog().debug( "Building project for " + artifact );
+ getLog().debug("Building project for " + artifact);
MavenProject p;
- try
- {
+ try {
ProjectBuildingRequest req = new DefaultProjectBuildingRequest()
- .setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL )
- .setProcessPlugins( false )
- .setRepositorySession( mavenSession.getRepositorySession() )
- .setSystemProperties( mavenSession.getSystemProperties() )
- .setUserProperties( mavenSession.getUserProperties() )
- .setLocalRepository( mavenSession.getLocalRepository() )
- .setRemoteRepositories( project.getRemoteArtifactRepositories() );
- ProjectBuildingResult res = projectBuilder.build( artifact, req );
+ .setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL)
+ .setProcessPlugins(false)
+ .setRepositorySession(mavenSession.getRepositorySession())
+ .setSystemProperties(mavenSession.getSystemProperties())
+ .setUserProperties(mavenSession.getUserProperties())
+ .setLocalRepository(mavenSession.getLocalRepository())
+ .setRemoteRepositories(project.getRemoteArtifactRepositories());
+ ProjectBuildingResult res = projectBuilder.build(artifact, req);
p = res.getProject();
- }
- catch ( ProjectBuildingException e )
- {
- getLog().warn( "Invalid project model for artifact [" + artifact.getGroupId() + ":"
+ } catch (ProjectBuildingException e) {
+ getLog().warn("Invalid project model for artifact [" + artifact.getGroupId() + ":"
+ artifact.getArtifactId() + ":" + artifact.getVersion() + "]. "
- + "It will be ignored by the remote resources Mojo." );
+ + "It will be ignored by the remote resources Mojo.");
continue;
}
- String supplementKey =
- generateSupplementMapKey( p.getModel().getGroupId(), p.getModel().getArtifactId() );
-
- if ( supplementModels.containsKey( supplementKey ) )
- {
- Model mergedModel = mergeModels( p.getModel(), supplementModels.get( supplementKey ) );
- MavenProject mergedProject = new MavenProject( mergedModel );
- projects.add( mergedProject );
- mergedProject.setArtifact( artifact );
- mergedProject.setVersion( artifact.getVersion() );
- getLog().debug( "Adding project with groupId [" + mergedProject.getGroupId() + "] (supplemented)" );
- }
- else
- {
- projects.add( p );
- getLog().debug( "Adding project with groupId [" + p.getGroupId() + "]" );
+ String supplementKey = generateSupplementMapKey(
+ p.getModel().getGroupId(), p.getModel().getArtifactId());
+
+ if (supplementModels.containsKey(supplementKey)) {
+ Model mergedModel = mergeModels(p.getModel(), supplementModels.get(supplementKey));
+ MavenProject mergedProject = new MavenProject(mergedModel);
+ projects.add(mergedProject);
+ mergedProject.setArtifact(artifact);
+ mergedProject.setVersion(artifact.getVersion());
+ getLog().debug("Adding project with groupId [" + mergedProject.getGroupId() + "] (supplemented)");
+ } else {
+ projects.add(p);
+ getLog().debug("Adding project with groupId [" + p.getGroupId() + "]");
}
}
- projects.sort( new ProjectComparator() );
+ projects.sort(new ProjectComparator());
return projects;
}
@@ -619,129 +571,97 @@ public abstract class AbstractProcessRemoteResourcesMojo
*/
protected abstract Set<Artifact> getDirectDependencies();
- protected Map<Organization, List<MavenProject>> getProjectsSortedByOrganization( List<MavenProject> projects )
- {
- Map<Organization, List<MavenProject>> organizations =
- new TreeMap<>( new OrganizationComparator() );
+ protected Map<Organization, List<MavenProject>> getProjectsSortedByOrganization(List<MavenProject> projects) {
+ Map<Organization, List<MavenProject>> organizations = new TreeMap<>(new OrganizationComparator());
List<MavenProject> unknownOrganization = new ArrayList<>();
- for ( MavenProject p : projects )
- {
- if ( p.getOrganization() != null && StringUtils.isNotEmpty( p.getOrganization().getName() ) )
- {
- List<MavenProject> sortedProjects = organizations.get( p.getOrganization() );
- if ( sortedProjects == null )
- {
+ for (MavenProject p : projects) {
+ if (p.getOrganization() != null
+ && StringUtils.isNotEmpty(p.getOrganization().getName())) {
+ List<MavenProject> sortedProjects = organizations.get(p.getOrganization());
+ if (sortedProjects == null) {
sortedProjects = new ArrayList<>();
}
- sortedProjects.add( p );
+ sortedProjects.add(p);
- organizations.put( p.getOrganization(), sortedProjects );
- }
- else
- {
- unknownOrganization.add( p );
+ organizations.put(p.getOrganization(), sortedProjects);
+ } else {
+ unknownOrganization.add(p);
}
}
- if ( !unknownOrganization.isEmpty() )
- {
+ if (!unknownOrganization.isEmpty()) {
Organization unknownOrg = new Organization();
- unknownOrg.setName( "an unknown organization" );
- organizations.put( unknownOrg, unknownOrganization );
+ unknownOrg.setName("an unknown organization");
+ organizations.put(unknownOrg, unknownOrganization);
}
return organizations;
}
- protected boolean copyResourceIfExists( File file, String relFileName, VelocityContext context )
- throws IOException, MojoExecutionException
- {
- for ( Resource resource : project.getResources() )
- {
- File resourceDirectory = new File( resource.getDirectory() );
+ protected boolean copyResourceIfExists(File file, String relFileName, VelocityContext context)
+ throws IOException, MojoExecutionException {
+ for (Resource resource : project.getResources()) {
+ File resourceDirectory = new File(resource.getDirectory());
- if ( !resourceDirectory.exists() )
- {
+ if (!resourceDirectory.exists()) {
continue;
}
// TODO - really should use the resource includes/excludes and name mapping
- File source = new File( resourceDirectory, relFileName );
- File templateSource = new File( resourceDirectory, relFileName + TEMPLATE_SUFFIX );
+ File source = new File(resourceDirectory, relFileName);
+ File templateSource = new File(resourceDirectory, relFileName + TEMPLATE_SUFFIX);
- if ( !source.exists() && templateSource.exists() )
- {
+ if (!source.exists() && templateSource.exists()) {
source = templateSource;
}
- if ( source.exists() && !source.equals( file ) )
- {
- if ( source == templateSource )
- {
- try ( DeferredFileOutputStream os =
- new DeferredFileOutputStream( velocityFilterInMemoryThreshold, file ) )
- {
- try ( Reader reader = getReader( source ); Writer writer = getWriter( os ) )
- {
- velocity.evaluate( context, writer, "", reader );
+ if (source.exists() && !source.equals(file)) {
+ if (source == templateSource) {
+ try (DeferredFileOutputStream os =
+ new DeferredFileOutputStream(velocityFilterInMemoryThreshold, file)) {
+ try (Reader reader = getReader(source);
+ Writer writer = getWriter(os)) {
+ velocity.evaluate(context, writer, "", reader);
+ } catch (ParseErrorException | MethodInvocationException | ResourceNotFoundException e) {
+ throw new MojoExecutionException("Error rendering velocity resource: " + source, e);
}
- catch ( ParseErrorException | MethodInvocationException | ResourceNotFoundException e )
- {
- throw new MojoExecutionException( "Error rendering velocity resource: " + source, e );
- }
- fileWriteIfDiffers( os );
+ fileWriteIfDiffers(os);
}
- }
- else if ( resource.isFiltering() )
- {
+ } else if (resource.isFiltering()) {
- MavenFileFilterRequest req = setupRequest( resource, source, file );
+ MavenFileFilterRequest req = setupRequest(resource, source, file);
- try
- {
- fileFilter.copyFile( req );
- }
- catch ( MavenFilteringException e )
- {
- throw new MojoExecutionException( "Error filtering resource: " + source, e );
+ try {
+ fileFilter.copyFile(req);
+ } catch (MavenFilteringException e) {
+ throw new MojoExecutionException("Error filtering resource: " + source, e);
}
- }
- else
- {
- FileUtils.copyFile( source, file );
+ } else {
+ FileUtils.copyFile(source, file);
}
// exclude the original (so eclipse doesn't complain about duplicate resources)
- resource.addExclude( relFileName );
+ resource.addExclude(relFileName);
return true;
}
-
}
return false;
}
- private Reader getReader( File source ) throws IOException
- {
- if ( encoding != null )
- {
- return new InputStreamReader( Files.newInputStream( source.toPath() ), encoding );
- }
- else
- {
- return ReaderFactory.newPlatformReader( source );
+ private Reader getReader(File source) throws IOException {
+ if (encoding != null) {
+ return new InputStreamReader(Files.newInputStream(source.toPath()), encoding);
+ } else {
+ return ReaderFactory.newPlatformReader(source);
}
}
- private Writer getWriter( OutputStream os ) throws IOException
- {
- if ( encoding != null )
- {
- return new OutputStreamWriter( os, encoding );
- }
- else
- {
- return WriterFactory.newPlatformWriter( os );
+ private Writer getWriter(OutputStream os) throws IOException {
+ if (encoding != null) {
+ return new OutputStreamWriter(os, encoding);
+ } else {
+ return WriterFactory.newPlatformWriter(os);
}
}
@@ -756,536 +676,413 @@ public abstract class AbstractProcessRemoteResourcesMojo
* @param outStream Deferred stream
* @throws IOException On IO error.
*/
- private void fileWriteIfDiffers( DeferredFileOutputStream outStream )
- throws IOException
- {
+ private void fileWriteIfDiffers(DeferredFileOutputStream outStream) throws IOException {
File file = outStream.getFile();
- if ( outStream.isThresholdExceeded() )
- {
- getLog().info(
- "File " + file + " was overwritten due to content limit threshold " + outStream.getThreshold()
- + " reached" );
+ if (outStream.isThresholdExceeded()) {
+ getLog().info("File " + file + " was overwritten due to content limit threshold " + outStream.getThreshold()
+ + " reached");
return;
}
boolean needOverwrite = true;
- if ( file.exists() )
- {
- try ( InputStream is = Files.newInputStream( file.toPath() );
- InputStream newContents = new ByteArrayInputStream( outStream.getData() ) )
- {
- needOverwrite = !IOUtil.contentEquals( is, newContents );
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( "File " + file + " contents " + ( needOverwrite ? "differs" : "does not differ" ) );
+ if (file.exists()) {
+ try (InputStream is = Files.newInputStream(file.toPath());
+ InputStream newContents = new ByteArrayInputStream(outStream.getData())) {
+ needOverwrite = !IOUtil.contentEquals(is, newContents);
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("File " + file + " contents " + (needOverwrite ? "differs" : "does not differ"));
}
}
}
- if ( !needOverwrite )
- {
- getLog().debug( "File " + file + " is up to date" );
+ if (!needOverwrite) {
+ getLog().debug("File " + file + " is up to date");
return;
}
- getLog().debug( "Writing " + file );
+ getLog().debug("Writing " + file);
- try ( OutputStream os = Files.newOutputStream( file.toPath() ) )
- {
- outStream.writeTo( os );
+ try (OutputStream os = Files.newOutputStream(file.toPath())) {
+ outStream.writeTo(os);
}
}
- private MavenFileFilterRequest setupRequest( Resource resource, File source, File file )
- {
+ private MavenFileFilterRequest setupRequest(Resource resource, File source, File file) {
MavenFileFilterRequest req = new MavenFileFilterRequest();
- req.setFrom( source );
- req.setTo( file );
- req.setFiltering( resource.isFiltering() );
+ req.setFrom(source);
+ req.setTo(file);
+ req.setFiltering(resource.isFiltering());
- req.setMavenProject( project );
- req.setMavenSession( mavenSession );
- req.setInjectProjectBuildFilters( true );
+ req.setMavenProject(project);
+ req.setMavenSession(mavenSession);
+ req.setInjectProjectBuildFilters(true);
- if ( encoding != null )
- {
- req.setEncoding( encoding );
+ if (encoding != null) {
+ req.setEncoding(encoding);
}
- if ( filterDelimiters != null && !filterDelimiters.isEmpty() )
- {
+ if (filterDelimiters != null && !filterDelimiters.isEmpty()) {
LinkedHashSet<String> delims = new LinkedHashSet<>();
- if ( useDefaultFilterDelimiters )
- {
- delims.addAll( req.getDelimiters() );
+ if (useDefaultFilterDelimiters) {
+ delims.addAll(req.getDelimiters());
}
- for ( String delim : filterDelimiters )
- {
- if ( delim == null )
- {
- delims.add( "${*}" );
- }
- else
- {
- delims.add( delim );
+ for (String delim : filterDelimiters) {
+ if (delim == null) {
+ delims.add("${*}");
+ } else {
+ delims.add(delim);
}
}
- req.setDelimiters( delims );
+ req.setDelimiters(delims);
}
return req;
}
- protected void validate()
- throws MojoExecutionException
- {
+ protected void validate() throws MojoExecutionException {
int bundleCount = 1;
- for ( String artifactDescriptor : resourceBundles )
- {
+ for (String artifactDescriptor : resourceBundles) {
// groupId:artifactId:version, groupId:artifactId:version:type
// or groupId:artifactId:version:type:classifier
- String[] s = StringUtils.split( artifactDescriptor, ":" );
+ String[] s = StringUtils.split(artifactDescriptor, ":");
- if ( s.length < 3 || s.length > 5 )
- {
+ if (s.length < 3 || s.length > 5) {
String position;
- if ( bundleCount == 1 )
- {
+ if (bundleCount == 1) {
position = "1st";
- }
- else if ( bundleCount == 2 )
- {
+ } else if (bundleCount == 2) {
position = "2nd";
- }
- else if ( bundleCount == 3 )
- {
+ } else if (bundleCount == 3) {
position = "3rd";
- }
- else
- {
+ } else {
position = bundleCount + "th";
}
- throw new MojoExecutionException( "The " + position
+ throw new MojoExecutionException("The " + position
+ " resource bundle configured must specify a groupId, artifactId, "
+ " version and, optionally, type and classifier for a remote resource bundle. "
+ "Must be of the form <resourceBundle>groupId:artifactId:version</resourceBundle>, "
+ "<resourceBundle>groupId:artifactId:version:type</resourceBundle> or "
- + "<resourceBundle>groupId:artifactId:version:type:classifier</resourceBundle>" );
+ + "<resourceBundle>groupId:artifactId:version:type:classifier</resourceBundle>");
}
bundleCount++;
}
-
}
private static final String KEY_PROJECTS = "projects";
private static final String KEY_PROJECTS_ORGS = "projectsSortedByOrganization";
- protected VelocityContext buildVelocityContext( Map<String, Object> properties )
- {
+ protected VelocityContext buildVelocityContext(Map<String, Object> properties) {
// the following properties are expensive to calculate, so we provide them lazily
- VelocityContext context = new VelocityContext( properties )
- {
+ VelocityContext context = new VelocityContext(properties) {
@Override
- public Object internalGet( String key )
- {
- Object result = super.internalGet( key );
- if ( result == null && key != null && key.startsWith( KEY_PROJECTS ) && containsKey( key ) )
- {
+ public Object internalGet(String key) {
+ Object result = super.internalGet(key);
+ if (result == null && key != null && key.startsWith(KEY_PROJECTS) && containsKey(key)) {
// calculate and put projects* properties
List<MavenProject> projects = getProjects();
- put( KEY_PROJECTS, projects );
- put( KEY_PROJECTS_ORGS, getProjectsSortedByOrganization( projects ) );
- return super.internalGet( key );
+ put(KEY_PROJECTS, projects);
+ put(KEY_PROJECTS_ORGS, getProjectsSortedByOrganization(projects));
+ return super.internalGet(key);
}
return result;
}
};
// to have a consistent getKeys()/containsKey() behaviour, keys must be present from the start
- context.put( KEY_PROJECTS, null );
- context.put( KEY_PROJECTS_ORGS, null );
+ context.put(KEY_PROJECTS, null);
+ context.put(KEY_PROJECTS_ORGS, null);
// the following properties are cheap to calculate, so we provide them eagerly
- // Reproducible Builds: try to use reproducible output timestamp
+ // Reproducible Builds: try to use reproducible output timestamp
MavenArchiver archiver = new MavenArchiver();
- Date outputDate = archiver.parseOutputTimestamp( outputTimestamp );
+ Date outputDate = archiver.parseOutputTimestamp(outputTimestamp);
String inceptionYear = project.getInceptionYear();
- String year = new SimpleDateFormat( "yyyy" ).format( ( outputDate == null ) ? new Date() : outputDate );
+ String year = new SimpleDateFormat("yyyy").format((outputDate == null) ? new Date() : outputDate);
- if ( StringUtils.isEmpty( inceptionYear ) )
- {
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( "inceptionYear not specified, defaulting to " + year );
+ if (StringUtils.isEmpty(inceptionYear)) {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("inceptionYear not specified, defaulting to " + year);
}
inceptionYear = year;
}
- context.put( "project", project );
- context.put( "presentYear", year );
- context.put( "locator", locator );
-
- if ( inceptionYear.equals( year ) )
- {
- context.put( "projectTimespan", year );
- }
- else
- {
- context.put( "projectTimespan", inceptionYear + "-" + year );
+ context.put("project", project);
+ context.put("presentYear", year);
+ context.put("locator", locator);
+
+ if (inceptionYear.equals(year)) {
+ context.put("projectTimespan", year);
+ } else {
+ context.put("projectTimespan", inceptionYear + "-" + year);
}
return context;
}
- private List<File> downloadBundles( List<String> bundles )
- throws MojoExecutionException
- {
+ private List<File> downloadBundles(List<String> bundles) throws MojoExecutionException {
List<File> bundleArtifacts = new ArrayList<>();
- for ( String artifactDescriptor : bundles )
- {
- getLog().info( "Preparing remote bundle " + artifactDescriptor );
+ for (String artifactDescriptor : bundles) {
+ getLog().info("Preparing remote bundle " + artifactDescriptor);
// groupId:artifactId:version[:type[:classifier]]
- String[] s = artifactDescriptor.split( ":" );
+ String[] s = artifactDescriptor.split(":");
File artifactFile = null;
// check if the artifact is part of the reactor
- if ( mavenSession != null )
- {
+ if (mavenSession != null) {
List<MavenProject> list = mavenSession.getProjects();
- for ( MavenProject p : list )
- {
- if ( s[0].equals( p.getGroupId() ) && s[1].equals( p.getArtifactId() )
- && s[2].equals( p.getVersion() ) )
- {
- if ( s.length >= 4 && "test-jar".equals( s[3] ) )
- {
- artifactFile = new File( p.getBuild().getTestOutputDirectory() );
- }
- else
- {
- artifactFile = new File( p.getBuild().getOutputDirectory() );
+ for (MavenProject p : list) {
+ if (s[0].equals(p.getGroupId()) && s[1].equals(p.getArtifactId()) && s[2].equals(p.getVersion())) {
+ if (s.length >= 4 && "test-jar".equals(s[3])) {
+ artifactFile = new File(p.getBuild().getTestOutputDirectory());
+ } else {
+ artifactFile = new File(p.getBuild().getOutputDirectory());
}
}
}
}
- if ( artifactFile == null || !artifactFile.exists() )
- {
+ if (artifactFile == null || !artifactFile.exists()) {
String g = s[0];
String a = s[1];
String v = s[2];
- String type = ( s.length >= 4 ? s[3] : "jar" );
- ArtifactType artifactType = RepositoryUtils.newArtifactType( type,
- artifactHandlerManager.getArtifactHandler( type ) );
- String classifier = ( s.length == 5 ? s[4] : artifactType.getClassifier() );
-
- DefaultArtifact artifact = new DefaultArtifact(
- g, a, classifier, artifactType.getExtension(), v, artifactType );
-
- try
- {
- ArtifactRequest request = new ArtifactRequest(
- artifact,
- project.getRemoteProjectRepositories(),
- "remote-resources" );
- ArtifactResult result = repoSystem.resolveArtifact(
- mavenSession.getRepositorySession(), request );
+ String type = (s.length >= 4 ? s[3] : "jar");
+ ArtifactType artifactType =
+ RepositoryUtils.newArtifactType(type, artifactHandlerManager.getArtifactHandler(type));
+ String classifier = (s.length == 5 ? s[4] : artifactType.getClassifier());
+
+ DefaultArtifact artifact =
+ new DefaultArtifact(g, a, classifier, artifactType.getExtension(), v, artifactType);
+
+ try {
+ ArtifactRequest request =
+ new ArtifactRequest(artifact, project.getRemoteProjectRepositories(), "remote-resources");
+ ArtifactResult result = repoSystem.resolveArtifact(mavenSession.getRepositorySession(), request);
artifactFile = result.getArtifact().getFile();
+ } catch (ArtifactResolutionException e) {
+ throw new MojoExecutionException("Error processing remote resources", e);
}
- catch ( ArtifactResolutionException e )
- {
- throw new MojoExecutionException( "Error processing remote resources", e );
- }
-
}
- bundleArtifacts.add( artifactFile );
+ bundleArtifacts.add(artifactFile);
}
return bundleArtifacts;
}
- private ClassLoader initalizeClassloader( List<File> artifacts )
- throws MojoExecutionException
- {
- RemoteResourcesClassLoader cl = new RemoteResourcesClassLoader( null );
- try
- {
- for ( File artifact : artifacts )
- {
- cl.addURL( artifact.toURI().toURL() );
+ private ClassLoader initalizeClassloader(List<File> artifacts) throws MojoExecutionException {
+ RemoteResourcesClassLoader cl = new RemoteResourcesClassLoader(null);
+ try {
+ for (File artifact : artifacts) {
+ cl.addURL(artifact.toURI().toURL());
}
return cl;
- }
- catch ( MalformedURLException e )
- {
- throw new MojoExecutionException( "Unable to configure resources classloader: " + e.getMessage(), e );
+ } catch (MalformedURLException e) {
+ throw new MojoExecutionException("Unable to configure resources classloader: " + e.getMessage(), e);
}
}
- protected void processResourceBundles( ClassLoader classLoader, VelocityContext context )
- throws MojoExecutionException
- {
- List<Map.Entry<String, RemoteResourcesBundle>> remoteResources =
- new ArrayList<>();
+ protected void processResourceBundles(ClassLoader classLoader, VelocityContext context)
+ throws MojoExecutionException {
+ List<Map.Entry<String, RemoteResourcesBundle>> remoteResources = new ArrayList<>();
int bundleCount = 0;
int resourceCount = 0;
// list remote resources form bundles
- try
- {
+ try {
RemoteResourcesBundleXpp3Reader bundleReader = new RemoteResourcesBundleXpp3Reader();
- for ( Enumeration<URL> e =
- classLoader.getResources( BundleRemoteResourcesMojo.RESOURCES_MANIFEST ); e.hasMoreElements(); )
- {
+ for (Enumeration<URL> e = classLoader.getResources(BundleRemoteResourcesMojo.RESOURCES_MANIFEST);
+ e.hasMoreElements(); ) {
URL url = e.nextElement();
bundleCount++;
- getLog().debug( "processResourceBundle on bundle#" + bundleCount + " " + url );
+ getLog().debug("processResourceBundle on bundle#" + bundleCount + " " + url);
RemoteResourcesBundle bundle;
- try ( InputStream in = url.openStream() )
- {
- bundle = bundleReader.read( in );
+ try (InputStream in = url.openStream()) {
+ bundle = bundleReader.read(in);
}
int n = 0;
- for ( String bundleResource : bundle.getRemoteResources() )
- {
+ for (String bundleResource : bundle.getRemoteResources()) {
n++;
resourceCount++;
- getLog().debug( "bundle#" + bundleCount + " resource#" + n + " " + bundleResource );
- remoteResources.add( new AbstractMap.SimpleEntry<>( bundleResource, bundle ) );
+ getLog().debug("bundle#" + bundleCount + " resource#" + n + " " + bundleResource);
+ remoteResources.add(new AbstractMap.SimpleEntry<>(bundleResource, bundle));
}
}
- }
- catch ( IOException ioe )
- {
- throw new MojoExecutionException( "Error finding remote resources manifests", ioe );
- }
- catch ( XmlPullParserException xppe )
- {
- throw new MojoExecutionException( "Error parsing remote resource bundle descriptor.", xppe );
+ } catch (IOException ioe) {
+ throw new MojoExecutionException("Error finding remote resources manifests", ioe);
+ } catch (XmlPullParserException xppe) {
+ throw new MojoExecutionException("Error parsing remote resource bundle descriptor.", xppe);
}
- getLog().info(
- "Copying " + resourceCount + " resource" + ( ( resourceCount > 1 ) ? "s" : "" ) + " from " + bundleCount
- + " bundle" + ( ( bundleCount > 1 ) ? "s" : "" ) + "." );
+ getLog().info("Copying " + resourceCount + " resource" + ((resourceCount > 1) ? "s" : "") + " from "
+ + bundleCount + " bundle" + ((bundleCount > 1) ? "s" : "") + ".");
String velocityResource = null;
- try
- {
+ try {
- for ( Map.Entry<String, RemoteResourcesBundle> entry : remoteResources )
- {
+ for (Map.Entry<String, RemoteResourcesBundle> entry : remoteResources) {
String bundleResource = entry.getKey();
RemoteResourcesBundle bundle = entry.getValue();
String projectResource = bundleResource;
boolean doVelocity = false;
- if ( projectResource.endsWith( TEMPLATE_SUFFIX ) )
- {
- projectResource = projectResource.substring( 0, projectResource.length() - 3 );
+ if (projectResource.endsWith(TEMPLATE_SUFFIX)) {
+ projectResource = projectResource.substring(0, projectResource.length() - 3);
velocityResource = bundleResource;
doVelocity = true;
}
// Don't overwrite resource that are already being provided.
- File f = new File( outputDirectory, projectResource );
-
- FileUtils.mkdir( f.getParentFile().getAbsolutePath() );
-
- if ( !copyResourceIfExists( f, projectResource, context ) )
- {
- if ( doVelocity )
- {
- try ( DeferredFileOutputStream os =
- new DeferredFileOutputStream( velocityFilterInMemoryThreshold, f ) )
- {
- try ( Writer writer = bundle.getSourceEncoding() == null ? new OutputStreamWriter( os )
- : new OutputStreamWriter( os, bundle.getSourceEncoding() ) )
- {
- if ( bundle.getSourceEncoding() == null )
- {
+ File f = new File(outputDirectory, projectResource);
+
+ FileUtils.mkdir(f.getParentFile().getAbsolutePath());
+
+ if (!copyResourceIfExists(f, projectResource, context)) {
+ if (doVelocity) {
+ try (DeferredFileOutputStream os =
+ new DeferredFileOutputStream(velocityFilterInMemoryThreshold, f)) {
+ try (Writer writer = bundle.getSourceEncoding() == null
+ ? new OutputStreamWriter(os)
+ : new OutputStreamWriter(os, bundle.getSourceEncoding())) {
+ if (bundle.getSourceEncoding() == null) {
// TODO: Is this correct? Shouldn't we behave like the rest of maven and fail
// down to JVM default instead ISO-8859-1 ?
- velocity.mergeTemplate( bundleResource, "ISO-8859-1", context, writer );
- }
- else
- {
- velocity.mergeTemplate( bundleResource, bundle.getSourceEncoding(), context,
- writer );
+ velocity.mergeTemplate(bundleResource, "ISO-8859-1", context, writer);
+ } else {
+ velocity.mergeTemplate(bundleResource, bundle.getSourceEncoding(), context, writer);
}
}
- fileWriteIfDiffers( os );
+ fileWriteIfDiffers(os);
}
- }
- else
- {
- URL resUrl = classLoader.getResource( bundleResource );
- if ( resUrl != null )
- {
- FileUtils.copyURLToFile( resUrl, f );
+ } else {
+ URL resUrl = classLoader.getResource(bundleResource);
+ if (resUrl != null) {
+ FileUtils.copyURLToFile(resUrl, f);
}
}
- File appendedResourceFile = new File( appendedResourcesDirectory, projectResource );
- File appendedVmResourceFile = new File( appendedResourcesDirectory, projectResource + ".vm" );
+ File appendedResourceFile = new File(appendedResourcesDirectory, projectResource);
+ File appendedVmResourceFile = new File(appendedResourcesDirectory, projectResource + ".vm");
- if ( appendedResourceFile.exists() )
- {
- getLog().info( "Copying appended resource: " + projectResource );
- try ( InputStream in = Files.newInputStream( appendedResourceFile.toPath() );
- OutputStream out = new FileOutputStream( f, true ) )
- {
- IOUtil.copy( in, out );
+ if (appendedResourceFile.exists()) {
+ getLog().info("Copying appended resource: " + projectResource);
+ try (InputStream in = Files.newInputStream(appendedResourceFile.toPath());
+ OutputStream out = new FileOutputStream(f, true)) {
+ IOUtil.copy(in, out);
}
- }
- else if ( appendedVmResourceFile.exists() )
- {
- getLog().info( "Filtering appended resource: " + projectResource + ".vm" );
-
+ } else if (appendedVmResourceFile.exists()) {
+ getLog().info("Filtering appended resource: " + projectResource + ".vm");
- try ( Reader reader = new FileReader( appendedVmResourceFile );
- Writer writer = getWriter( bundle, f ) )
- {
+ try (Reader reader = new FileReader(appendedVmResourceFile);
+ Writer writer = getWriter(bundle, f)) {
Velocity.init();
- Velocity.evaluate( context, writer, "remote-resources", reader );
+ Velocity.evaluate(context, writer, "remote-resources", reader);
}
}
}
}
- }
- catch ( IOException ioe )
- {
- throw new MojoExecutionException( "Error reading remote resource", ioe );
- }
- catch ( VelocityException e )
- {
- throw new MojoExecutionException( "Error rendering Velocity resource '" + velocityResource + "'", e );
+ } catch (IOException ioe) {
+ throw new MojoExecutionException("Error reading remote resource", ioe);
+ } catch (VelocityException e) {
+ throw new MojoExecutionException("Error rendering Velocity resource '" + velocityResource + "'", e);
}
}
- private Writer getWriter( RemoteResourcesBundle bundle, File f )
- throws IOException
- {
+ private Writer getWriter(RemoteResourcesBundle bundle, File f) throws IOException {
Writer writer;
- if ( bundle.getSourceEncoding() == null )
- {
- writer = new PrintWriter( new FileWriter( f, true ) );
- }
- else
- {
- writer = new PrintWriter( new OutputStreamWriter( new FileOutputStream( f, true ),
- bundle.getSourceEncoding() ) );
+ if (bundle.getSourceEncoding() == null) {
+ writer = new PrintWriter(new FileWriter(f, true));
+ } else {
+ writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(f, true), bundle.getSourceEncoding()));
}
return writer;
}
- protected Model getSupplement( Xpp3Dom supplementModelXml )
- throws MojoExecutionException
- {
+ protected Model getSupplement(Xpp3Dom supplementModelXml) throws MojoExecutionException {
MavenXpp3Reader modelReader = new MavenXpp3Reader();
Model model = null;
- try
- {
- model = modelReader.read( new StringReader( supplementModelXml.toString() ) );
+ try {
+ model = modelReader.read(new StringReader(supplementModelXml.toString()));
String groupId = model.getGroupId();
String artifactId = model.getArtifactId();
- if ( groupId == null || groupId.trim().equals( "" ) )
- {
- throw new MojoExecutionException( "Supplemental project XML "
- + "requires that a <groupId> element be present." );
+ if (groupId == null || groupId.trim().equals("")) {
+ throw new MojoExecutionException(
+ "Supplemental project XML " + "requires that a <groupId> element be present.");
}
- if ( artifactId == null || artifactId.trim().equals( "" ) )
- {
- throw new MojoExecutionException( "Supplemental project XML "
- + "requires that a <artifactId> element be present." );
+ if (artifactId == null || artifactId.trim().equals("")) {
+ throw new MojoExecutionException(
+ "Supplemental project XML " + "requires that a <artifactId> element be present.");
}
- }
- catch ( IOException e )
- {
- getLog().warn( "Unable to read supplemental XML: " + e.getMessage(), e );
- }
- catch ( XmlPullParserException e )
- {
- getLog().warn( "Unable to parse supplemental XML: " + e.getMessage(), e );
+ } catch (IOException e) {
+ getLog().warn("Unable to read supplemental XML: " + e.getMessage(), e);
+ } catch (XmlPullParserException e) {
+ getLog().warn("Unable to parse supplemental XML: " + e.getMessage(), e);
}
return model;
}
- protected Model mergeModels( Model parent, Model child )
- {
- inheritanceAssembler.assembleModelInheritance( child, parent );
+ protected Model mergeModels(Model parent, Model child) {
+ inheritanceAssembler.assembleModelInheritance(child, parent);
return child;
}
- private static String generateSupplementMapKey( String groupId, String artifactId )
- {
+ private static String generateSupplementMapKey(String groupId, String artifactId) {
return groupId.trim() + ":" + artifactId.trim();
}
- private Map<String, Model> loadSupplements( String[] models )
- throws MojoExecutionException
- {
- if ( models == null )
- {
- getLog().debug( "Supplemental data models won't be loaded. No models specified." );
+ private Map<String, Model> loadSupplements(String[] models) throws MojoExecutionException {
+ if (models == null) {
+ getLog().debug("Supplemental data models won't be loaded. No models specified.");
return Collections.emptyMap();
}
List<Supplement> supplements = new ArrayList<>();
- for ( String set : models )
- {
- getLog().debug( "Preparing ruleset: " + set );
- try
- {
- File f = locator.getResourceAsFile( set, getLocationTemp( set ) );
-
- if ( null == f || !f.exists() )
- {
- throw new MojoExecutionException( "Cold not resolve " + set );
+ for (String set : models) {
+ getLog().debug("Preparing ruleset: " + set);
+ try {
+ File f = locator.getResourceAsFile(set, getLocationTemp(set));
+
+ if (null == f || !f.exists()) {
+ throw new MojoExecutionException("Cold not resolve " + set);
}
- if ( !f.canRead() )
- {
- throw new MojoExecutionException( "Supplemental data models won't be loaded. " + "File "
- + f.getAbsolutePath() + " cannot be read, check permissions on the file." );
+ if (!f.canRead()) {
+ throw new MojoExecutionException("Supplemental data models won't be loaded. " + "File "
+ + f.getAbsolutePath() + " cannot be read, check permissions on the file.");
}
- getLog().debug( "Loading supplemental models from " + f.getAbsolutePath() );
+ getLog().debug("Loading supplemental models from " + f.getAbsolutePath());
SupplementalDataModelXpp3Reader reader = new SupplementalDataModelXpp3Reader();
- SupplementalDataModel supplementalModel = reader.read( new FileReader( f ) );
- supplements.addAll( supplementalModel.getSupplement() );
- }
- catch ( Exception e )
- {
+ SupplementalDataModel supplementalModel = reader.read(new FileReader(f));
+ supplements.addAll(supplementalModel.getSupplement());
+ } catch (Exception e) {
String msg = "Error loading supplemental data models: " + e.getMessage();
- getLog().error( msg, e );
- throw new MojoExecutionException( msg, e );
+ getLog().error(msg, e);
+ throw new MojoExecutionException(msg, e);
}
}
- getLog().debug( "Loading supplements complete." );
+ getLog().debug("Loading supplements complete.");
Map<String, Model> supplementMap = new HashMap<>();
- for ( Supplement sd : supplements )
- {
+ for (Supplement sd : supplements) {
Xpp3Dom dom = (Xpp3Dom) sd.getProject();
- Model m = getSupplement( dom );
- supplementMap.put( generateSupplementMapKey( m.getGroupId(), m.getArtifactId() ), m );
+ Model m = getSupplement(dom);
+ supplementMap.put(generateSupplementMapKey(m.getGroupId(), m.getArtifactId()), m);
}
return supplementMap;
@@ -1297,62 +1094,45 @@ public abstract class AbstractProcessRemoteResourcesMojo
* @param name the name of the file whose location is to be resolved
* @return a String that contains the absolute file name of the file
*/
- private String getLocationTemp( String name )
- {
+ private String getLocationTemp(String name) {
String loc = name;
- if ( loc.indexOf( '/' ) != -1 )
- {
- loc = loc.substring( loc.lastIndexOf( '/' ) + 1 );
+ if (loc.indexOf('/') != -1) {
+ loc = loc.substring(loc.lastIndexOf('/') + 1);
}
- if ( loc.indexOf( '\\' ) != -1 )
- {
- loc = loc.substring( loc.lastIndexOf( '\\' ) + 1 );
+ if (loc.indexOf('\\') != -1) {
+ loc = loc.substring(loc.lastIndexOf('\\') + 1);
}
- getLog().debug( "Before: " + name + " After: " + loc );
+ getLog().debug("Before: " + name + " After: " + loc);
return loc;
}
- static class OrganizationComparator
- implements Comparator<Organization>
- {
+ static class OrganizationComparator implements Comparator<Organization> {
@Override
- public int compare( Organization org1, Organization org2 )
- {
- int i = compareStrings( org1.getName(), org2.getName() );
- if ( i == 0 )
- {
- i = compareStrings( org1.getUrl(), org2.getUrl() );
+ public int compare(Organization org1, Organization org2) {
+ int i = compareStrings(org1.getName(), org2.getName());
+ if (i == 0) {
+ i = compareStrings(org1.getUrl(), org2.getUrl());
}
return i;
}
- private int compareStrings( String s1, String s2 )
- {
- if ( s1 == null && s2 == null )
- {
+ private int compareStrings(String s1, String s2) {
+ if (s1 == null && s2 == null) {
return 0;
- }
- else if ( s1 == null )
- {
+ } else if (s1 == null) {
return 1;
- }
- else if ( s2 == null )
- {
+ } else if (s2 == null) {
return -1;
}
- return s1.compareToIgnoreCase( s2 );
+ return s1.compareToIgnoreCase(s2);
}
}
- static class ProjectComparator
- implements Comparator<MavenProject>
- {
+ static class ProjectComparator implements Comparator<MavenProject> {
@Override
- public int compare( MavenProject p1, MavenProject p2 )
- {
- return p1.getArtifact().compareTo( p2.getArtifact() );
+ public int compare(MavenProject p1, MavenProject p2) {
+ return p1.getArtifact().compareTo(p2.getArtifact());
}
}
-
}
diff --git a/src/main/java/org/apache/maven/plugin/resources/remote/AggregateProcessRemoteResourcesMojo.java b/src/main/java/org/apache/maven/plugin/resources/remote/AggregateProcessRemoteResourcesMojo.java
index e65f1c5..339d02a 100644
--- a/src/main/java/org/apache/maven/plugin/resources/remote/AggregateProcessRemoteResourcesMojo.java
+++ b/src/main/java/org/apache/maven/plugin/resources/remote/AggregateProcessRemoteResourcesMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugin.resources.remote;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -40,32 +39,27 @@ import org.apache.maven.project.MavenProject;
* </p>
* Resources that don't end in ".vm" are copied "as is".
*/
-@Mojo( name = "aggregate",
- defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
- aggregator = true,
- requiresDependencyResolution = ResolutionScope.TEST,
- threadSafe = true )
-public class AggregateProcessRemoteResourcesMojo
- extends AbstractProcessRemoteResourcesMojo
-{
+@Mojo(
+ name = "aggregate",
+ defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
+ aggregator = true,
+ requiresDependencyResolution = ResolutionScope.TEST,
+ threadSafe = true)
+public class AggregateProcessRemoteResourcesMojo extends AbstractProcessRemoteResourcesMojo {
@Override
- protected Set<Artifact> getAllDependencies()
- {
+ protected Set<Artifact> getAllDependencies() {
LinkedHashSet<Artifact> result = new LinkedHashSet<>();
- for ( MavenProject mavenProject : mavenSession.getProjects() )
- {
- result.addAll( mavenProject.getArtifacts() );
+ for (MavenProject mavenProject : mavenSession.getProjects()) {
+ result.addAll(mavenProject.getArtifacts());
}
return result;
}
@Override
- protected Set<Artifact> getDirectDependencies()
- {
+ protected Set<Artifact> getDirectDependencies() {
LinkedHashSet<Artifact> result = new LinkedHashSet<>();
- for ( MavenProject mavenProject : mavenSession.getProjects() )
- {
- result.addAll( mavenProject.getDependencyArtifacts() );
+ for (MavenProject mavenProject : mavenSession.getProjects()) {
+ result.addAll(mavenProject.getDependencyArtifacts());
}
return result;
}
diff --git a/src/main/java/org/apache/maven/plugin/resources/remote/BundleRemoteResourcesMojo.java b/src/main/java/org/apache/maven/plugin/resources/remote/BundleRemoteResourcesMojo.java
index 379e4ec..c5211b6 100644
--- a/src/main/java/org/apache/maven/plugin/resources/remote/BundleRemoteResourcesMojo.java
+++ b/src/main/java/org/apache/maven/plugin/resources/remote/BundleRemoteResourcesMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,14 @@ package org.apache.maven.plugin.resources.remote;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.List;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -30,36 +36,28 @@ import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Arrays;
-import java.util.List;
-
/**
* Bundle up resources that should be considered as a remote-resource,
* generating <code>META-INF/maven/remote-resources.xml</code> descriptor.
*/
-@Mojo( name = "bundle", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true )
-public class BundleRemoteResourcesMojo
- extends AbstractMojo
-{
+@Mojo(name = "bundle", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true)
+public class BundleRemoteResourcesMojo extends AbstractMojo {
public static final String RESOURCES_MANIFEST = "META-INF/maven/remote-resources.xml";
- private static final String[] DEFAULT_INCLUDES = new String[]{ "**/*.txt", "**/*.vm", };
-
+ private static final String[] DEFAULT_INCLUDES = new String[] {
+ "**/*.txt", "**/*.vm",
+ };
/**
* The directory which contains the resources you want packaged up in this resource bundle.
*/
- @Parameter( defaultValue = "${basedir}/src/main/resources" )
+ @Parameter(defaultValue = "${basedir}/src/main/resources")
private File resourcesDirectory;
/**
* The directory where you want the resource bundle manifest written to.
*/
- @Parameter( defaultValue = "${project.build.outputDirectory}", required = true )
+ @Parameter(defaultValue = "${project.build.outputDirectory}", required = true)
private File outputDirectory;
/**
@@ -85,23 +83,19 @@ public class BundleRemoteResourcesMojo
*
* @since 1.1
*/
- @Parameter( defaultValue = "${project.build.sourceEncoding}" )
+ @Parameter(defaultValue = "${project.build.sourceEncoding}")
private String sourceEncoding;
@Override
- public void execute()
- throws MojoExecutionException
- {
- if ( !resourcesDirectory.exists() )
- {
- getLog().info( "skip non existing resourceDirectory " + resourcesDirectory.getAbsolutePath() );
+ public void execute() throws MojoExecutionException {
+ if (!resourcesDirectory.exists()) {
+ getLog().info("skip non existing resourceDirectory " + resourcesDirectory.getAbsolutePath());
return;
}
- if ( StringUtils.isEmpty( sourceEncoding ) )
- {
- getLog().warn( "sourceEncoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
- + ", i.e. build is platform dependent!" );
+ if (StringUtils.isEmpty(sourceEncoding)) {
+ getLog().warn("sourceEncoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
+ + ", i.e. build is platform dependent!");
sourceEncoding = ReaderFactory.FILE_ENCODING;
}
@@ -109,53 +103,43 @@ public class BundleRemoteResourcesMojo
// so that velocity can easily process any resources inside the JAR that need to be processed.
RemoteResourcesBundle remoteResourcesBundle = new RemoteResourcesBundle();
- remoteResourcesBundle.setSourceEncoding( sourceEncoding );
+ remoteResourcesBundle.setSourceEncoding(sourceEncoding);
DirectoryScanner scanner = new DirectoryScanner();
- scanner.setBasedir( resourcesDirectory );
- if ( includes != null && includes.length != 0 )
- {
- scanner.setIncludes( includes );
- }
- else
- {
- scanner.setIncludes( DEFAULT_INCLUDES );
+ scanner.setBasedir(resourcesDirectory);
+ if (includes != null && includes.length != 0) {
+ scanner.setIncludes(includes);
+ } else {
+ scanner.setIncludes(DEFAULT_INCLUDES);
}
- if ( excludes != null && excludes.length != 0 )
- {
- scanner.setExcludes( excludes );
+ if (excludes != null && excludes.length != 0) {
+ scanner.setExcludes(excludes);
}
scanner.addDefaultExcludes();
scanner.scan();
- List<String> includedFiles = Arrays.asList( scanner.getIncludedFiles() );
+ List<String> includedFiles = Arrays.asList(scanner.getIncludedFiles());
- for ( String resource : includedFiles )
- {
- remoteResourcesBundle.addRemoteResource( StringUtils.replace( resource, '\\', '/' ) );
+ for (String resource : includedFiles) {
+ remoteResourcesBundle.addRemoteResource(StringUtils.replace(resource, '\\', '/'));
}
int n = remoteResourcesBundle.getRemoteResources().size();
- getLog().info( "Writing " + RESOURCES_MANIFEST + " descriptor with " + n + " entr"
- + ( ( n > 1 ) ? "ies" : "y" ) );
+ getLog().info("Writing " + RESOURCES_MANIFEST + " descriptor with " + n + " entr" + ((n > 1) ? "ies" : "y"));
RemoteResourcesBundleXpp3Writer w = new RemoteResourcesBundleXpp3Writer();
- File f = new File( outputDirectory, RESOURCES_MANIFEST );
+ File f = new File(outputDirectory, RESOURCES_MANIFEST);
- FileUtils.mkdir( f.getParentFile()
- .getAbsolutePath() );
-
- try ( Writer writer = new FileWriter( f ) )
- {
- w.write( writer, remoteResourcesBundle );
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Error creating remote resources manifest.", e );
+ FileUtils.mkdir(f.getParentFile().getAbsolutePath());
+
+ try (Writer writer = new FileWriter(f)) {
+ w.write(writer, remoteResourcesBundle);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Error creating remote resources manifest.", e);
}
}
}
diff --git a/src/main/java/org/apache/maven/plugin/resources/remote/ModelInheritanceAssembler.java b/src/main/java/org/apache/maven/plugin/resources/remote/ModelInheritanceAssembler.java
index e713afd..1da5c2e 100644
--- a/src/main/java/org/apache/maven/plugin/resources/remote/ModelInheritanceAssembler.java
+++ b/src/main/java/org/apache/maven/plugin/resources/remote/ModelInheritanceAssembler.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.plugin.resources.remote;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.plugin.resources.remote;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -48,582 +47,481 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
* DefaultModelInheritanceAssembler
*/
-public class ModelInheritanceAssembler
-{
+public class ModelInheritanceAssembler {
// TODO Remove this!
- public void assembleBuildInheritance( Build childBuild, Build parentBuild, boolean handleAsInheritance )
- {
+ public void assembleBuildInheritance(Build childBuild, Build parentBuild, boolean handleAsInheritance) {
// The build has been set but we want to step in here and fill in
// values that have not been set by the child.
- if ( childBuild.getSourceDirectory() == null )
- {
- childBuild.setSourceDirectory( parentBuild.getSourceDirectory() );
+ if (childBuild.getSourceDirectory() == null) {
+ childBuild.setSourceDirectory(parentBuild.getSourceDirectory());
}
- if ( childBuild.getScriptSourceDirectory() == null )
- {
- childBuild.setScriptSourceDirectory( parentBuild.getScriptSourceDirectory() );
+ if (childBuild.getScriptSourceDirectory() == null) {
+ childBuild.setScriptSourceDirectory(parentBuild.getScriptSourceDirectory());
}
- if ( childBuild.getTestSourceDirectory() == null )
- {
- childBuild.setTestSourceDirectory( parentBuild.getTestSourceDirectory() );
+ if (childBuild.getTestSourceDirectory() == null) {
+ childBuild.setTestSourceDirectory(parentBuild.getTestSourceDirectory());
}
- if ( childBuild.getOutputDirectory() == null )
- {
- childBuild.setOutputDirectory( parentBuild.getOutputDirectory() );
+ if (childBuild.getOutputDirectory() == null) {
+ childBuild.setOutputDirectory(parentBuild.getOutputDirectory());
}
- if ( childBuild.getTestOutputDirectory() == null )
- {
- childBuild.setTestOutputDirectory( parentBuild.getTestOutputDirectory() );
+ if (childBuild.getTestOutputDirectory() == null) {
+ childBuild.setTestOutputDirectory(parentBuild.getTestOutputDirectory());
}
// Extensions are accumulated
- mergeExtensionLists( childBuild, parentBuild );
+ mergeExtensionLists(childBuild, parentBuild);
- if ( childBuild.getDirectory() == null )
- {
- childBuild.setDirectory( parentBuild.getDirectory() );
+ if (childBuild.getDirectory() == null) {
+ childBuild.setDirectory(parentBuild.getDirectory());
}
- if ( childBuild.getDefaultGoal() == null )
- {
- childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
+ if (childBuild.getDefaultGoal() == null) {
+ childBuild.setDefaultGoal(parentBuild.getDefaultGoal());
}
- if ( childBuild.getFinalName() == null )
- {
- childBuild.setFinalName( parentBuild.getFinalName() );
+ if (childBuild.getFinalName() == null) {
+ childBuild.setFinalName(parentBuild.getFinalName());
}
- ModelUtils.mergeFilterLists( childBuild.getFilters(), parentBuild.getFilters() );
+ ModelUtils.mergeFilterLists(childBuild.getFilters(), parentBuild.getFilters());
List<Resource> resources = childBuild.getResources();
- if ( ( resources == null ) || resources.isEmpty() )
- {
- childBuild.setResources( parentBuild.getResources() );
+ if ((resources == null) || resources.isEmpty()) {
+ childBuild.setResources(parentBuild.getResources());
}
resources = childBuild.getTestResources();
- if ( ( resources == null ) || resources.isEmpty() )
- {
- childBuild.setTestResources( parentBuild.getTestResources() );
+ if ((resources == null) || resources.isEmpty()) {
+ childBuild.setTestResources(parentBuild.getTestResources());
}
// Plugins are aggregated if Plugin.inherit != false
- ModelUtils.mergePluginLists( childBuild, parentBuild, handleAsInheritance );
+ ModelUtils.mergePluginLists(childBuild, parentBuild, handleAsInheritance);
// Plugin management :: aggregate
PluginManagement dominantPM = childBuild.getPluginManagement();
PluginManagement recessivePM = parentBuild.getPluginManagement();
- if ( ( dominantPM == null ) && ( recessivePM != null ) )
- {
+ if ((dominantPM == null) && (recessivePM != null)) {
// FIXME: Filter out the inherited == false stuff!
- childBuild.setPluginManagement( recessivePM );
- }
- else
- {
- ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(), false );
+ childBuild.setPluginManagement(recessivePM);
+ } else {
+ ModelUtils.mergePluginLists(childBuild.getPluginManagement(), parentBuild.getPluginManagement(), false);
}
}
- private void assembleScmInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths )
- {
- if ( parent.getScm() != null )
- {
+ private void assembleScmInheritance(Model child, Model parent, String childPathAdjustment, boolean appendPaths) {
+ if (parent.getScm() != null) {
Scm parentScm = parent.getScm();
Scm childScm = child.getScm();
- if ( childScm == null )
- {
+ if (childScm == null) {
childScm = new Scm();
- child.setScm( childScm );
+ child.setScm(childScm);
}
- if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) )
- {
+ if (StringUtils.isEmpty(childScm.getConnection()) && !StringUtils.isEmpty(parentScm.getConnection())) {
childScm.setConnection(
- appendPath( parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
+ appendPath(parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths));
}
- if ( StringUtils.isEmpty( childScm.getDeveloperConnection() )
- && !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) )
- {
- childScm
- .setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(),
- childPathAdjustment, appendPaths ) );
+ if (StringUtils.isEmpty(childScm.getDeveloperConnection())
+ && !StringUtils.isEmpty(parentScm.getDeveloperConnection())) {
+ childScm.setDeveloperConnection(appendPath(
+ parentScm.getDeveloperConnection(), child.getArtifactId(), childPathAdjustment, appendPaths));
}
- if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) )
- {
+ if (StringUtils.isEmpty(childScm.getUrl()) && !StringUtils.isEmpty(parentScm.getUrl())) {
childScm.setUrl(
- appendPath( parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
+ appendPath(parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths));
}
}
}
- public void copyModel( Model dest, Model source )
- {
- assembleModelInheritance( dest, source, null, false );
+ public void copyModel(Model dest, Model source) {
+ assembleModelInheritance(dest, source, null, false);
}
- public void assembleModelInheritance( Model child, Model parent, String childPathAdjustment )
- {
- assembleModelInheritance( child, parent, childPathAdjustment, true );
+ public void assembleModelInheritance(Model child, Model parent, String childPathAdjustment) {
+ assembleModelInheritance(child, parent, childPathAdjustment, true);
}
- public void assembleModelInheritance( Model child, Model parent )
- {
- assembleModelInheritance( child, parent, null, true );
+ public void assembleModelInheritance(Model child, Model parent) {
+ assembleModelInheritance(child, parent, null, true);
}
- private void assembleModelInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths )
- {
+ private void assembleModelInheritance(Model child, Model parent, String childPathAdjustment, boolean appendPaths) {
// cannot inherit from null parent.
- if ( parent == null )
- {
+ if (parent == null) {
return;
}
// Group id
- if ( child.getGroupId() == null )
- {
- child.setGroupId( parent.getGroupId() );
+ if (child.getGroupId() == null) {
+ child.setGroupId(parent.getGroupId());
}
// version
- if ( child.getVersion() == null )
- {
+ if (child.getVersion() == null) {
// The parent version may have resolved to something different, so we take what we asked for...
// instead of - child.setVersion( parent.getVersion() );
- if ( child.getParent() != null )
- {
- child.setVersion( child.getParent().getVersion() );
+ if (child.getParent() != null) {
+ child.setVersion(child.getParent().getVersion());
}
}
// inceptionYear
- if ( child.getInceptionYear() == null )
- {
- child.setInceptionYear( parent.getInceptionYear() );
+ if (child.getInceptionYear() == null) {
+ child.setInceptionYear(parent.getInceptionYear());
}
// url
- if ( child.getUrl() == null )
- {
- if ( parent.getUrl() != null )
- {
- child.setUrl( appendPath( parent.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
- }
- else
- {
- child.setUrl( parent.getUrl() );
+ if (child.getUrl() == null) {
+ if (parent.getUrl() != null) {
+ child.setUrl(appendPath(parent.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths));
+ } else {
+ child.setUrl(parent.getUrl());
}
}
- assembleDistributionInheritance( child, parent, childPathAdjustment, appendPaths );
+ assembleDistributionInheritance(child, parent, childPathAdjustment, appendPaths);
// issueManagement
- if ( child.getIssueManagement() == null )
- {
- child.setIssueManagement( parent.getIssueManagement() );
+ if (child.getIssueManagement() == null) {
+ child.setIssueManagement(parent.getIssueManagement());
}
// description
- if ( child.getDescription() == null )
- {
- child.setDescription( parent.getDescription() );
+ if (child.getDescription() == null) {
+ child.setDescription(parent.getDescription());
}
// Organization
- if ( child.getOrganization() == null )
- {
- child.setOrganization( parent.getOrganization() );
+ if (child.getOrganization() == null) {
+ child.setOrganization(parent.getOrganization());
}
// Scm
- assembleScmInheritance( child, parent, childPathAdjustment, appendPaths );
+ assembleScmInheritance(child, parent, childPathAdjustment, appendPaths);
// ciManagement
- if ( child.getCiManagement() == null )
- {
- child.setCiManagement( parent.getCiManagement() );
+ if (child.getCiManagement() == null) {
+ child.setCiManagement(parent.getCiManagement());
}
// developers
- if ( child.getDevelopers().size() == 0 )
- {
- child.setDevelopers( parent.getDevelopers() );
+ if (child.getDevelopers().size() == 0) {
+ child.setDevelopers(parent.getDevelopers());
}
// licenses
- if ( child.getLicenses().size() == 0 )
- {
- child.setLicenses( parent.getLicenses() );
+ if (child.getLicenses().size() == 0) {
+ child.setLicenses(parent.getLicenses());
}
// developers
- if ( child.getContributors().size() == 0 )
- {
- child.setContributors( parent.getContributors() );
+ if (child.getContributors().size() == 0) {
+ child.setContributors(parent.getContributors());
}
// mailingLists
- if ( child.getMailingLists().size() == 0 )
- {
- child.setMailingLists( parent.getMailingLists() );
+ if (child.getMailingLists().size() == 0) {
+ child.setMailingLists(parent.getMailingLists());
}
// Build
- assembleBuildInheritance( child, parent );
+ assembleBuildInheritance(child, parent);
- assembleDependencyInheritance( child, parent );
+ assembleDependencyInheritance(child, parent);
- child.setRepositories( ModelUtils.mergeRepositoryLists( child.getRepositories(), parent.getRepositories() ) );
-// child.setPluginRepositories(
-// ModelUtils.mergeRepositoryLists( child.getPluginRepositories(), parent.getPluginRepositories() ) );
+ child.setRepositories(ModelUtils.mergeRepositoryLists(child.getRepositories(), parent.getRepositories()));
+ // child.setPluginRepositories(
+ // ModelUtils.mergeRepositoryLists( child.getPluginRepositories(), parent.getPluginRepositories() )
+ // );
- assembleReportingInheritance( child, parent );
+ assembleReportingInheritance(child, parent);
- assembleDependencyManagementInheritance( child, parent );
+ assembleDependencyManagementInheritance(child, parent);
Properties props = new Properties();
- props.putAll( parent.getProperties() );
- props.putAll( child.getProperties() );
+ props.putAll(parent.getProperties());
+ props.putAll(child.getProperties());
- child.setProperties( props );
+ child.setProperties(props);
}
// TODO Remove this!
- private void assembleDependencyManagementInheritance( Model child, Model parent )
- {
+ private void assembleDependencyManagementInheritance(Model child, Model parent) {
DependencyManagement parentDepMgmt = parent.getDependencyManagement();
DependencyManagement childDepMgmt = child.getDependencyManagement();
- if ( parentDepMgmt != null )
- {
- if ( childDepMgmt == null )
- {
- child.setDependencyManagement( parentDepMgmt );
- }
- else
- {
+ if (parentDepMgmt != null) {
+ if (childDepMgmt == null) {
+ child.setDependencyManagement(parentDepMgmt);
+ } else {
List<Dependency> childDeps = childDepMgmt.getDependencies();
Map<String, Dependency> mappedChildDeps = new TreeMap<>();
- for ( Dependency dep : childDeps )
- {
- mappedChildDeps.put( dep.getManagementKey(), dep );
+ for (Dependency dep : childDeps) {
+ mappedChildDeps.put(dep.getManagementKey(), dep);
}
- for ( Dependency dep : parentDepMgmt.getDependencies() )
- {
- if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) )
- {
- childDepMgmt.addDependency( dep );
+ for (Dependency dep : parentDepMgmt.getDependencies()) {
+ if (!mappedChildDeps.containsKey(dep.getManagementKey())) {
+ childDepMgmt.addDependency(dep);
}
}
}
}
}
- private void assembleReportingInheritance( Model child, Model parent )
- {
+ private void assembleReportingInheritance(Model child, Model parent) {
// Reports :: aggregate
Reporting childReporting = child.getReporting();
Reporting parentReporting = parent.getReporting();
- if ( parentReporting != null )
- {
- if ( childReporting == null )
- {
+ if (parentReporting != null) {
+ if (childReporting == null) {
childReporting = new Reporting();
- child.setReporting( childReporting );
+ child.setReporting(childReporting);
}
- childReporting.setExcludeDefaults( parentReporting.isExcludeDefaults() );
+ childReporting.setExcludeDefaults(parentReporting.isExcludeDefaults());
- if ( StringUtils.isEmpty( childReporting.getOutputDirectory() ) )
- {
- childReporting.setOutputDirectory( parentReporting.getOutputDirectory() );
+ if (StringUtils.isEmpty(childReporting.getOutputDirectory())) {
+ childReporting.setOutputDirectory(parentReporting.getOutputDirectory());
}
- mergeReportPluginLists( childReporting, parentReporting, true );
+ mergeReportPluginLists(childReporting, parentReporting, true);
}
}
- private static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance )
- {
- if ( ( child == null ) || ( parent == null ) )
- {
+ private static void mergeReportPluginLists(Reporting child, Reporting parent, boolean handleAsInheritance) {
+ if ((child == null) || (parent == null)) {
// nothing to do.
return;
}
List<ReportPlugin> parentPlugins = parent.getPlugins();
- if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
- {
+ if ((parentPlugins != null) && !parentPlugins.isEmpty()) {
Map<String, ReportPlugin> assembledPlugins = new TreeMap<>();
Map<String, ReportPlugin> childPlugins = child.getReportPluginsAsMap();
- for ( ReportPlugin parentPlugin : parentPlugins )
- {
+ for (ReportPlugin parentPlugin : parentPlugins) {
String parentInherited = parentPlugin.getInherited();
- if ( !handleAsInheritance || ( parentInherited == null ) || Boolean.parseBoolean( parentInherited ) )
- {
+ if (!handleAsInheritance || (parentInherited == null) || Boolean.parseBoolean(parentInherited)) {
ReportPlugin assembledPlugin = parentPlugin;
- ReportPlugin childPlugin = childPlugins.get( parentPlugin.getKey() );
+ ReportPlugin childPlugin = childPlugins.get(parentPlugin.getKey());
- if ( childPlugin != null )
- {
+ if (childPlugin != null) {
assembledPlugin = childPlugin;
- mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance );
+ mergeReportPluginDefinitions(childPlugin, parentPlugin, handleAsInheritance);
}
- if ( handleAsInheritance && ( parentInherited == null ) )
- {
+ if (handleAsInheritance && (parentInherited == null)) {
assembledPlugin.unsetInheritanceApplied();
}
- assembledPlugins.put( assembledPlugin.getKey(), assembledPlugin );
+ assembledPlugins.put(assembledPlugin.getKey(), assembledPlugin);
}
}
- for ( ReportPlugin childPlugin : childPlugins.values() )
- {
- if ( !assembledPlugins.containsKey( childPlugin.getKey() ) )
- {
- assembledPlugins.put( childPlugin.getKey(), childPlugin );
+ for (ReportPlugin childPlugin : childPlugins.values()) {
+ if (!assembledPlugins.containsKey(childPlugin.getKey())) {
+ assembledPlugins.put(childPlugin.getKey(), childPlugin);
}
}
- child.setPlugins( new ArrayList<>( assembledPlugins.values() ) );
+ child.setPlugins(new ArrayList<>(assembledPlugins.values()));
child.flushReportPluginMap();
}
}
- private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent )
- {
+ private static void mergeReportSetDefinitions(ReportSet child, ReportSet parent) {
List<String> parentReports = parent.getReports();
List<String> childReports = child.getReports();
List<String> reports = new ArrayList<>();
- if ( ( childReports != null ) && !childReports.isEmpty() )
- {
- reports.addAll( childReports );
+ if ((childReports != null) && !childReports.isEmpty()) {
+ reports.addAll(childReports);
}
- if ( parentReports != null )
- {
- for ( String report : parentReports )
- {
- if ( !reports.contains( report ) )
- {
- reports.add( report );
+ if (parentReports != null) {
+ for (String report : parentReports) {
+ if (!reports.contains(report)) {
+ reports.add(report);
}
}
}
- child.setReports( reports );
+ child.setReports(reports);
Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
- childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
+ childConfiguration = Xpp3Dom.mergeXpp3Dom(childConfiguration, parentConfiguration);
- child.setConfiguration( childConfiguration );
+ child.setConfiguration(childConfiguration);
}
-
- public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent,
- boolean handleAsInheritance )
- {
- if ( ( child == null ) || ( parent == null ) )
- {
+ public static void mergeReportPluginDefinitions(
+ ReportPlugin child, ReportPlugin parent, boolean handleAsInheritance) {
+ if ((child == null) || (parent == null)) {
// nothing to do.
return;
}
- if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) )
- {
- child.setVersion( parent.getVersion() );
+ if ((child.getVersion() == null) && (parent.getVersion() != null)) {
+ child.setVersion(parent.getVersion());
}
// from here to the end of the method is dealing with merging of the <executions/> section.
String parentInherited = parent.getInherited();
- boolean parentIsInherited = ( parentInherited == null ) || Boolean.parseBoolean( parentInherited );
+ boolean parentIsInherited = (parentInherited == null) || Boolean.parseBoolean(parentInherited);
List<ReportSet> parentReportSets = parent.getReportSets();
- if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() )
- {
+ if ((parentReportSets != null) && !parentReportSets.isEmpty()) {
Map<String, ReportSet> assembledReportSets = new TreeMap<>();
Map<String, ReportSet> childReportSets = child.getReportSetsAsMap();
- for ( ReportSet parentReportSet : parentReportSets )
- {
+ for (ReportSet parentReportSet : parentReportSets) {
- if ( !handleAsInheritance || parentIsInherited )
- {
+ if (!handleAsInheritance || parentIsInherited) {
ReportSet assembledReportSet = parentReportSet;
- ReportSet childReportSet = childReportSets.get( parentReportSet.getId() );
+ ReportSet childReportSet = childReportSets.get(parentReportSet.getId());
- if ( childReportSet != null )
- {
- mergeReportSetDefinitions( childReportSet, parentReportSet );
+ if (childReportSet != null) {
+ mergeReportSetDefinitions(childReportSet, parentReportSet);
assembledReportSet = childReportSet;
- }
- else if ( handleAsInheritance && ( parentInherited == null ) )
- {
+ } else if (handleAsInheritance && (parentInherited == null)) {
parentReportSet.unsetInheritanceApplied();
}
- assembledReportSets.put( assembledReportSet.getId(), assembledReportSet );
+ assembledReportSets.put(assembledReportSet.getId(), assembledReportSet);
}
}
- for ( Map.Entry<String, ReportSet> entry : childReportSets.entrySet() )
- {
+ for (Map.Entry<String, ReportSet> entry : childReportSets.entrySet()) {
String id = entry.getKey();
- if ( !assembledReportSets.containsKey( id ) )
- {
- assembledReportSets.put( id, entry.getValue() );
+ if (!assembledReportSets.containsKey(id)) {
+ assembledReportSets.put(id, entry.getValue());
}
}
- child.setReportSets( new ArrayList<>( assembledReportSets.values() ) );
+ child.setReportSets(new ArrayList<>(assembledReportSets.values()));
child.flushReportSetMap();
}
-
}
// TODO Remove this!
- private void assembleDependencyInheritance( Model child, Model parent )
- {
+ private void assembleDependencyInheritance(Model child, Model parent) {
Map<String, Dependency> depsMap = new LinkedHashMap<>();
List<Dependency> deps = parent.getDependencies();
- if ( deps != null )
- {
- for ( Dependency dependency : deps )
- {
- depsMap.put( dependency.getManagementKey(), dependency );
+ if (deps != null) {
+ for (Dependency dependency : deps) {
+ depsMap.put(dependency.getManagementKey(), dependency);
}
}
deps = child.getDependencies();
- if ( deps != null )
- {
- for ( Dependency dependency : deps )
- {
- depsMap.put( dependency.getManagementKey(), dependency );
+ if (deps != null) {
+ for (Dependency dependency : deps) {
+ depsMap.put(dependency.getManagementKey(), dependency);
}
}
- child.setDependencies( new ArrayList<>( depsMap.values() ) );
+ child.setDependencies(new ArrayList<>(depsMap.values()));
}
- private void assembleBuildInheritance( Model child, Model parent )
- {
+ private void assembleBuildInheritance(Model child, Model parent) {
Build childBuild = child.getBuild();
Build parentBuild = parent.getBuild();
- if ( parentBuild != null )
- {
- if ( childBuild == null )
- {
+ if (parentBuild != null) {
+ if (childBuild == null) {
childBuild = new Build();
- child.setBuild( childBuild );
+ child.setBuild(childBuild);
}
- assembleBuildInheritance( childBuild, parentBuild, true );
+ assembleBuildInheritance(childBuild, parentBuild, true);
}
}
- private void assembleDistributionInheritance( Model child, Model parent, String childPathAdjustment,
- boolean appendPaths )
- {
- if ( parent.getDistributionManagement() != null )
- {
+ private void assembleDistributionInheritance(
+ Model child, Model parent, String childPathAdjustment, boolean appendPaths) {
+ if (parent.getDistributionManagement() != null) {
DistributionManagement parentDistMgmt = parent.getDistributionManagement();
DistributionManagement childDistMgmt = child.getDistributionManagement();
- if ( childDistMgmt == null )
- {
+ if (childDistMgmt == null) {
childDistMgmt = new DistributionManagement();
- child.setDistributionManagement( childDistMgmt );
+ child.setDistributionManagement(childDistMgmt);
}
- if ( childDistMgmt.getSite() == null )
- {
- if ( parentDistMgmt.getSite() != null )
- {
+ if (childDistMgmt.getSite() == null) {
+ if (parentDistMgmt.getSite() != null) {
Site site = new Site();
- childDistMgmt.setSite( site );
+ childDistMgmt.setSite(site);
- site.setId( parentDistMgmt.getSite().getId() );
+ site.setId(parentDistMgmt.getSite().getId());
- site.setName( parentDistMgmt.getSite().getName() );
+ site.setName(parentDistMgmt.getSite().getName());
- site.setUrl( parentDistMgmt.getSite().getUrl() );
+ site.setUrl(parentDistMgmt.getSite().getUrl());
- if ( site.getUrl() != null )
- {
- site.setUrl(
- appendPath( site.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
+ if (site.getUrl() != null) {
+ site.setUrl(appendPath(site.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths));
}
}
}
- if ( childDistMgmt.getRepository() == null )
- {
- if ( parentDistMgmt.getRepository() != null )
- {
- DeploymentRepository repository = copyDistributionRepository( parentDistMgmt.getRepository() );
- childDistMgmt.setRepository( repository );
+ if (childDistMgmt.getRepository() == null) {
+ if (parentDistMgmt.getRepository() != null) {
+ DeploymentRepository repository = copyDistributionRepository(parentDistMgmt.getRepository());
+ childDistMgmt.setRepository(repository);
}
}
- if ( childDistMgmt.getSnapshotRepository() == null )
- {
- if ( parentDistMgmt.getSnapshotRepository() != null )
- {
+ if (childDistMgmt.getSnapshotRepository() == null) {
+ if (parentDistMgmt.getSnapshotRepository() != null) {
DeploymentRepository repository =
- copyDistributionRepository( parentDistMgmt.getSnapshotRepository() );
- childDistMgmt.setSnapshotRepository( repository );
+ copyDistributionRepository(parentDistMgmt.getSnapshotRepository());
+ childDistMgmt.setSnapshotRepository(repository);
}
}
- if ( StringUtils.isEmpty( childDistMgmt.getDownloadUrl() ) )
- {
- childDistMgmt.setDownloadUrl( parentDistMgmt.getDownloadUrl() );
+ if (StringUtils.isEmpty(childDistMgmt.getDownloadUrl())) {
+ childDistMgmt.setDownloadUrl(parentDistMgmt.getDownloadUrl());
}
// NOTE: We SHOULD NOT be inheriting status, since this is an assessment of the POM quality.
@@ -631,114 +529,96 @@ public class ModelInheritanceAssembler
}
}
- private static DeploymentRepository copyDistributionRepository( DeploymentRepository parentRepository )
- {
+ private static DeploymentRepository copyDistributionRepository(DeploymentRepository parentRepository) {
DeploymentRepository repository = new DeploymentRepository();
- repository.setId( parentRepository.getId() );
+ repository.setId(parentRepository.getId());
- repository.setName( parentRepository.getName() );
+ repository.setName(parentRepository.getName());
- repository.setUrl( parentRepository.getUrl() );
+ repository.setUrl(parentRepository.getUrl());
- repository.setLayout( parentRepository.getLayout() );
+ repository.setLayout(parentRepository.getLayout());
- repository.setUniqueVersion( parentRepository.isUniqueVersion() );
+ repository.setUniqueVersion(parentRepository.isUniqueVersion());
return repository;
}
// TODO This should eventually be migrated to DefaultPathTranslator.
- protected String appendPath( String parentPath, String childPath, String pathAdjustment, boolean appendPaths )
- {
+ protected String appendPath(String parentPath, String childPath, String pathAdjustment, boolean appendPaths) {
String uncleanPath = parentPath;
- if ( appendPaths )
- {
- if ( pathAdjustment != null )
- {
+ if (appendPaths) {
+ if (pathAdjustment != null) {
uncleanPath += "/" + pathAdjustment;
}
- if ( childPath != null )
- {
+ if (childPath != null) {
uncleanPath += "/" + childPath;
}
}
String cleanedPath = "";
- int protocolIdx = uncleanPath.indexOf( "://" );
+ int protocolIdx = uncleanPath.indexOf("://");
- if ( protocolIdx > -1 )
- {
- cleanedPath = uncleanPath.substring( 0, protocolIdx + 3 );
- uncleanPath = uncleanPath.substring( protocolIdx + 3 );
+ if (protocolIdx > -1) {
+ cleanedPath = uncleanPath.substring(0, protocolIdx + 3);
+ uncleanPath = uncleanPath.substring(protocolIdx + 3);
}
- if ( uncleanPath.startsWith( "/" ) )
- {
+ if (uncleanPath.startsWith("/")) {
cleanedPath += "/";
}
- return cleanedPath + resolvePath( uncleanPath );
+ return cleanedPath + resolvePath(uncleanPath);
}
// TODO Move this to plexus-utils' PathTool.
- private static String resolvePath( String uncleanPath )
- {
+ private static String resolvePath(String uncleanPath) {
LinkedList<String> pathElements = new LinkedList<>();
- StringTokenizer tokenizer = new StringTokenizer( uncleanPath, "/" );
+ StringTokenizer tokenizer = new StringTokenizer(uncleanPath, "/");
- while ( tokenizer.hasMoreTokens() )
- {
+ while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
- switch ( token )
- {
+ switch (token) {
case "":
// Empty path entry ("...//.."), remove.
break;
case "..":
- if ( pathElements.isEmpty() )
- {
+ if (pathElements.isEmpty()) {
// FIXME: somehow report to the user
// that there are too many '..' elements.
// For now, ignore the extra '..'.
- }
- else
- {
+ } else {
pathElements.removeLast();
}
break;
default:
- pathElements.addLast( token );
+ pathElements.addLast(token);
break;
}
}
StringBuilder cleanedPath = new StringBuilder();
- while ( !pathElements.isEmpty() )
- {
- cleanedPath.append( pathElements.removeFirst() );
- if ( !pathElements.isEmpty() )
- {
- cleanedPath.append( '/' );
+ while (!pathElements.isEmpty()) {
+ cleanedPath.append(pathElements.removeFirst());
+ if (!pathElements.isEmpty()) {
+ cleanedPath.append('/');
}
}
return cleanedPath.toString();
}
- private static void mergeExtensionLists( Build childBuild, Build parentBuild )
- {
- for ( Extension e : parentBuild.getExtensions() )
- {
- if ( !childBuild.getExtensions().contains( e ) )
- {
- childBuild.addExtension( e );
+ private static void mergeExtensionLists(Build childBuild, Build parentBuild) {
+ for (Extension e : parentBuild.getExtensions()) {
+ if (!childBuild.getExtensions().contains(e)) {
+ childBuild.addExtension(e);
}
}
}
diff --git a/src/main/java/org/apache/maven/plugin/resources/remote/ModelUtils.java b/src/main/java/org/apache/maven/plugin/resources/remote/ModelUtils.java
index cc0570a..bc94f83 100644
--- a/src/main/java/org/apache/maven/plugin/resources/remote/ModelUtils.java
+++ b/src/main/java/org/apache/maven/plugin/resources/remote/ModelUtils.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.plugin.resources.remote;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.plugin.resources.remote;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote;
import java.util.ArrayList;
import java.util.Iterator;
@@ -34,8 +33,7 @@ import org.apache.maven.model.Repository;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/** HELPER CLASS */
-public final class ModelUtils
-{
+public final class ModelUtils {
/**
* This should be the resulting ordering of plugins after merging:
@@ -50,33 +48,27 @@ public final class ModelUtils
* X -> Y -> A -> B -> C -> D -> E -> F
* </pre>
*/
- public static void mergePluginLists( PluginContainer childContainer, PluginContainer parentContainer,
- boolean handleAsInheritance )
- {
- if ( ( childContainer == null ) || ( parentContainer == null ) )
- {
+ public static void mergePluginLists(
+ PluginContainer childContainer, PluginContainer parentContainer, boolean handleAsInheritance) {
+ if ((childContainer == null) || (parentContainer == null)) {
// nothing to do.
return;
}
List<Plugin> parentPlugins = parentContainer.getPlugins();
- if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
- {
- parentPlugins = new ArrayList<>( parentPlugins );
+ if ((parentPlugins != null) && !parentPlugins.isEmpty()) {
+ parentPlugins = new ArrayList<>(parentPlugins);
// If we're processing this merge as an inheritance, we have to build up a list of
// plugins that were considered for inheritance.
- if ( handleAsInheritance )
- {
- for ( Iterator<Plugin> it = parentPlugins.iterator(); it.hasNext(); )
- {
+ if (handleAsInheritance) {
+ for (Iterator<Plugin> it = parentPlugins.iterator(); it.hasNext(); ) {
Plugin plugin = it.next();
String inherited = plugin.getInherited();
- if ( ( inherited != null ) && !Boolean.parseBoolean( inherited ) )
- {
+ if ((inherited != null) && !Boolean.parseBoolean(inherited)) {
it.remove();
}
}
@@ -86,8 +78,7 @@ public final class ModelUtils
Map<String, Plugin> childPlugins = childContainer.getPluginsAsMap();
- for ( Plugin parentPlugin : parentPlugins )
- {
+ for (Plugin parentPlugin : parentPlugins) {
String parentInherited = parentPlugin.getInherited();
// only merge plugin definition from the parent if at least one
@@ -95,26 +86,22 @@ public final class ModelUtils
// 1. we're not processing the plugins in an inheritance-based merge
// 2. the parent's <inherited/> flag is not set
// 3. the parent's <inherited/> flag is set to true
- if ( !handleAsInheritance || ( parentInherited == null )
- || Boolean.parseBoolean( parentInherited ) )
- {
- Plugin childPlugin = childPlugins.get( parentPlugin.getKey() );
+ if (!handleAsInheritance || (parentInherited == null) || Boolean.parseBoolean(parentInherited)) {
+ Plugin childPlugin = childPlugins.get(parentPlugin.getKey());
- if ( ( childPlugin != null ) && !assembledPlugins.contains( childPlugin ) )
- {
+ if ((childPlugin != null) && !assembledPlugins.contains(childPlugin)) {
Plugin assembledPlugin = childPlugin;
- mergePluginDefinitions( childPlugin, parentPlugin, handleAsInheritance );
+ mergePluginDefinitions(childPlugin, parentPlugin, handleAsInheritance);
// fix for MNG-2221 (assembly cache was not being populated for later reference):
- assembledPlugins.add( assembledPlugin );
+ assembledPlugins.add(assembledPlugin);
}
// if we're processing this as an inheritance-based merge, and
// the parent's <inherited/> flag is not set, then we need to
// clear the inherited flag in the merge result.
- if ( handleAsInheritance && ( parentInherited == null ) )
- {
+ if (handleAsInheritance && (parentInherited == null)) {
parentPlugin.unsetInheritanceApplied();
}
}
@@ -122,61 +109,51 @@ public final class ModelUtils
// very important to use the parentPlugins List, rather than parentContainer.getPlugins()
// since this list is a local one, and may have been modified during processing.
List<Plugin> results =
- ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins, childContainer.getPlugins() );
+ ModelUtils.orderAfterMerge(assembledPlugins, parentPlugins, childContainer.getPlugins());
- childContainer.setPlugins( results );
+ childContainer.setPlugins(results);
childContainer.flushPluginMap();
}
}
}
- public static List<Plugin> orderAfterMerge( List<Plugin> merged, List<Plugin> highPrioritySource,
- List<Plugin> lowPrioritySource )
- {
+ public static List<Plugin> orderAfterMerge(
+ List<Plugin> merged, List<Plugin> highPrioritySource, List<Plugin> lowPrioritySource) {
List<Plugin> results = new ArrayList<>();
- if ( !merged.isEmpty() )
- {
- results.addAll( merged );
+ if (!merged.isEmpty()) {
+ results.addAll(merged);
}
List<Plugin> missingFromResults = new ArrayList<>();
List<List<Plugin>> sources = new ArrayList<>();
- sources.add( highPrioritySource );
- sources.add( lowPrioritySource );
-
- for ( List<Plugin> source : sources )
- {
- for ( Plugin item : source )
- {
- if ( results.contains( item ) )
- {
- if ( !missingFromResults.isEmpty() )
- {
- int idx = results.indexOf( item );
-
- if ( idx < 0 )
- {
+ sources.add(highPrioritySource);
+ sources.add(lowPrioritySource);
+
+ for (List<Plugin> source : sources) {
+ for (Plugin item : source) {
+ if (results.contains(item)) {
+ if (!missingFromResults.isEmpty()) {
+ int idx = results.indexOf(item);
+
+ if (idx < 0) {
idx = 0;
}
- results.addAll( idx, missingFromResults );
+ results.addAll(idx, missingFromResults);
missingFromResults.clear();
}
- }
- else
- {
- missingFromResults.add( item );
+ } else {
+ missingFromResults.add(item);
}
}
- if ( !missingFromResults.isEmpty() )
- {
- results.addAll( missingFromResults );
+ if (!missingFromResults.isEmpty()) {
+ results.addAll(missingFromResults);
missingFromResults.clear();
}
@@ -185,98 +162,82 @@ public final class ModelUtils
return results;
}
-
- public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance )
- {
- if ( ( child == null ) || ( parent == null ) )
- {
+ public static void mergePluginDefinitions(Plugin child, Plugin parent, boolean handleAsInheritance) {
+ if ((child == null) || (parent == null)) {
// nothing to do.
return;
}
- if ( parent.isExtensions() )
- {
- child.setExtensions( true );
+ if (parent.isExtensions()) {
+ child.setExtensions(true);
}
- if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) )
- {
- child.setVersion( parent.getVersion() );
+ if ((child.getVersion() == null) && (parent.getVersion() != null)) {
+ child.setVersion(parent.getVersion());
}
Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
- childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
+ childConfiguration = Xpp3Dom.mergeXpp3Dom(childConfiguration, parentConfiguration);
- child.setConfiguration( childConfiguration );
+ child.setConfiguration(childConfiguration);
- child.setDependencies( mergeDependencyList( child.getDependencies(), parent.getDependencies() ) );
+ child.setDependencies(mergeDependencyList(child.getDependencies(), parent.getDependencies()));
// from here to the end of the method is dealing with merging of the <executions/> section.
String parentInherited = parent.getInherited();
- boolean parentIsInherited = ( parentInherited == null ) || Boolean.parseBoolean( parentInherited );
+ boolean parentIsInherited = (parentInherited == null) || Boolean.parseBoolean(parentInherited);
List<PluginExecution> parentExecutions = parent.getExecutions();
- if ( ( parentExecutions != null ) && !parentExecutions.isEmpty() )
- {
+ if ((parentExecutions != null) && !parentExecutions.isEmpty()) {
List<PluginExecution> mergedExecutions = new ArrayList<>();
Map<String, PluginExecution> assembledExecutions = new TreeMap<>();
Map<String, PluginExecution> childExecutions = child.getExecutionsAsMap();
- for ( PluginExecution parentExecution : parentExecutions )
- {
+ for (PluginExecution parentExecution : parentExecutions) {
String inherited = parentExecution.getInherited();
boolean parentExecInherited =
- parentIsInherited && ( ( inherited == null ) || Boolean.parseBoolean( inherited ) );
+ parentIsInherited && ((inherited == null) || Boolean.parseBoolean(inherited));
- if ( !handleAsInheritance || parentExecInherited )
- {
+ if (!handleAsInheritance || parentExecInherited) {
PluginExecution assembled = parentExecution;
- PluginExecution childExecution = childExecutions.get( parentExecution.getId() );
+ PluginExecution childExecution = childExecutions.get(parentExecution.getId());
- if ( childExecution != null )
- {
- mergePluginExecutionDefinitions( childExecution, parentExecution );
+ if (childExecution != null) {
+ mergePluginExecutionDefinitions(childExecution, parentExecution);
assembled = childExecution;
- }
- else if ( handleAsInheritance && ( parentInherited == null ) )
- {
+ } else if (handleAsInheritance && (parentInherited == null)) {
parentExecution.unsetInheritanceApplied();
}
- assembledExecutions.put( assembled.getId(), assembled );
- mergedExecutions.add( assembled );
+ assembledExecutions.put(assembled.getId(), assembled);
+ mergedExecutions.add(assembled);
}
}
- for ( PluginExecution childExecution : child.getExecutions() )
- {
- if ( !assembledExecutions.containsKey( childExecution.getId() ) )
- {
- mergedExecutions.add( childExecution );
+ for (PluginExecution childExecution : child.getExecutions()) {
+ if (!assembledExecutions.containsKey(childExecution.getId())) {
+ mergedExecutions.add(childExecution);
}
}
- child.setExecutions( mergedExecutions );
+ child.setExecutions(mergedExecutions);
child.flushExecutionMap();
}
-
}
- private static void mergePluginExecutionDefinitions( PluginExecution child, PluginExecution parent )
- {
- if ( child.getPhase() == null )
- {
- child.setPhase( parent.getPhase() );
+ private static void mergePluginExecutionDefinitions(PluginExecution child, PluginExecution parent) {
+ if (child.getPhase() == null) {
+ child.setPhase(parent.getPhase());
}
List<String> parentGoals = parent.getGoals();
@@ -284,80 +245,64 @@ public final class ModelUtils
List<String> goals = new ArrayList<>();
- if ( ( childGoals != null ) && !childGoals.isEmpty() )
- {
- goals.addAll( childGoals );
+ if ((childGoals != null) && !childGoals.isEmpty()) {
+ goals.addAll(childGoals);
}
- if ( parentGoals != null )
- {
- for ( String goal : parentGoals )
- {
- if ( !goals.contains( goal ) )
- {
- goals.add( goal );
+ if (parentGoals != null) {
+ for (String goal : parentGoals) {
+ if (!goals.contains(goal)) {
+ goals.add(goal);
}
}
}
- child.setGoals( goals );
+ child.setGoals(goals);
Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
- childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
+ childConfiguration = Xpp3Dom.mergeXpp3Dom(childConfiguration, parentConfiguration);
- child.setConfiguration( childConfiguration );
+ child.setConfiguration(childConfiguration);
}
- public static List<Repository> mergeRepositoryLists( List<Repository> dominant, List<Repository> recessive )
- {
+ public static List<Repository> mergeRepositoryLists(List<Repository> dominant, List<Repository> recessive) {
- List<Repository> repositories = new ArrayList<>( dominant );
+ List<Repository> repositories = new ArrayList<>(dominant);
- for ( Repository repository : recessive )
- {
- if ( !repositories.contains( repository ) )
- {
- repositories.add( repository );
+ for (Repository repository : recessive) {
+ if (!repositories.contains(repository)) {
+ repositories.add(repository);
}
}
return repositories;
}
- public static void mergeFilterLists( List<String> childFilters, List<String> parentFilters )
- {
- for ( String f : parentFilters )
- {
- if ( !childFilters.contains( f ) )
- {
- childFilters.add( f );
+ public static void mergeFilterLists(List<String> childFilters, List<String> parentFilters) {
+ for (String f : parentFilters) {
+ if (!childFilters.contains(f)) {
+ childFilters.add(f);
}
}
}
- private static List<Dependency> mergeDependencyList( List<Dependency> child, List<Dependency> parent )
- {
+ private static List<Dependency> mergeDependencyList(List<Dependency> child, List<Dependency> parent) {
Map<String, Dependency> depsMap = new LinkedHashMap<>();
- if ( parent != null )
- {
- for ( Dependency dependency : parent )
- {
- depsMap.put( dependency.getManagementKey(), dependency );
+ if (parent != null) {
+ for (Dependency dependency : parent) {
+ depsMap.put(dependency.getManagementKey(), dependency);
}
}
- if ( child != null )
- {
- for ( Dependency dependency : child )
- {
- depsMap.put( dependency.getManagementKey(), dependency );
+ if (child != null) {
+ for (Dependency dependency : child) {
+ depsMap.put(dependency.getManagementKey(), dependency);
}
}
- return new ArrayList<>( depsMap.values() );
+ return new ArrayList<>(depsMap.values());
}
-
}
diff --git a/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java b/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
index 6572260..5c55aa5 100644
--- a/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
+++ b/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugin.resources.remote;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote;
import java.util.Set;
@@ -38,22 +37,19 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
* </p>
* Resources that don't end in ".vm" are copied "as is".
*/
-@Mojo( name = "process",
- defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
- requiresDependencyResolution = ResolutionScope.TEST,
- threadSafe = true )
-public class ProcessRemoteResourcesMojo
- extends AbstractProcessRemoteResourcesMojo
-{
+@Mojo(
+ name = "process",
+ defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
+ requiresDependencyResolution = ResolutionScope.TEST,
+ threadSafe = true)
+public class ProcessRemoteResourcesMojo extends AbstractProcessRemoteResourcesMojo {
@Override
- protected Set<Artifact> getAllDependencies()
- {
+ protected Set<Artifact> getAllDependencies() {
return project.getArtifacts();
}
@Override
- protected Set<Artifact> getDirectDependencies()
- {
+ protected Set<Artifact> getDirectDependencies() {
return project.getDependencyArtifacts();
}
}
diff --git a/src/main/java/org/apache/maven/plugin/resources/remote/RemoteResourcesClassLoader.java b/src/main/java/org/apache/maven/plugin/resources/remote/RemoteResourcesClassLoader.java
index 7166fd1..c83cfe2 100644
--- a/src/main/java/org/apache/maven/plugin/resources/remote/RemoteResourcesClassLoader.java
+++ b/src/main/java/org/apache/maven/plugin/resources/remote/RemoteResourcesClassLoader.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,25 +16,22 @@ package org.apache.maven.plugin.resources.remote;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote;
-import java.net.URLClassLoader;
import java.net.URL;
+import java.net.URLClassLoader;
/**
* @author Jason van Zyl
*/
-public class RemoteResourcesClassLoader
- extends URLClassLoader
-{
- public RemoteResourcesClassLoader( ClassLoader parent )
- {
- super( new URL[]{} , parent );
+public class RemoteResourcesClassLoader extends URLClassLoader {
+ public RemoteResourcesClassLoader(ClassLoader parent) {
+ super(new URL[] {}, parent);
}
@Override
- public void addURL( URL url )
- {
- super.addURL( url );
+ public void addURL(URL url) {
+ super.addURL(url);
}
// don't check the parents for the resources. Just check the jars
@@ -44,14 +39,11 @@ public class RemoteResourcesClassLoader
// system classpath jars and stuff instead of the jars
// we specifically provided
@Override
- public URL getResource( String name )
- {
- URL url = findResource( name );
- if ( url == null )
- {
- url = super.getResource( name );
+ public URL getResource(String name) {
+ URL url = findResource(name);
+ if (url == null) {
+ url = super.getResource(name);
}
return url;
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java b/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java
index 41050c3..7a2ca0f 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugin.resources.remote;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote;
import java.io.File;
import java.io.InputStream;
@@ -52,374 +51,270 @@ import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
-
/**
* RemoteResources plugin Test Case
*/
-public class RemoteResourcesMojoTest
- extends AbstractMojoTestCase
-{
+public class RemoteResourcesMojoTest extends AbstractMojoTestCase {
static final String DEFAULT_BUNDLE_POM_PATH = "target/test-classes/unit/rrmojotest/bundle-plugin-config.xml";
static final String DEFAULT_PROCESS_POM_PATH = "target/test-classes/unit/rrmojotest/process-plugin-config.xml";
private final String LOCAL_REPO = "target/local-repo/";
@Override
- public void setUp()
- throws Exception
- {
+ public void setUp() throws Exception {
super.setUp();
}
@Override
- public void tearDown()
- throws Exception
- {
-
- }
+ public void tearDown() throws Exception {}
/**
* check test environment
*
* @throws Exception if any exception occurs
*/
- public void testTestEnvironment()
- throws Exception
- {
+ public void testTestEnvironment() throws Exception {
// Perform lookup on the Mojo to make sure everything is ok
lookupProcessMojo();
}
+ public void testNoBundles() throws Exception {
+ final MavenProjectResourcesStub project = createTestProject("default-nobundles");
+ final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithDefaultSettings(project);
- public void testNoBundles()
- throws Exception
- {
- final MavenProjectResourcesStub project = createTestProject( "default-nobundles" );
- final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithDefaultSettings( project );
-
- setupDefaultProject( project );
+ setupDefaultProject(project);
mojo.execute();
}
- public void testCreateBundle()
- throws Exception
- {
- buildResourceBundle( "default-createbundle",
- null,
- new String[] {"SIMPLE.txt"},
- null );
+ public void testCreateBundle() throws Exception {
+ buildResourceBundle("default-createbundle", null, new String[] {"SIMPLE.txt"}, null);
}
- public void testSimpleBundles()
- throws Exception
- {
- final MavenProjectResourcesStub project = createTestProject( "default-simplebundles" );
- final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings( project,
- new String[] {
- "test:test:1.0"
- } );
+ public void testSimpleBundles() throws Exception {
+ final MavenProjectResourcesStub project = createTestProject("default-simplebundles");
+ final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] {"test:test:1.0"});
- setupDefaultProject( project );
+ setupDefaultProject(project);
- String path = pathOf( new DefaultArtifact( "test",
- "test",
- VersionRange.createFromVersion( "1.0" ),
- null,
- "jar",
- "",
- new DefaultArtifactHandler() ) );
+ String path = pathOf(new DefaultArtifact(
+ "test", "test", VersionRange.createFromVersion("1.0"), null, "jar", "", new DefaultArtifactHandler()));
- File file = new File( path );
+ File file = new File(path);
file.getParentFile().mkdirs();
- buildResourceBundle( "default-simplebundles-create",
- null,
- new String[] {"SIMPLE.txt"},
- file );
-
+ buildResourceBundle("default-simplebundles-create", null, new String[] {"SIMPLE.txt"}, file);
mojo.execute();
- file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
- file = new File( file, "SIMPLE.txt" );
- assertTrue( file.exists() );
+ file = (File) getVariableValueFromObject(mojo, "outputDirectory");
+ file = new File(file, "SIMPLE.txt");
+ assertTrue(file.exists());
}
- public void testSimpleBundlesWithType()
- throws Exception
- {
- final MavenProjectResourcesStub project = createTestProject( "default-simplebundles" );
- final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings( project,
- new String[] {
- "test:test:1.0:war"
- } );
+ public void testSimpleBundlesWithType() throws Exception {
+ final MavenProjectResourcesStub project = createTestProject("default-simplebundles");
+ final ProcessRemoteResourcesMojo mojo =
+ lookupProcessMojoWithSettings(project, new String[] {"test:test:1.0:war"});
- setupDefaultProject( project );
+ setupDefaultProject(project);
- String path = pathOf( new DefaultArtifact( "test",
- "test",
- VersionRange.createFromVersion( "1.0" ),
- null,
- "war",
- "",
- new DefaultArtifactHandler() ) );
+ String path = pathOf(new DefaultArtifact(
+ "test", "test", VersionRange.createFromVersion("1.0"), null, "war", "", new DefaultArtifactHandler()));
- File file = new File( path );
+ File file = new File(path);
file.getParentFile().mkdirs();
- buildResourceBundle( "default-simplebundles-create",
- null,
- new String[] {"SIMPLE.txt"},
- file );
-
+ buildResourceBundle("default-simplebundles-create", null, new String[] {"SIMPLE.txt"}, file);
mojo.execute();
- file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
- file = new File( file, "SIMPLE.txt" );
- assertTrue( file.exists() );
+ file = (File) getVariableValueFromObject(mojo, "outputDirectory");
+ file = new File(file, "SIMPLE.txt");
+ assertTrue(file.exists());
}
- public void testSimpleBundlesWithClassifier()
- throws Exception
- {
- final MavenProjectResourcesStub project = createTestProject( "default-simplebundles" );
- final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings( project,
- new String[] {
- "test:test:1.0:jar:test"
- } );
+ public void testSimpleBundlesWithClassifier() throws Exception {
+ final MavenProjectResourcesStub project = createTestProject("default-simplebundles");
+ final ProcessRemoteResourcesMojo mojo =
+ lookupProcessMojoWithSettings(project, new String[] {"test:test:1.0:jar:test"});
- setupDefaultProject( project );
+ setupDefaultProject(project);
- String path = pathOf( new DefaultArtifact( "test",
+ String path = pathOf(new DefaultArtifact(
"test",
- VersionRange.createFromVersion( "1.0" ),
+ "test",
+ VersionRange.createFromVersion("1.0"),
null,
"jar",
"test",
- new DefaultArtifactHandler() ) );
+ new DefaultArtifactHandler()));
- File file = new File( path );
+ File file = new File(path);
file.getParentFile().mkdirs();
- buildResourceBundle( "default-simplebundles-create",
- null,
- new String[] {"SIMPLE.txt"},
- file );
-
+ buildResourceBundle("default-simplebundles-create", null, new String[] {"SIMPLE.txt"}, file);
mojo.execute();
- file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
- file = new File( file, "SIMPLE.txt" );
- assertTrue( file.exists() );
+ file = (File) getVariableValueFromObject(mojo, "outputDirectory");
+ file = new File(file, "SIMPLE.txt");
+ assertTrue(file.exists());
}
- public void testVelocityUTF8()
- throws Exception
- {
- final MavenProjectResourcesStub project = createTestProject( "default-utf8" );
- final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings( project,
- new String[] {
- "test:test:1.2"
- } );
+ public void testVelocityUTF8() throws Exception {
+ final MavenProjectResourcesStub project = createTestProject("default-utf8");
+ final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] {"test:test:1.2"});
- setupDefaultProject( project );
+ setupDefaultProject(project);
- String path = pathOf( new DefaultArtifact( "test",
- "test",
- VersionRange.createFromVersion( "1.2" ),
- null,
- "jar",
- "",
- new DefaultArtifactHandler() ) );
+ String path = pathOf(new DefaultArtifact(
+ "test", "test", VersionRange.createFromVersion("1.2"), null, "jar", "", new DefaultArtifactHandler()));
- File file = new File( path );
+ File file = new File(path);
file.getParentFile().mkdirs();
- buildResourceBundle( "default-utf8-create",
- "UTF-8",
- new String[] {"UTF-8.bin.vm"},
- file );
+ buildResourceBundle("default-utf8-create", "UTF-8", new String[] {"UTF-8.bin.vm"}, file);
mojo.execute();
- file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
- file = new File( file, "UTF-8.bin" );
- assertTrue( file.exists() );
+ file = (File) getVariableValueFromObject(mojo, "outputDirectory");
+ file = new File(file, "UTF-8.bin");
+ assertTrue(file.exists());
- try ( InputStream in = Files.newInputStream( file.toPath() ) )
- {
- byte[] data = IOUtil.toByteArray( in );
- byte[] expected = "\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00DF".getBytes( StandardCharsets.UTF_8 );
- assertTrue( Arrays.equals( expected, data ) );
+ try (InputStream in = Files.newInputStream(file.toPath())) {
+ byte[] data = IOUtil.toByteArray(in);
+ byte[] expected = "\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00DF".getBytes(StandardCharsets.UTF_8);
+ assertTrue(Arrays.equals(expected, data));
}
}
- public void testVelocityISO88591()
- throws Exception
- {
- final MavenProjectResourcesStub project = createTestProject( "default-iso88591" );
- final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings( project,
- new String[] {
- "test:test:1.3"
- } );
+ public void testVelocityISO88591() throws Exception {
+ final MavenProjectResourcesStub project = createTestProject("default-iso88591");
+ final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] {"test:test:1.3"});
- setupDefaultProject( project );
+ setupDefaultProject(project);
- String path = pathOf( new DefaultArtifact( "test",
- "test",
- VersionRange.createFromVersion( "1.3" ),
- null,
- "jar",
- "",
- new DefaultArtifactHandler() ) );
+ String path = pathOf(new DefaultArtifact(
+ "test", "test", VersionRange.createFromVersion("1.3"), null, "jar", "", new DefaultArtifactHandler()));
- File file = new File( path );
+ File file = new File(path);
file.getParentFile().mkdirs();
- buildResourceBundle( "default-iso88591-create",
- "ISO-8859-1",
- new String[] {"ISO-8859-1.bin.vm"},
- file );
+ buildResourceBundle("default-iso88591-create", "ISO-8859-1", new String[] {"ISO-8859-1.bin.vm"}, file);
mojo.execute();
- file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
- file = new File( file, "ISO-8859-1.bin" );
- assertTrue( file.exists() );
+ file = (File) getVariableValueFromObject(mojo, "outputDirectory");
+ file = new File(file, "ISO-8859-1.bin");
+ assertTrue(file.exists());
- try ( InputStream in = Files.newInputStream( file.toPath() ) )
- {
- byte[] data = IOUtil.toByteArray( in );
- byte[] expected = "\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00DF".getBytes( StandardCharsets.ISO_8859_1 );
- assertTrue( Arrays.equals( expected, data ) );
+ try (InputStream in = Files.newInputStream(file.toPath())) {
+ byte[] data = IOUtil.toByteArray(in);
+ byte[] expected = "\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00DF".getBytes(StandardCharsets.ISO_8859_1);
+ assertTrue(Arrays.equals(expected, data));
}
-
}
- public void testFilteredBundles()
- throws Exception
- {
- final MavenProjectResourcesStub project = createTestProject( "default-filterbundles" );
- final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings( project,
- new String[] {
- "test:test:1.1"
- } );
+ public void testFilteredBundles() throws Exception {
+ final MavenProjectResourcesStub project = createTestProject("default-filterbundles");
+ final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] {"test:test:1.1"});
- setupDefaultProject( project );
+ setupDefaultProject(project);
- String path = pathOf( new DefaultArtifact( "test",
- "test",
- VersionRange.createFromVersion( "1.1" ),
- null,
- "jar",
- "",
- new DefaultArtifactHandler() ) );
+ String path = pathOf(new DefaultArtifact(
+ "test", "test", VersionRange.createFromVersion("1.1"), null, "jar", "", new DefaultArtifactHandler()));
- File file = new File( path );
+ File file = new File(path);
file.getParentFile().mkdirs();
- buildResourceBundle( "default-filterbundles-create",
- null,
- new String[] {"FILTER.txt.vm"},
- file );
-
+ buildResourceBundle("default-filterbundles-create", null, new String[] {"FILTER.txt.vm"}, file);
mojo.execute();
// executing a second time (example: forked lifecycle) should still work
mojo.execute();
- file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
- file = new File( file, "FILTER.txt" );
- assertTrue( file.exists() );
+ file = (File) getVariableValueFromObject(mojo, "outputDirectory");
+ file = new File(file, "FILTER.txt");
+ assertTrue(file.exists());
- String data = FileUtils.fileRead( file );
- assertTrue( data.contains( "project.name: Test Project default-filterbundles" ) );
- assertTrue( data.contains( "projectTimespan: 2007-2019" ) );
- assertTrue( data.contains( "projects: [" ) );
- assertTrue( data.contains( "projectsSortedByOrganization: {" ) );
+ String data = FileUtils.fileRead(file);
+ assertTrue(data.contains("project.name: Test Project default-filterbundles"));
+ assertTrue(data.contains("projectTimespan: 2007-2019"));
+ assertTrue(data.contains("projects: ["));
+ assertTrue(data.contains("projectsSortedByOrganization: {"));
}
- public void testFilteredBundlesWithProjectProperties()
- throws Exception
- {
- final MavenProjectResourcesStub project = createTestProject( "default-filterbundles-two" );
+ public void testFilteredBundlesWithProjectProperties() throws Exception {
+ final MavenProjectResourcesStub project = createTestProject("default-filterbundles-two");
final ProcessRemoteResourcesMojo mojo =
- lookupProcessMojoWithSettings( project,
- new String[] {"test-filtered-bundles:test-filtered-bundles:2"} );
+ lookupProcessMojoWithSettings(project, new String[] {"test-filtered-bundles:test-filtered-bundles:2"});
mojo.includeProjectProperties = true;
- setupDefaultProject( project );
+ setupDefaultProject(project);
- project.addProperty( "testingPropertyOne", "maven" );
- project.addProperty( "testingPropertyTwo", "rules" );
+ project.addProperty("testingPropertyOne", "maven");
+ project.addProperty("testingPropertyTwo", "rules");
- String path = pathOf( new DefaultArtifact( "test-filtered-bundles", "test-filtered-bundles",
- VersionRange.createFromVersion( "2" ), null, "jar", "",
- new DefaultArtifactHandler() ) );
+ String path = pathOf(new DefaultArtifact(
+ "test-filtered-bundles",
+ "test-filtered-bundles",
+ VersionRange.createFromVersion("2"),
+ null,
+ "jar",
+ "",
+ new DefaultArtifactHandler()));
- File file = new File( path );
+ File file = new File(path);
file.getParentFile().mkdirs();
- buildResourceBundle( "default-filterbundles-two-create", null, new String[] {"PROPERTIES.txt.vm"}, file );
+ buildResourceBundle("default-filterbundles-two-create", null, new String[] {"PROPERTIES.txt.vm"}, file);
mojo.execute();
// executing a second time (example: forked lifecycle) should still work
mojo.execute();
- file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
- file = new File( file, "PROPERTIES.txt" );
+ file = (File) getVariableValueFromObject(mojo, "outputDirectory");
+ file = new File(file, "PROPERTIES.txt");
- assertTrue( file.exists() );
+ assertTrue(file.exists());
- String data = FileUtils.fileRead( file );
- assertTrue( data.contains( "maven" ) );
- assertTrue( data.contains( "rules" ) );
+ String data = FileUtils.fileRead(file);
+ assertTrue(data.contains("maven"));
+ assertTrue(data.contains("rules"));
}
- protected void buildResourceBundle( String id,
- String sourceEncoding,
- String[] resourceNames,
- File jarName )
- throws Exception
- {
- final MavenProjectResourcesStub project = createTestProject( id );
+ protected void buildResourceBundle(String id, String sourceEncoding, String[] resourceNames, File jarName)
+ throws Exception {
+ final MavenProjectResourcesStub project = createTestProject(id);
- final File resourceDir = new File( project.getBasedir() + "/src/main/resources" );
- final BundleRemoteResourcesMojo mojo = lookupBundleMojoWithSettings( project, resourceDir, sourceEncoding );
+ final File resourceDir = new File(project.getBasedir() + "/src/main/resources");
+ final BundleRemoteResourcesMojo mojo = lookupBundleMojoWithSettings(project, resourceDir, sourceEncoding);
- setupDefaultProject( project );
+ setupDefaultProject(project);
- for ( String resourceName2 : resourceNames )
- {
- File resource = new File( resourceDir, resourceName2 );
- URL source = getClass().getResource( "/" + resourceName2 );
+ for (String resourceName2 : resourceNames) {
+ File resource = new File(resourceDir, resourceName2);
+ URL source = getClass().getResource("/" + resourceName2);
- FileUtils.copyURLToFile( source, resource );
+ FileUtils.copyURLToFile(source, resource);
}
mojo.execute();
- File xmlFile = new File( project.getBasedir() + "/target/classes/META-INF/maven/remote-resources.xml" );
- assertTrue( xmlFile.exists() );
+ File xmlFile = new File(project.getBasedir() + "/target/classes/META-INF/maven/remote-resources.xml");
+ assertTrue(xmlFile.exists());
- String data = FileUtils.fileRead( xmlFile );
- for ( String resourceName1 : resourceNames )
- {
- assertTrue( data.contains( resourceName1 ) );
+ String data = FileUtils.fileRead(xmlFile);
+ for (String resourceName1 : resourceNames) {
+ assertTrue(data.contains(resourceName1));
}
- if ( null != jarName )
- {
- try ( OutputStream fos = Files.newOutputStream( jarName.toPath() );
- JarOutputStream jar = new JarOutputStream( fos ) )
- {
- jar.putNextEntry( new ZipEntry( "META-INF/maven/remote-resources.xml" ) );
- jar.write( data.getBytes() );
+ if (null != jarName) {
+ try (OutputStream fos = Files.newOutputStream(jarName.toPath());
+ JarOutputStream jar = new JarOutputStream(fos)) {
+ jar.putNextEntry(new ZipEntry("META-INF/maven/remote-resources.xml"));
+ jar.write(data.getBytes());
jar.closeEntry();
- for ( String resourceName : resourceNames )
- {
- File resource = new File( resourceDir, resourceName );
- try ( InputStream in = Files.newInputStream( resource.toPath() ) )
- {
- jar.putNextEntry( new ZipEntry( resourceName ) );
- IOUtil.copy( in, jar );
+ for (String resourceName : resourceNames) {
+ File resource = new File(resourceDir, resourceName);
+ try (InputStream in = Files.newInputStream(resource.toPath())) {
+ jar.putNextEntry(new ZipEntry(resourceName));
+ IOUtil.copy(in, jar);
jar.closeEntry();
}
}
@@ -427,127 +322,108 @@ public class RemoteResourcesMojoTest
}
}
-
- protected MavenProjectResourcesStub createTestProject( final String testName )
- throws Exception
- {
+ protected MavenProjectResourcesStub createTestProject(final String testName) throws Exception {
// this will automatically create the isolated
// test environment
- return new MavenProjectResourcesStub( testName );
+ return new MavenProjectResourcesStub(testName);
}
- protected void setupDefaultProject( final MavenProjectResourcesStub project )
- throws Exception
- {
+ protected void setupDefaultProject(final MavenProjectResourcesStub project) throws Exception {
// put this on the root dir
- project.addFile( "pom.xml", MavenProjectBuildStub.ROOT_FILE );
- project.setInceptionYear( "2007" );
+ project.addFile("pom.xml", MavenProjectBuildStub.ROOT_FILE);
+ project.setInceptionYear("2007");
// start creating the environment
project.setupBuildEnvironment();
}
+ protected BundleRemoteResourcesMojo lookupBundleMojo() throws Exception {
+ File pomFile = new File(getBasedir(), DEFAULT_BUNDLE_POM_PATH);
+ BundleRemoteResourcesMojo mojo = (BundleRemoteResourcesMojo) lookupMojo("bundle", pomFile);
- protected BundleRemoteResourcesMojo lookupBundleMojo()
- throws Exception
- {
- File pomFile = new File( getBasedir(), DEFAULT_BUNDLE_POM_PATH );
- BundleRemoteResourcesMojo mojo = (BundleRemoteResourcesMojo) lookupMojo( "bundle", pomFile );
-
- assertNotNull( mojo );
+ assertNotNull(mojo);
return mojo;
}
- protected BundleRemoteResourcesMojo lookupBundleMojoWithDefaultSettings( final MavenProject project )
- throws Exception
- {
- File resourceDir = new File( project.getBasedir() + "/src/main/resources" );
- return lookupBundleMojoWithSettings( project, resourceDir, null );
+ protected BundleRemoteResourcesMojo lookupBundleMojoWithDefaultSettings(final MavenProject project)
+ throws Exception {
+ File resourceDir = new File(project.getBasedir() + "/src/main/resources");
+ return lookupBundleMojoWithSettings(project, resourceDir, null);
}
- protected BundleRemoteResourcesMojo lookupBundleMojoWithSettings( final MavenProject project,
- File resourceDir, String sourceEncoding )
- throws Exception
- {
+ protected BundleRemoteResourcesMojo lookupBundleMojoWithSettings(
+ final MavenProject project, File resourceDir, String sourceEncoding) throws Exception {
final BundleRemoteResourcesMojo mojo = lookupBundleMojo();
- setVariableValueToObject( mojo, "resourcesDirectory", resourceDir );
- setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
- setVariableValueToObject( mojo, "sourceEncoding", sourceEncoding );
+ setVariableValueToObject(mojo, "resourcesDirectory", resourceDir);
+ setVariableValueToObject(
+ mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
+ setVariableValueToObject(mojo, "sourceEncoding", sourceEncoding);
return mojo;
}
- protected ProcessRemoteResourcesMojo lookupProcessMojo()
- throws Exception
- {
- File pomFile = new File( getBasedir(), DEFAULT_PROCESS_POM_PATH );
- ProcessRemoteResourcesMojo mojo = (ProcessRemoteResourcesMojo) lookupMojo( "process", pomFile );
+ protected ProcessRemoteResourcesMojo lookupProcessMojo() throws Exception {
+ File pomFile = new File(getBasedir(), DEFAULT_PROCESS_POM_PATH);
+ ProcessRemoteResourcesMojo mojo = (ProcessRemoteResourcesMojo) lookupMojo("process", pomFile);
- assertNotNull( mojo );
+ assertNotNull(mojo);
return mojo;
}
-
- protected ProcessRemoteResourcesMojo lookupProcessMojoWithSettings( final MavenProject project,
- String[] bundles )
- throws Exception
- {
- return lookupProcessMojoWithSettings( project, new ArrayList<>( Arrays.asList( bundles ) ) );
+ protected ProcessRemoteResourcesMojo lookupProcessMojoWithSettings(final MavenProject project, String[] bundles)
+ throws Exception {
+ return lookupProcessMojoWithSettings(project, new ArrayList<>(Arrays.asList(bundles)));
}
- protected ProcessRemoteResourcesMojo lookupProcessMojoWithSettings( final MavenProject project,
- ArrayList<String> bundles )
- throws Exception
- {
+ protected ProcessRemoteResourcesMojo lookupProcessMojoWithSettings(
+ final MavenProject project, ArrayList<String> bundles) throws Exception {
final ProcessRemoteResourcesMojo mojo = lookupProcessMojo();
DefaultRepositorySystemSession reposession = MavenRepositorySystemUtils.newSession();
- reposession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory()
- .newInstance( reposession, new LocalRepository( new File( LOCAL_REPO ) ) ) );
+ reposession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory()
+ .newInstance(reposession, new LocalRepository(new File(LOCAL_REPO))));
DefaultMavenExecutionRequest request = new DefaultMavenExecutionRequest();
- request.setUserProperties( null );
- //request.setLocalRepository( reposession.getLocalRepository() );
- request.setGoals( Collections.singletonList( "install" ) );
- request.setBaseDirectory( project.getBasedir() );
- request.setStartTime( Calendar.getInstance().getTime() );
+ request.setUserProperties(null);
+ // request.setLocalRepository( reposession.getLocalRepository() );
+ request.setGoals(Collections.singletonList("install"));
+ request.setBaseDirectory(project.getBasedir());
+ request.setStartTime(Calendar.getInstance().getTime());
// TODO: get rid of this uglyness/legacy
MavenArtifactRepository localRepository = new MavenArtifactRepository();
- localRepository.setId( "local" );
- localRepository.setUrl( new File( LOCAL_REPO ).toURI().toASCIIString() );
- localRepository.setLayout( new DefaultRepositoryLayout() );
- request.setLocalRepository( localRepository );
+ localRepository.setId("local");
+ localRepository.setUrl(new File(LOCAL_REPO).toURI().toASCIIString());
+ localRepository.setLayout(new DefaultRepositoryLayout());
+ request.setLocalRepository(localRepository);
MavenSession session =
- new MavenSession( getContainer(), reposession, request, new DefaultMavenExecutionResult() );
- session.setProjects( Collections.singletonList( project ) );
-
- setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
- setVariableValueToObject( mojo, "resourceBundles", bundles );
- setVariableValueToObject( mojo, "mavenSession", session );
- setVariableValueToObject( mojo, "project", project );
+ new MavenSession(getContainer(), reposession, request, new DefaultMavenExecutionResult());
+ session.setProjects(Collections.singletonList(project));
+
+ setVariableValueToObject(
+ mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
+ setVariableValueToObject(mojo, "resourceBundles", bundles);
+ setVariableValueToObject(mojo, "mavenSession", session);
+ setVariableValueToObject(mojo, "project", project);
return mojo;
}
- protected ProcessRemoteResourcesMojo lookupProcessMojoWithDefaultSettings( final MavenProject project )
- throws Exception
- {
- return lookupProcessMojoWithSettings( project, new ArrayList<>() );
+ protected ProcessRemoteResourcesMojo lookupProcessMojoWithDefaultSettings(final MavenProject project)
+ throws Exception {
+ return lookupProcessMojoWithSettings(project, new ArrayList<>());
}
- private String pathOf( Artifact artifact )
- {
- String path = LOCAL_REPO + artifact.getGroupId().replace( ".", "/" ) + "/"
+ private String pathOf(Artifact artifact) {
+ String path = LOCAL_REPO + artifact.getGroupId().replace(".", "/") + "/"
+ artifact.getArtifactId() + "/"
+ artifact.getBaseVersion() + "/"
+ artifact.getArtifactId() + "-" + artifact.getVersion();
- if ( artifact.getClassifier() != null && !artifact.getClassifier().isEmpty() )
- {
+ if (artifact.getClassifier() != null && !artifact.getClassifier().isEmpty()) {
path = path + "-" + artifact.getClassifier();
}
String ext = artifact.getArtifactHandler().getExtension();
- if ( ext == null ) {
+ if (ext == null) {
ext = artifact.getType();
}
path = path + "." + ext;
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/AbstractIT.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/AbstractIT.java
index 814ba12..59e1879 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/AbstractIT.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/AbstractIT.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.it;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,16 +16,14 @@ package org.apache.maven.plugin.resources.remote.it;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.it;
import org.apache.maven.plugin.resources.remote.it.support.BootstrapInstaller;
import org.junit.Before;
-public abstract class AbstractIT
-{
+public abstract class AbstractIT {
@Before
- public void setUp()
- throws Exception
- {
+ public void setUp() throws Exception {
BootstrapInstaller.install();
}
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_BadDependencyPoms.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_BadDependencyPoms.java
index bb8358b..39a098a 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_BadDependencyPoms.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_BadDependencyPoms.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.it;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,8 +16,11 @@ package org.apache.maven.plugin.resources.remote.it;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.it;
-import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.apache.maven.plugin.resources.remote.it.support.TestUtils;
import org.apache.maven.shared.verifier.VerificationException;
@@ -27,32 +28,23 @@ import org.apache.maven.shared.verifier.Verifier;
import org.codehaus.plexus.util.FileUtils;
import org.junit.Test;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import static org.junit.Assert.assertTrue;
/**
* @author Benjamin Bentmann
*/
-public class IT_BadDependencyPoms
- extends AbstractIT
-{
+public class IT_BadDependencyPoms extends AbstractIT {
@Test
- public void test()
- throws IOException, URISyntaxException, VerificationException
- {
- File dir = TestUtils.getTestDir( "bad-dependency-poms" );
+ public void test() throws IOException, URISyntaxException, VerificationException {
+ File dir = TestUtils.getTestDir("bad-dependency-poms");
- Verifier verifier = TestUtils.newVerifier( dir );
- verifier.deleteArtifacts( "test" );
- verifier.getSystemProperties().setProperty( "it.dir", dir.getAbsolutePath() );
+ Verifier verifier = TestUtils.newVerifier(dir);
+ verifier.deleteArtifacts("test");
+ verifier.getSystemProperties().setProperty("it.dir", dir.getAbsolutePath());
- try
- {
- verifier.executeGoal( "generate-resources" );
- }
- catch ( VerificationException e )
- {
+ try {
+ verifier.executeGoal("generate-resources");
+ } catch (VerificationException e) {
verifier.resetStreams();
// We will get an exception from harness in case
@@ -65,14 +57,15 @@ public class IT_BadDependencyPoms
// from maven which will print out message according to
// the missing artifacts.
- File output = new File( dir, "log.txt" );
- String content = FileUtils.fileRead( output );
+ File output = new File(dir, "log.txt");
+ String content = FileUtils.fileRead(output);
- assertTrue( content.contains( "mvn install:install-file -DgroupId=test -DartifactId=pom -Dversion=0.2 -Dpackaging=jar" ) );
- assertTrue( content.contains( "mvn install:install-file -DgroupId=test -DartifactId=missing -Dversion=0.1 -Dpackaging=jar" ) );
- assertTrue( content.contains( "mvn install:install-file -DgroupId=test -DartifactId=invalid -Dversion=0.1 -Dpackaging=jar" ) );
+ assertTrue(content.contains(
+ "mvn install:install-file -DgroupId=test -DartifactId=pom -Dversion=0.2 -Dpackaging=jar"));
+ assertTrue(content.contains(
+ "mvn install:install-file -DgroupId=test -DartifactId=missing -Dversion=0.1 -Dpackaging=jar"));
+ assertTrue(content.contains(
+ "mvn install:install-file -DgroupId=test -DartifactId=invalid -Dversion=0.1 -Dpackaging=jar"));
}
-
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_CustomFilterDelimiter.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_CustomFilterDelimiter.java
index b4d479c..c8776ad 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_CustomFilterDelimiter.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_CustomFilterDelimiter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.it;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,8 +16,11 @@ package org.apache.maven.plugin.resources.remote.it;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.it;
-import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.apache.maven.plugin.resources.remote.it.support.TestUtils;
import org.apache.maven.shared.verifier.VerificationException;
@@ -27,30 +28,23 @@ import org.apache.maven.shared.verifier.Verifier;
import org.codehaus.plexus.util.FileUtils;
import org.junit.Test;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import static org.junit.Assert.assertTrue;
-public class IT_CustomFilterDelimiter
- extends AbstractIT
-{
+public class IT_CustomFilterDelimiter extends AbstractIT {
@Test
- public void test()
- throws IOException, URISyntaxException, VerificationException
- {
- File dir = TestUtils.getTestDir( "custom-filter-delim" );
- Verifier verifier = TestUtils.newVerifier( dir );
+ public void test() throws IOException, URISyntaxException, VerificationException {
+ File dir = TestUtils.getTestDir("custom-filter-delim");
+ Verifier verifier = TestUtils.newVerifier(dir);
- verifier.addCliArgument( "-X" );
- verifier.addCliArgument( "validate" );
+ verifier.addCliArgument("-X");
+ verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
- File output = new File( dir, "target/maven-shared-archive-resources/DEPENDENCIES" );
- String content = FileUtils.fileRead( output );
+ File output = new File(dir, "target/maven-shared-archive-resources/DEPENDENCIES");
+ String content = FileUtils.fileRead(output);
- assertTrue( content.contains( "Override: custom-filter-delim" ) );
+ assertTrue(content.contains("Override: custom-filter-delim"));
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_FilterLocalOverride.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_FilterLocalOverride.java
index 78a4617..73cc527 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_FilterLocalOverride.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_FilterLocalOverride.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.it;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,8 +16,11 @@ package org.apache.maven.plugin.resources.remote.it;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.it;
-import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.apache.maven.plugin.resources.remote.it.support.TestUtils;
import org.apache.maven.shared.verifier.VerificationException;
@@ -27,28 +28,21 @@ import org.apache.maven.shared.verifier.Verifier;
import org.codehaus.plexus.util.FileUtils;
import org.junit.Test;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import static org.junit.Assert.assertTrue;
-public class IT_FilterLocalOverride
- extends AbstractIT
-{
+public class IT_FilterLocalOverride extends AbstractIT {
@Test
- public void test()
- throws IOException, URISyntaxException, VerificationException
- {
- File dir = TestUtils.getTestDir( "filter-local-override" );
- Verifier verifier = TestUtils.newVerifier( dir );
+ public void test() throws IOException, URISyntaxException, VerificationException {
+ File dir = TestUtils.getTestDir("filter-local-override");
+ Verifier verifier = TestUtils.newVerifier(dir);
- verifier.addCliArgument( "generate-resources" );
+ verifier.addCliArgument("generate-resources");
verifier.execute();
verifier.verifyErrorFreeLog();
- File output = new File( dir, "target/maven-shared-archive-resources/DEPENDENCIES" );
- String content = FileUtils.fileRead( output );
+ File output = new File(dir, "target/maven-shared-archive-resources/DEPENDENCIES");
+ String content = FileUtils.fileRead(output);
- assertTrue( content.contains( "Override: filter-local-override" ) );
+ assertTrue(content.contains("Override: filter-local-override"));
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GenerateFromBundle.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GenerateFromBundle.java
index 7e3b62a..a6771c7 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GenerateFromBundle.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GenerateFromBundle.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.it;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,8 +16,11 @@ package org.apache.maven.plugin.resources.remote.it;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.it;
-import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.apache.maven.plugin.resources.remote.it.support.TestUtils;
import org.apache.maven.shared.verifier.VerificationException;
@@ -27,28 +28,21 @@ import org.apache.maven.shared.verifier.Verifier;
import org.codehaus.plexus.util.FileUtils;
import org.junit.Test;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import static org.junit.Assert.assertTrue;
-public class IT_GenerateFromBundle
- extends AbstractIT
-{
+public class IT_GenerateFromBundle extends AbstractIT {
@Test
- public void test()
- throws IOException, URISyntaxException, VerificationException
- {
- File dir = TestUtils.getTestDir( "generate-from-bundle" );
- Verifier verifier = TestUtils.newVerifier( dir );
+ public void test() throws IOException, URISyntaxException, VerificationException {
+ File dir = TestUtils.getTestDir("generate-from-bundle");
+ Verifier verifier = TestUtils.newVerifier(dir);
- verifier.addCliArgument( "generate-resources" );
+ verifier.addCliArgument("generate-resources");
verifier.execute();
verifier.verifyErrorFreeLog();
- File output = new File( dir, "target/maven-shared-archive-resources/DEPENDENCIES" );
- String content = FileUtils.fileRead( output );
+ File output = new File(dir, "target/maven-shared-archive-resources/DEPENDENCIES");
+ String content = FileUtils.fileRead(output);
- assertTrue( content.contains( "Built-In:" ) );
+ assertTrue(content.contains("Built-In:"));
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GenerateFromBundleWithTypeAndClassifier.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GenerateFromBundleWithTypeAndClassifier.java
index a04ff75..345730a 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GenerateFromBundleWithTypeAndClassifier.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GenerateFromBundleWithTypeAndClassifier.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.it;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,8 +16,11 @@ package org.apache.maven.plugin.resources.remote.it;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.it;
-import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.apache.maven.plugin.resources.remote.it.support.TestUtils;
import org.apache.maven.shared.verifier.VerificationException;
@@ -27,29 +28,22 @@ import org.apache.maven.shared.verifier.Verifier;
import org.codehaus.plexus.util.FileUtils;
import org.junit.Test;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import static org.junit.Assert.assertTrue;
-public class IT_GenerateFromBundleWithTypeAndClassifier
- extends AbstractIT
-{
+public class IT_GenerateFromBundleWithTypeAndClassifier extends AbstractIT {
@Test
- public void test()
- throws IOException, URISyntaxException, VerificationException
- {
+ public void test() throws IOException, URISyntaxException, VerificationException {
- File dir = TestUtils.getTestDir( "generate-from-bundle-with-type-and-classifier" );
- Verifier verifier = TestUtils.newVerifier( dir );
+ File dir = TestUtils.getTestDir("generate-from-bundle-with-type-and-classifier");
+ Verifier verifier = TestUtils.newVerifier(dir);
- verifier.addCliArgument( "generate-resources" );
+ verifier.addCliArgument("generate-resources");
verifier.execute();
verifier.verifyErrorFreeLog();
- File output = new File( dir, "target/maven-shared-archive-resources/DEPENDENCIES" );
- String content = FileUtils.fileRead( output );
+ File output = new File(dir, "target/maven-shared-archive-resources/DEPENDENCIES");
+ String content = FileUtils.fileRead(output);
- assertTrue( content.contains( "Built-In:" ) );
+ assertTrue(content.contains("Built-In:"));
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GenerateFromOverride.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GenerateFromOverride.java
index 06ecfd5..c4ba634 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GenerateFromOverride.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GenerateFromOverride.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.it;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,8 +16,11 @@ package org.apache.maven.plugin.resources.remote.it;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.it;
-import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.apache.maven.plugin.resources.remote.it.support.TestUtils;
import org.apache.maven.shared.verifier.VerificationException;
@@ -27,28 +28,21 @@ import org.apache.maven.shared.verifier.Verifier;
import org.codehaus.plexus.util.FileUtils;
import org.junit.Test;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import static org.junit.Assert.assertTrue;
-public class IT_GenerateFromOverride
- extends AbstractIT
-{
+public class IT_GenerateFromOverride extends AbstractIT {
@Test
- public void test()
- throws IOException, URISyntaxException, VerificationException
- {
- File dir = TestUtils.getTestDir( "generate-from-override" );
- Verifier verifier = TestUtils.newVerifier( dir );
+ public void test() throws IOException, URISyntaxException, VerificationException {
+ File dir = TestUtils.getTestDir("generate-from-override");
+ Verifier verifier = TestUtils.newVerifier(dir);
- verifier.addCliArgument( "generate-resources" );
+ verifier.addCliArgument("generate-resources");
verifier.execute();
verifier.verifyErrorFreeLog();
- File output = new File( dir, "target/maven-shared-archive-resources/DEPENDENCIES" );
- String content = FileUtils.fileRead( output );
+ File output = new File(dir, "target/maven-shared-archive-resources/DEPENDENCIES");
+ String content = FileUtils.fileRead(output);
- assertTrue( content.contains( "Override:" ) );
+ assertTrue(content.contains("Override:"));
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GetDependencyProjects.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GetDependencyProjects.java
index 350d298..8d071be 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GetDependencyProjects.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GetDependencyProjects.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.it;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,8 +16,11 @@ package org.apache.maven.plugin.resources.remote.it;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.it;
-import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.apache.maven.plugin.resources.remote.it.support.TestUtils;
import org.apache.maven.shared.verifier.VerificationException;
@@ -27,40 +28,31 @@ import org.apache.maven.shared.verifier.Verifier;
import org.codehaus.plexus.util.FileUtils;
import org.junit.Test;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import static org.junit.Assert.assertTrue;
/**
* @author Benjamin Bentmann
*/
-public class IT_GetDependencyProjects
- extends AbstractIT
-{
+public class IT_GetDependencyProjects extends AbstractIT {
@Test
- public void test()
- throws IOException, URISyntaxException, VerificationException
- {
- File dir = TestUtils.getTestDir( "get-dependency-projects" );
+ public void test() throws IOException, URISyntaxException, VerificationException {
+ File dir = TestUtils.getTestDir("get-dependency-projects");
Verifier verifier;
- verifier = TestUtils.newVerifier( dir );
- verifier.addCliArgument( "deploy" );
+ verifier = TestUtils.newVerifier(dir);
+ verifier.addCliArgument("deploy");
verifier.execute();
verifier.verifyErrorFreeLog();
- verifier = TestUtils.newVerifier( new File( dir, "project" ) );
+ verifier = TestUtils.newVerifier(new File(dir, "project"));
- verifier.deleteArtifacts( "org.apache.maven.plugin.rresource.it.gdp" );
+ verifier.deleteArtifacts("org.apache.maven.plugin.rresource.it.gdp");
- try
- {
- verifier.addCliArgument( "generate-resources" );
+ try {
+ verifier.addCliArgument("generate-resources");
verifier.execute();
- }
- catch ( VerificationException e)
- {
+ } catch (VerificationException e) {
// We will get an exception from harness in case
// of execution failure (return code non zero).
// This is the case if we have missing artifacts
@@ -70,11 +62,15 @@ public class IT_GetDependencyProjects
// So the only reliable way is to check the log output
// from maven which will print out message according to
// the missing artifacts.
- File output = new File( verifier.getBasedir(), "log.txt" );
- String content = FileUtils.fileRead( output );
+ File output = new File(verifier.getBasedir(), "log.txt");
+ String content = FileUtils.fileRead(output);
- assertTrue( content.contains( "mvn install:install-file -DgroupId=org.apache.maven.plugin.rresource.it.gdp -DartifactId=release -Dversion=1.0 -Dpackaging=jar" ) );
- assertTrue( content.contains( "mvn install:install-file -DgroupId=org.apache.maven.plugin.rresource.it.gdp -DartifactId=snapshot -Dversion=1.0-SNAPSHOT -Dpackaging=jar" ) );
+ assertTrue(
+ content.contains(
+ "mvn install:install-file -DgroupId=org.apache.maven.plugin.rresource.it.gdp -DartifactId=release -Dversion=1.0 -Dpackaging=jar"));
+ assertTrue(
+ content.contains(
+ "mvn install:install-file -DgroupId=org.apache.maven.plugin.rresource.it.gdp -DartifactId=snapshot -Dversion=1.0-SNAPSHOT -Dpackaging=jar"));
}
}
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_RunOnlyAtExecutionRoot.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_RunOnlyAtExecutionRoot.java
index 32b88a2..a151ed4 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_RunOnlyAtExecutionRoot.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_RunOnlyAtExecutionRoot.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.it;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,10 +16,11 @@ package org.apache.maven.plugin.resources.remote.it;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.it;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.apache.maven.plugin.resources.remote.it.support.TestUtils;
import org.apache.maven.shared.verifier.VerificationException;
@@ -30,36 +29,33 @@ import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.Os;
import org.junit.Test;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
/**
* @author Benjamin Bentmann
*/
-public class IT_RunOnlyAtExecutionRoot
- extends AbstractIT
-{
+public class IT_RunOnlyAtExecutionRoot extends AbstractIT {
@Test
- public void test()
- throws IOException, URISyntaxException, VerificationException
- {
+ public void test() throws IOException, URISyntaxException, VerificationException {
// Workaround for Windows + Maven-3.5.x/3.6.0 + Jenkins due to MNG-6261
- assumeTrue( !( System.getenv( "JENKINS_HOME" ) != null
- && Os.isFamily( Os.FAMILY_WINDOWS )
- && ( System.getenv( "MAVEN_HOME" ).contains( "-3.5." ) || System.getenv( "MAVEN_HOME" ).contains( "-3.6.0" ) ) ) );
+ assumeTrue(!(System.getenv("JENKINS_HOME") != null
+ && Os.isFamily(Os.FAMILY_WINDOWS)
+ && (System.getenv("MAVEN_HOME").contains("-3.5.")
+ || System.getenv("MAVEN_HOME").contains("-3.6.0"))));
- File dir = TestUtils.getTestDir( "run-only-at-execution-root" );
+ File dir = TestUtils.getTestDir("run-only-at-execution-root");
Verifier verifier;
- verifier = TestUtils.newVerifier( new File( dir, "resource-projects" ) );
- verifier.addCliArgument( "deploy" );
+ verifier = TestUtils.newVerifier(new File(dir, "resource-projects"));
+ verifier.addCliArgument("deploy");
verifier.execute();
- verifier.setLogFileName( "first.log" );
+ verifier.setLogFileName("first.log");
verifier.verifyErrorFreeLog();
- verifier = TestUtils.newVerifier( dir );
+ verifier = TestUtils.newVerifier(dir);
// I'm not sure what exactly the intention of the test was.
// Based on the name i assumed to be sure the remote-resources-plugin
@@ -70,22 +66,21 @@ public class IT_RunOnlyAtExecutionRoot
// verifier.deleteArtifacts( "org.apache.maven.plugin.rresource.it.mrr41" );
// verifier.addCliArgument( "generate-resources" );
- verifier.addCliArgument( "package" );
+ verifier.addCliArgument("package");
verifier.execute();
verifier.verifyErrorFreeLog();
String depResource = "target/maven-shared-archive-resources/DEPENDENCIES";
- File output = new File( dir, depResource );
- assertTrue( output.exists() );
+ File output = new File(dir, depResource);
+ assertTrue(output.exists());
// aggregates in bulk, not per-child
- assertFalse( new File( dir, "child1/" + depResource ).exists() );
- assertFalse( new File( dir, "child2/" + depResource ).exists() );
+ assertFalse(new File(dir, "child1/" + depResource).exists());
+ assertFalse(new File(dir, "child2/" + depResource).exists());
- String content = FileUtils.fileRead( output );
+ String content = FileUtils.fileRead(output);
- assertTrue( content.contains( "Dependency Id: org.apache.maven.plugin.rresource.it.mrr41:release:1.0" ) );
- assertTrue( content.contains( "Dependency Id: org.apache.maven.plugin.rresource.it.mrr41:snapshot:1.0-SNAPSHOT" ) );
+ assertTrue(content.contains("Dependency Id: org.apache.maven.plugin.rresource.it.mrr41:release:1.0"));
+ assertTrue(content.contains("Dependency Id: org.apache.maven.plugin.rresource.it.mrr41:snapshot:1.0-SNAPSHOT"));
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_SupplementalArtifact.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_SupplementalArtifact.java
index e4e07e7..a4af81c 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_SupplementalArtifact.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_SupplementalArtifact.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.it;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,8 +16,11 @@ package org.apache.maven.plugin.resources.remote.it;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.it;
-import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.apache.maven.plugin.resources.remote.it.support.TestUtils;
import org.apache.maven.shared.verifier.VerificationException;
@@ -27,44 +28,39 @@ import org.apache.maven.shared.verifier.Verifier;
import org.codehaus.plexus.util.FileUtils;
import org.junit.Test;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import static org.junit.Assert.assertTrue;
/**
* @author John Casey
*/
-public class IT_SupplementalArtifact
- extends AbstractIT
-{
+public class IT_SupplementalArtifact extends AbstractIT {
@Test
- public void test()
- throws IOException, URISyntaxException, VerificationException
- {
- File dir = TestUtils.getTestDir( "supplemental-artifact" );
- File resources = new File( dir, "resource-projects" );
+ public void test() throws IOException, URISyntaxException, VerificationException {
+ File dir = TestUtils.getTestDir("supplemental-artifact");
+ File resources = new File(dir, "resource-projects");
Verifier verifier;
- verifier = TestUtils.newVerifier( resources );
+ verifier = TestUtils.newVerifier(resources);
- verifier.deleteArtifacts( "org.apache.maven.plugin.rresource.it.mrr43" );
+ verifier.deleteArtifacts("org.apache.maven.plugin.rresource.it.mrr43");
- verifier.addCliArgument( "deploy" );
+ verifier.addCliArgument("deploy");
verifier.execute();
verifier.verifyErrorFreeLog();
- verifier = TestUtils.newVerifier( dir );
+ verifier = TestUtils.newVerifier(dir);
- verifier.addCliArgument( "generate-resources" );
+ verifier.addCliArgument("generate-resources");
verifier.execute();
verifier.verifyErrorFreeLog();
- File output = new File( dir, "target/maven-shared-archive-resources/DEPENDENCIES" );
- String content = FileUtils.fileRead( output );
+ File output = new File(dir, "target/maven-shared-archive-resources/DEPENDENCIES");
+ String content = FileUtils.fileRead(output);
- assertTrue( content.contains( "From: 'Deficient Tooling, Inc.' (http://www.deficient-tools.us/)" ) );
- assertTrue( content.contains( "Deficient Dependency (http://www.deficient-tools.us/dep) org.apache.maven.plugin.rresource.it.mrr43:deficient-dep" ) );
+ assertTrue(content.contains("From: 'Deficient Tooling, Inc.' (http://www.deficient-tools.us/)"));
+ assertTrue(
+ content.contains(
+ "Deficient Dependency (http://www.deficient-tools.us/dep) org.apache.maven.plugin.rresource.it.mrr43:deficient-dep"));
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/support/BootstrapInstaller.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/support/BootstrapInstaller.java
index f3ff52c..77808e8 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/support/BootstrapInstaller.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/support/BootstrapInstaller.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.it.support;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,7 +16,7 @@ package org.apache.maven.plugin.resources.remote.it.support;
* specific language governing permissions and limitations
* under the License.
*/
-
+package org.apache.maven.plugin.resources.remote.it.support;
import java.io.File;
import java.io.IOException;
@@ -27,21 +25,17 @@ import java.net.URISyntaxException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.shared.verifier.Verifier;
-public class BootstrapInstaller
-{
+public class BootstrapInstaller {
private static boolean installed = false;
- public static void install()
- throws IOException, URISyntaxException, VerificationException
- {
- if ( !installed )
- {
- File bootstrapDir = TestUtils.getTestDir( "bootstrap" );
+ public static void install() throws IOException, URISyntaxException, VerificationException {
+ if (!installed) {
+ File bootstrapDir = TestUtils.getTestDir("bootstrap");
- Verifier verifier = TestUtils.newVerifier( bootstrapDir );
+ Verifier verifier = TestUtils.newVerifier(bootstrapDir);
- verifier.executeGoal( "deploy" );
+ verifier.executeGoal("deploy");
verifier.verifyErrorFreeLog();
verifier.resetStreams();
@@ -49,5 +43,4 @@ public class BootstrapInstaller
installed = true;
}
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/support/TestUtils.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/support/TestUtils.java
index 61a8991..3cae087 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/support/TestUtils.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/support/TestUtils.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.it.support;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugin.resources.remote.it.support;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.it.support;
import java.io.File;
import java.io.IOException;
@@ -28,49 +27,37 @@ import java.net.URL;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.shared.verifier.Verifier;
-public class TestUtils
-{
- public static File getTestDir( final String name )
- throws IOException, URISyntaxException
- {
+public class TestUtils {
+ public static File getTestDir(final String name) throws IOException, URISyntaxException {
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
- URL resource = cloader.getResource( name );
+ URL resource = cloader.getResource(name);
- if ( resource == null )
- {
- throw new IOException( "Cannot find test directory: " + name );
+ if (resource == null) {
+ throw new IOException("Cannot find test directory: " + name);
}
- return new File( new URI( resource.toExternalForm() ).normalize().getPath() );
+ return new File(new URI(resource.toExternalForm()).normalize().getPath());
}
- public static File getBaseDir()
- {
- File result = new File( System.getProperty( "basedir", "." ) );
- try
- {
+ public static File getBaseDir() {
+ File result = new File(System.getProperty("basedir", "."));
+ try {
return result.getCanonicalFile();
- }
- catch ( IOException e )
- {
+ } catch (IOException e) {
return result.getAbsoluteFile();
}
}
- public static Verifier newVerifier( File dir )
- throws VerificationException
- {
- Verifier verifier = new Verifier( dir.getAbsolutePath() );
- verifier.setLocalRepo( System.getProperty( "localRepositoryPath" ) );
- verifier.getSystemProperties().setProperty( "https.protocols", System.getProperty( "https.protocols", "TLSv1.2" ) );
+ public static Verifier newVerifier(File dir) throws VerificationException {
+ Verifier verifier = new Verifier(dir.getAbsolutePath());
+ verifier.setLocalRepo(System.getProperty("localRepositoryPath"));
+ verifier.getSystemProperties().setProperty("https.protocols", System.getProperty("https.protocols", "TLSv1.2"));
- int javaVersion = Integer.getInteger( "java.specification.version", 7 );
- if ( javaVersion >= 12 )
- {
- verifier.setSystemProperty( "maven.compiler.source", "7" );
- verifier.setSystemProperty( "maven.compiler.target", "7" );
- }
+ int javaVersion = Integer.getInteger("java.specification.version", 7);
+ if (javaVersion >= 12) {
+ verifier.setSystemProperty("maven.compiler.source", "7");
+ verifier.setSystemProperty("maven.compiler.target", "7");
+ }
return verifier;
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/stub/ArtifactStub.java b/src/test/java/org/apache/maven/plugin/resources/remote/stub/ArtifactStub.java
index fc52d6f..df746a4 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/stub/ArtifactStub.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/stub/ArtifactStub.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.stub;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugin.resources.remote.stub;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.stub;
import java.io.File;
import java.util.Collection;
@@ -34,13 +33,10 @@ import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange;
-
/**
* Stub
*/
-public class ArtifactStub
- implements Artifact
-{
+public class ArtifactStub implements Artifact {
boolean hasClassifier;
@@ -80,300 +76,231 @@ public class ArtifactStub
VersionRange versionRange;
-
- public ArtifactStub()
- {
+ public ArtifactStub() {
type = "testtype";
scope = "testscope";
classifier = "testclassifier";
artifactHandler = new DefaultArtifactHandler();
}
- public void populate( MavenProjectBasicStub project )
- {
+ public void populate(MavenProjectBasicStub project) {
groupId = project.getGroupId();
artifactId = project.getArtifactId();
version = project.getVersion();
- versionRange = VersionRange.createFromVersion( version );
+ versionRange = VersionRange.createFromVersion(version);
}
@Override
- public boolean hasClassifier()
- {
+ public boolean hasClassifier() {
return true;
}
@Override
- public String getBaseVersion()
- {
+ public String getBaseVersion() {
return "Test Version";
}
@Override
- public void setBaseVersion( String version )
- {
+ public void setBaseVersion(String version) {
baseVersion = version;
}
@Override
- public void setFile( File _file )
- {
+ public void setFile(File _file) {
file = _file;
}
@Override
- public File getFile()
- {
- return new File( "testfile" );
+ public File getFile() {
+ return new File("testfile");
}
@Override
- public String getGroupId()
- {
+ public String getGroupId() {
return groupId;
}
@Override
- public String getArtifactId()
- {
+ public String getArtifactId() {
return artifactId;
}
@Override
- public String getVersion()
- {
+ public String getVersion() {
return version;
}
@Override
- public void setVersion( String _version )
- {
+ public void setVersion(String _version) {
version = _version;
}
@Override
- public String getScope()
- {
+ public String getScope() {
return scope;
}
@Override
- public String getType()
- {
+ public String getType() {
return type;
}
@Override
- public String getClassifier()
- {
+ public String getClassifier() {
return classifier;
}
@Override
- public String getId()
- {
+ public String getId() {
return identifier;
}
@Override
- public String getDependencyConflictId()
- {
+ public String getDependencyConflictId() {
return dependencyConflictId;
}
@Override
- public void addMetadata( ArtifactMetadata metadata )
- {
-
- }
+ public void addMetadata(ArtifactMetadata metadata) {}
@Override
- public Collection<ArtifactMetadata> getMetadataList()
- {
+ public Collection<ArtifactMetadata> getMetadataList() {
return new LinkedList<>();
}
@Override
- public void setRepository( ArtifactRepository remoteRepository )
- {
-
- }
+ public void setRepository(ArtifactRepository remoteRepository) {}
@Override
- public ArtifactRepository getRepository()
- {
+ public ArtifactRepository getRepository() {
return null;
}
@Override
- public void updateVersion( String version, ArtifactRepository localRepository )
- {
-
- }
+ public void updateVersion(String version, ArtifactRepository localRepository) {}
@Override
- public String getDownloadUrl()
- {
+ public String getDownloadUrl() {
return downloadUrl;
}
@Override
- public void setDownloadUrl( String _downloadUrl )
- {
+ public void setDownloadUrl(String _downloadUrl) {
downloadUrl = _downloadUrl;
}
@Override
- public ArtifactFilter getDependencyFilter()
- {
+ public ArtifactFilter getDependencyFilter() {
return null;
}
@Override
- public void setDependencyFilter( ArtifactFilter artifactFilter )
- {
-
- }
+ public void setDependencyFilter(ArtifactFilter artifactFilter) {}
@Override
- public ArtifactHandler getArtifactHandler()
- {
+ public ArtifactHandler getArtifactHandler() {
return artifactHandler;
}
@Override
- public List<String> getDependencyTrail()
- {
+ public List<String> getDependencyTrail() {
return new LinkedList<>();
}
@Override
- public void setDependencyTrail(List<String> dependencyTrail)
- {
-
- }
+ public void setDependencyTrail(List<String> dependencyTrail) {}
@Override
- public void setScope( String _scope )
- {
+ public void setScope(String _scope) {
scope = _scope;
}
@Override
- public VersionRange getVersionRange()
- {
+ public VersionRange getVersionRange() {
return versionRange;
}
@Override
- public void setVersionRange( VersionRange newRange )
- {
-
- }
+ public void setVersionRange(VersionRange newRange) {}
@Override
- public void selectVersion( String version )
- {
+ public void selectVersion(String version) {
selectedVersion = version;
}
@Override
- public void setGroupId( String _groupId )
- {
+ public void setGroupId(String _groupId) {
groupId = _groupId;
}
@Override
- public void setArtifactId( String _artifactId )
- {
+ public void setArtifactId(String _artifactId) {
artifactId = _artifactId;
}
@Override
- public boolean isSnapshot()
- {
+ public boolean isSnapshot() {
return true;
}
@Override
- public void setResolved( boolean _resolved )
- {
+ public void setResolved(boolean _resolved) {
resolved = _resolved;
}
@Override
- public boolean isResolved()
- {
+ public boolean isResolved() {
return true;
}
@Override
- public void setResolvedVersion( String version )
- {
+ public void setResolvedVersion(String version) {
resolvedVersion = version;
}
-
@Override
- public void setArtifactHandler( ArtifactHandler handler )
- {
-
- }
+ public void setArtifactHandler(ArtifactHandler handler) {}
@Override
- public boolean isRelease()
- {
+ public boolean isRelease() {
return true;
}
@Override
- public void setRelease( boolean _release )
- {
+ public void setRelease(boolean _release) {
release = _release;
}
@Override
- public List<ArtifactVersion> getAvailableVersions()
- {
+ public List<ArtifactVersion> getAvailableVersions() {
return new LinkedList<>();
}
@Override
- public void setAvailableVersions(List<ArtifactVersion> versions)
- {
-
- }
+ public void setAvailableVersions(List<ArtifactVersion> versions) {}
@Override
- public boolean isOptional()
- {
+ public boolean isOptional() {
return true;
}
@Override
- public void setOptional( boolean _optional )
- {
+ public void setOptional(boolean _optional) {
optional = _optional;
}
@Override
- public ArtifactVersion getSelectedVersion()
- throws OverConstrainedVersionException
- {
+ public ArtifactVersion getSelectedVersion() throws OverConstrainedVersionException {
return null;
}
@Override
- public boolean isSelectedVersionKnown()
- throws OverConstrainedVersionException
- {
+ public boolean isSelectedVersionKnown() throws OverConstrainedVersionException {
return true;
}
@Override
- public int compareTo( Artifact o )
- {
+ public int compareTo(Artifact o) {
return 0;
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBasicStub.java b/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBasicStub.java
index 07514ab..ac3d8fa 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBasicStub.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBasicStub.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.stub;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugin.resources.remote.stub;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.stub;
import java.io.File;
import java.util.HashSet;
@@ -34,9 +33,7 @@ import org.codehaus.plexus.util.FileUtils;
/**
* Stub
*/
-public class MavenProjectBasicStub
- extends MavenProject
-{
+public class MavenProjectBasicStub extends MavenProject {
protected String identifier;
protected String testRootDir;
@@ -51,11 +48,9 @@ public class MavenProjectBasicStub
protected ArtifactStub artifact;
- public MavenProjectBasicStub( String id )
- throws Exception
- {
+ public MavenProjectBasicStub(String id) throws Exception {
// most values are hardcoded to have a controlled environment
- super( new ModelStub() );
+ super(new ModelStub());
modelStub = (ModelStub) getModel();
properties = new Properties();
@@ -65,12 +60,11 @@ public class MavenProjectBasicStub
// set isolated root directory
testRootDir = PlexusTestCase.getBasedir() + "/target/test-classes/unit/test-dir/" + identifier;
- if ( !FileUtils.fileExists( testRootDir ) )
- {
- FileUtils.mkdir( testRootDir );
+ if (!FileUtils.fileExists(testRootDir)) {
+ FileUtils.mkdir(testRootDir);
}
- artifact.populate( this );
+ artifact.populate(this);
// this is ugly but needed to ensure that the copy constructor
// works correctly
@@ -78,94 +72,79 @@ public class MavenProjectBasicStub
}
@Override
- public String getName()
- {
+ public String getName() {
return "Test Project " + identifier;
}
@Override
- public void setDescription( String desc )
- {
+ public void setDescription(String desc) {
description = desc;
}
@Override
- public String getDescription()
- {
- if ( description == null )
- {
+ public String getDescription() {
+ if (description == null) {
return "this is a test project";
- }
- else
- {
+ } else {
return description;
}
}
@Override
- public File getBasedir()
- {
+ public File getBasedir() {
// create an isolated environment
// see setupTestEnvironment for details
- return new File( testRootDir );
+ return new File(testRootDir);
}
@Override
- public Artifact getArtifact()
- {
+ public Artifact getArtifact() {
return artifact;
}
@Override
- public String getGroupId()
- {
+ public String getGroupId() {
return "org.apache.maven.plugin.test";
}
@Override
- public String getArtifactId()
- {
+ public String getArtifactId() {
return "maven-resource-plugin-test#" + identifier;
}
@Override
- public String getPackaging()
- {
+ public String getPackaging() {
return "ejb";
}
@Override
- public String getVersion()
- {
+ public String getVersion() {
return identifier;
}
- public void addProperty( String key, String value )
- {
- properties.put( key, value );
+ public void addProperty(String key, String value) {
+ properties.put(key, value);
}
@Override
- public Properties getProperties()
- {
+ public Properties getProperties() {
return properties;
}
// to prevent the MavenProject copy constructor from blowing up
- private void initializeParentFields()
- {
+ private void initializeParentFields() {
// the pom should be located in the isolated dummy root
- super.setFile( new File( getBasedir(), "pom.xml" ) );
- super.setDependencyArtifacts( new HashSet<Artifact>() );
- super.setArtifacts( new HashSet<Artifact>() );
- super.setReportArtifacts( new HashSet<Artifact>() );
- super.setExtensionArtifacts( new HashSet<Artifact>() );
- super.setRemoteArtifactRepositories( new LinkedList<ArtifactRepository>() );
- super.setPluginArtifactRepositories( new LinkedList<ArtifactRepository>() );
- super.setCollectedProjects( new LinkedList<MavenProject>() );
- super.setActiveProfiles( new LinkedList<Profile>() );
- super.setOriginalModel( null );
- super.setExecutionProject( this );
- super.setArtifact( artifact );
+ super.setFile(new File(getBasedir(), "pom.xml"));
+ super.setDependencyArtifacts(new HashSet<Artifact>());
+ super.setArtifacts(new HashSet<Artifact>());
+ super.setReportArtifacts(new HashSet<Artifact>());
+ super.setExtensionArtifacts(new HashSet<Artifact>());
+ super.setRemoteArtifactRepositories(new LinkedList<ArtifactRepository>());
+ super.setPluginArtifactRepositories(new LinkedList<ArtifactRepository>());
+ super.setCollectedProjects(new LinkedList<MavenProject>());
+ super.setActiveProfiles(new LinkedList<Profile>());
+ super.setOriginalModel(null);
+ super.setExecutionProject(this);
+ super.setArtifact(artifact);
}
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBuildStub.java b/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBuildStub.java
index 3339fbe..19d1e49 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBuildStub.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBuildStub.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.stub;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugin.resources.remote.stub;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.stub;
import java.io.File;
import java.io.FileOutputStream;
@@ -32,9 +31,7 @@ import org.codehaus.plexus.util.FileUtils;
/**
* Stub
*/
-public class MavenProjectBuildStub
- extends MavenProjectBasicStub
-{
+public class MavenProjectBuildStub extends MavenProjectBasicStub {
public static final int RESOURCES_FILE = 1;
public static final int ROOT_FILE = 2;
@@ -75,10 +72,8 @@ public class MavenProjectBuildStub
protected HashMap<String, String> dataMap;
- public MavenProjectBuildStub( String key )
- throws Exception
- {
- super( key );
+ public MavenProjectBuildStub(String key) throws Exception {
+ super(key);
build = new Build();
resourcesFileList = new ArrayList<>();
@@ -90,61 +85,50 @@ public class MavenProjectBuildStub
setupBuild();
}
- public void addDirectory( String name )
- {
- if ( isValidPath( name ) )
- {
- directoryList.add( name );
+ public void addDirectory(String name) {
+ if (isValidPath(name)) {
+ directoryList.add(name);
}
}
- public void setOutputDirectory( String dir )
- {
+ public void setOutputDirectory(String dir) {
outputDirectory = buildDirectory + "/" + dir;
- build.setOutputDirectory( outputDirectory );
+ build.setOutputDirectory(outputDirectory);
}
- public void addFile( String name, int type )
- {
- if ( isValidPath( name ) )
- {
- List<String> list = getList( type );
+ public void addFile(String name, int type) {
+ if (isValidPath(name)) {
+ List<String> list = getList(type);
- list.add( name );
+ list.add(name);
}
}
- public void addFile( String name, String data, int type )
- {
- File fileName = new File( name );
+ public void addFile(String name, String data, int type) {
+ File fileName = new File(name);
- addFile( name, type );
- dataMap.put( fileName.getName(), data );
+ addFile(name, type);
+ dataMap.put(fileName.getName(), data);
}
- public String getOutputDirectory()
- {
+ public String getOutputDirectory() {
return outputDirectory;
}
- public String getTestOutputDirectory()
- {
+ public String getTestOutputDirectory() {
return testOutputDirectory;
}
- public String getResourcesDirectory()
- {
+ public String getResourcesDirectory() {
return resourcesDirectory;
}
- public String getTestResourcesDirectory()
- {
+ public String getTestResourcesDirectory() {
return testResourcesDirectory;
}
@Override
- public Build getBuild()
- {
+ public Build getBuild() {
return build;
}
@@ -157,20 +141,17 @@ public class MavenProjectBuildStub
* @param path
* @return
*/
- private boolean isValidPath( String path )
- {
+ private boolean isValidPath(String path) {
boolean bRetVal = true;
- if ( path.startsWith( "c:" ) || path.startsWith( ".." ) || path.startsWith( "/" ) || path.startsWith( "\\" ) )
- {
+ if (path.startsWith("c:") || path.startsWith("..") || path.startsWith("/") || path.startsWith("\\")) {
bRetVal = false;
}
return bRetVal;
}
- private void setupBuild()
- {
+ private void setupBuild() {
// check getBasedir method for the exact path
// we need to recreate the dir structure in
// an isolated environment
@@ -181,84 +162,72 @@ public class MavenProjectBuildStub
resourcesDirectory = srcDirectory + "/main/resources/";
testResourcesDirectory = srcDirectory + "/test/resources/";
- build.setDirectory( buildDirectory );
- build.setOutputDirectory( outputDirectory );
- build.setTestOutputDirectory( testOutputDirectory );
+ build.setDirectory(buildDirectory);
+ build.setOutputDirectory(outputDirectory);
+ build.setTestOutputDirectory(testOutputDirectory);
}
- public void setupBuildEnvironment()
- throws Exception
- {
+ public void setupBuildEnvironment() throws Exception {
// populate dummy resources and dummy test resources
// setup src dir
- if ( !FileUtils.fileExists( resourcesDirectory ) )
- {
- FileUtils.mkdir( resourcesDirectory );
+ if (!FileUtils.fileExists(resourcesDirectory)) {
+ FileUtils.mkdir(resourcesDirectory);
}
- if ( !FileUtils.fileExists( testResourcesDirectory ) )
- {
- FileUtils.mkdir( testResourcesDirectory );
+ if (!FileUtils.fileExists(testResourcesDirectory)) {
+ FileUtils.mkdir(testResourcesDirectory);
}
- createDirectories( resourcesDirectory, testResourcesDirectory );
- createFiles( resourcesDirectory, testResourcesDirectory );
+ createDirectories(resourcesDirectory, testResourcesDirectory);
+ createFiles(resourcesDirectory, testResourcesDirectory);
setupRootFiles();
// setup target dir
- if ( !FileUtils.fileExists( outputDirectory ) )
- {
- FileUtils.mkdir( outputDirectory );
+ if (!FileUtils.fileExists(outputDirectory)) {
+ FileUtils.mkdir(outputDirectory);
}
- if ( !FileUtils.fileExists( testOutputDirectory ) )
- {
- FileUtils.mkdir( testOutputDirectory );
+ if (!FileUtils.fileExists(testOutputDirectory)) {
+ FileUtils.mkdir(testOutputDirectory);
}
setupTargetFiles();
}
- private void createDirectories( String parent, String testparent )
- {
+ private void createDirectories(String parent, String testparent) {
File currentDirectory;
- for ( String aDirectoryList : directoryList )
- {
- currentDirectory = new File( parent, "/" + aDirectoryList );
+ for (String aDirectoryList : directoryList) {
+ currentDirectory = new File(parent, "/" + aDirectoryList);
- if ( !currentDirectory.exists() )
- {
+ if (!currentDirectory.exists()) {
currentDirectory.mkdirs();
}
// duplicate dir structure in test resources
- currentDirectory = new File( testparent, "/" + aDirectoryList );
+ currentDirectory = new File(testparent, "/" + aDirectoryList);
- if ( !currentDirectory.exists() )
- {
+ if (!currentDirectory.exists()) {
currentDirectory.mkdirs();
}
}
}
- private List<String> getList( int type )
- {
+ private List<String> getList(int type) {
ArrayList<String> retVal = null;
- switch ( type )
- {
- case SOURCE_FILE :
+ switch (type) {
+ case SOURCE_FILE:
retVal = sourceFileList;
break;
- case OUTPUT_FILE :
+ case OUTPUT_FILE:
retVal = targetClassesList;
break;
- case RESOURCES_FILE :
+ case RESOURCES_FILE:
retVal = resourcesFileList;
break;
- case ROOT_FILE :
+ case ROOT_FILE:
retVal = rootFileList;
break;
}
@@ -266,75 +235,59 @@ public class MavenProjectBuildStub
return retVal;
}
- private void createFiles( String parent, int type )
- {
+ private void createFiles(String parent, int type) {
File currentFile;
- List<String> list = getList( type );
+ List<String> list = getList(type);
// guard
- if ( list == null )
- {
+ if (list == null) {
return;
}
- for ( String aList : list )
- {
- currentFile = new File( parent, aList );
+ for (String aList : list) {
+ currentFile = new File(parent, aList);
// create the necessary parent directories
// before we create the files
- if ( !currentFile.getParentFile().exists() )
- {
+ if (!currentFile.getParentFile().exists()) {
currentFile.getParentFile().mkdirs();
}
- if ( !currentFile.exists() )
- {
- try
- {
+ if (!currentFile.exists()) {
+ try {
currentFile.createNewFile();
- populateFile( currentFile, RESOURCES_FILE );
- }
- catch ( IOException io )
- {
+ populateFile(currentFile, RESOURCES_FILE);
+ } catch (IOException io) {
// TODO: handle exception
}
}
}
}
- private void setupRootFiles()
- {
- createFiles( testRootDir, ROOT_FILE );
+ private void setupRootFiles() {
+ createFiles(testRootDir, ROOT_FILE);
}
- private void setupTargetFiles()
- {
- createFiles( getOutputDirectory(), OUTPUT_FILE );
+ private void setupTargetFiles() {
+ createFiles(getOutputDirectory(), OUTPUT_FILE);
}
- private void createFiles( String parent, String testparent )
- {
- createFiles( parent, RESOURCES_FILE );
- createFiles( testparent, RESOURCES_FILE );
+ private void createFiles(String parent, String testparent) {
+ createFiles(parent, RESOURCES_FILE);
+ createFiles(testparent, RESOURCES_FILE);
}
- private void populateFile( File file, int type )
- {
+ private void populateFile(File file, int type) {
FileOutputStream outputStream;
- String data = dataMap.get( file.getName() );
-
- if ( ( data != null ) && file.exists() )
- {
- try
- {
- outputStream = new FileOutputStream( file );
- outputStream.write( data.getBytes() );
+ String data = dataMap.get(file.getName());
+
+ if ((data != null) && file.exists()) {
+ try {
+ outputStream = new FileOutputStream(file);
+ outputStream.write(data.getBytes());
outputStream.flush();
outputStream.close();
- }
- catch ( IOException ex )
- {
+ } catch (IOException ex) {
// TODO: handle exception here
}
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectResourcesStub.java b/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectResourcesStub.java
index 905fa33..5b1234f 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectResourcesStub.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectResourcesStub.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.stub;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,98 +16,82 @@ package org.apache.maven.plugin.resources.remote.stub;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.stub;
import org.apache.maven.model.Resource;
-
/**
* Stub
*/
-public class MavenProjectResourcesStub
- extends MavenProjectBuildStub
-{
-
- public MavenProjectResourcesStub( String id )
- throws Exception
- {
- super( id );
+public class MavenProjectResourcesStub extends MavenProjectBuildStub {
+
+ public MavenProjectResourcesStub(String id) throws Exception {
+ super(id);
setupResources();
setupTestResources();
}
- public void addInclude( String pattern )
- {
- build.getResources().get( 0 ).addInclude(pattern);
+ public void addInclude(String pattern) {
+ build.getResources().get(0).addInclude(pattern);
}
- public void addExclude( String pattern )
- {
- build.getResources().get( 0 ).addExclude(pattern);
+ public void addExclude(String pattern) {
+ build.getResources().get(0).addExclude(pattern);
}
- public void addTestInclude( String pattern )
- {
- build.getTestResources().get( 0 ).addInclude(pattern);
+ public void addTestInclude(String pattern) {
+ build.getTestResources().get(0).addInclude(pattern);
}
- public void addTestExclude( String pattern )
- {
- build.getTestResources().get( 0 ).addExclude(pattern);
+ public void addTestExclude(String pattern) {
+ build.getTestResources().get(0).addExclude(pattern);
}
- public void setTargetPath( String path )
- {
- build.getResources().get( 0 ).setTargetPath(path);
+ public void setTargetPath(String path) {
+ build.getResources().get(0).setTargetPath(path);
}
- public void setTestTargetPath( String path )
- {
- build.getTestResources().get( 0 ).setTargetPath(path);
+ public void setTestTargetPath(String path) {
+ build.getTestResources().get(0).setTargetPath(path);
}
- public void setDirectory( String dir )
- {
- build.getResources().get( 0 ).setDirectory(dir);
+ public void setDirectory(String dir) {
+ build.getResources().get(0).setDirectory(dir);
}
- public void setTestDirectory( String dir )
- {
- build.getTestResources().get( 0 ).setDirectory(dir);
+ public void setTestDirectory(String dir) {
+ build.getTestResources().get(0).setDirectory(dir);
}
- public void setResourceFiltering( int nIndex, boolean filter )
- {
- if ( build.getResources().size() > nIndex )
- {
- build.getResources().get( nIndex ).setFiltering(filter);
+ public void setResourceFiltering(int nIndex, boolean filter) {
+ if (build.getResources().size() > nIndex) {
+ build.getResources().get(nIndex).setFiltering(filter);
}
}
- private void setupResources()
- {
+ private void setupResources() {
Resource resource = new Resource();
// see MavenProjectBasicStub for details
// of getBasedir
// setup default resources
- resource.setDirectory( getBasedir().getPath() + "/src/main/resources" );
- resource.setFiltering( false );
- resource.setTargetPath( null );
- build.addResource( resource );
+ resource.setDirectory(getBasedir().getPath() + "/src/main/resources");
+ resource.setFiltering(false);
+ resource.setTargetPath(null);
+ build.addResource(resource);
}
- private void setupTestResources()
- {
+ private void setupTestResources() {
Resource resource = new Resource();
// see MavenProjectBasicStub for details
// of getBasedir
// setup default test resources
- resource.setDirectory( getBasedir().getPath() + "/src/test/resources" );
- resource.setFiltering( false );
- resource.setTargetPath( null );
- build.addTestResource( resource );
+ resource.setDirectory(getBasedir().getPath() + "/src/test/resources");
+ resource.setFiltering(false);
+ resource.setTargetPath(null);
+ build.addTestResource(resource);
}
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/stub/ModelStub.java b/src/test/java/org/apache/maven/plugin/resources/remote/stub/ModelStub.java
index 3f64098..e0d090e 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/stub/ModelStub.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/stub/ModelStub.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugin.resources.remote.stub;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugin.resources.remote.stub;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.resources.remote.stub;
import java.util.Properties;
@@ -27,63 +26,49 @@ import org.apache.maven.model.Parent;
/**
* Stub
*/
-public class ModelStub
- extends Model
-{
+public class ModelStub extends Model {
private static final long serialVersionUID = 1L;
- public ModelStub()
- {
-
- }
+ public ModelStub() {}
@Override
- public String getVersion()
- {
+ public String getVersion() {
return "0.0-TEST";
}
@Override
- public String getModelVersion()
- {
+ public String getModelVersion() {
return "0.0-TEST";
}
@Override
- public String getName()
- {
+ public String getName() {
return "Test Model";
}
@Override
- public String getGroupId()
- {
+ public String getGroupId() {
return "org.apache.maven.test";
}
@Override
- public String getPackaging()
- {
+ public String getPackaging() {
return "jar";
}
@Override
- public Parent getParent()
- {
- //return new Parent();
+ public Parent getParent() {
+ // return new Parent();
return null;
}
@Override
- public String getArtifactId()
- {
+ public String getArtifactId() {
return "maven-test-plugin";
}
@Override
- public Properties getProperties()
- {
+ public Properties getProperties() {
return new Properties();
}
-
}