You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2018/03/07 22:50:16 UTC
[maven-ear-plugin] 01/01: o Removed unused parts. o Removed
ModuleIdentifierValidator including the test cause it's not needed anymore.
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a commit to branch CODE-CLEANUP
in repository https://gitbox.apache.org/repos/asf/maven-ear-plugin.git
commit cab3dfaf147d78563b484a1c8fac1066dfaaaa71
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Wed Mar 7 20:14:41 2018 +0100
o Removed unused parts.
o Removed ModuleIdentifierValidator including the test cause it's not needed
anymore.
---
.../maven/plugins/ear/AbstractEarModule.java | 1 -
.../apache/maven/plugins/ear/AbstractEarMojo.java | 13 +-
.../java/org/apache/maven/plugins/ear/EarMojo.java | 13 +-
.../ear/util/ModuleIdentifierValidator.java | 139 --------------
.../ear/util/ModuleIdentifierValidatorTest.java | 211 ---------------------
5 files changed, 4 insertions(+), 373 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/ear/AbstractEarModule.java b/src/main/java/org/apache/maven/plugins/ear/AbstractEarModule.java
index 34cda4c..8ceb14b 100644
--- a/src/main/java/org/apache/maven/plugins/ear/AbstractEarModule.java
+++ b/src/main/java/org/apache/maven/plugins/ear/AbstractEarModule.java
@@ -250,7 +250,6 @@ public abstract class AbstractEarModule
try
{
String outputFileNameMapping = earExecutionContext.getOutputFileNameMapping();
- System.out.println( "*** outputFileNameMapping:" + outputFileNameMapping );
bundleFileName = MappingUtils.evaluateFileNameMapping( outputFileNameMapping, artifact );
}
catch ( InterpolationException e )
diff --git a/src/main/java/org/apache/maven/plugins/ear/AbstractEarMojo.java b/src/main/java/org/apache/maven/plugins/ear/AbstractEarMojo.java
index bc258db..f8285d9 100644
--- a/src/main/java/org/apache/maven/plugins/ear/AbstractEarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/ear/AbstractEarMojo.java
@@ -29,12 +29,10 @@ import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.ear.util.ArtifactTypeMappingService;
import org.apache.maven.plugins.ear.util.JavaEEVersion;
import org.apache.maven.project.MavenProject;
-import org.apache.maven.shared.filtering.MavenResourcesFiltering;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
@@ -129,11 +127,9 @@ public abstract class AbstractEarMojo
// CHECKSTYLE_ON: LineLength
/**
- * When using a {@link #fileNameMapping} with versions, either use the {@code baseVersion} or the {@code version}.
- * When the artifact is a SNAPSHOT, {@code version} will always return a value with a {@code -SNAPSHOT} postfix
- * instead of the possible timestamped value.
- *
- * @since 2.9 FIXME: Check what exactly this means!!!
+ * When using a {@link #outputFileNameMapping} with versions, either use the {@code baseVersion} or the
+ * {@code version}. When the artifact is a SNAPSHOT, {@code version} will always return a value with a
+ * {@code -SNAPSHOT} postfix instead of the possible timestamped value.
*/
@Parameter
private Boolean useBaseVersion;
@@ -167,9 +163,6 @@ public abstract class AbstractEarMojo
@Parameter( defaultValue = "${project.build.directory}", required = true )
private File tempFolder;
- @Component
- private MavenResourcesFiltering mavenResourcesFiltering;
-
private List<EarModule> earModules;
private List<JarModule> allJarModules;
diff --git a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
index b671adf..df089bd 100644
--- a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
@@ -258,16 +258,6 @@ public class EarMojo
@Parameter( defaultValue = "true" )
private boolean useJvmChmod = true;
- /**
- * The list of artifacts is checked and if you set this to {@code true} the build will fail if duplicate artifacts
- * have been found within the build configuration.
- *
- * @since 2.10
- */
- // TODO: This can be removed if we change to full unique identifiers in EAR (next major version!)
- @Parameter( defaultValue = "false", property = "maven.ear.duplicateArtifactsBreakTheBuild" )
- private boolean duplicateArtifactsBreakTheBuild;
-
/** {@inheritDoc} */
public void execute()
throws MojoExecutionException, MojoFailureException
@@ -741,7 +731,7 @@ public class EarMojo
if ( module.getLibDir() != null )
{
// MEAR-189:
- // We use the original name, cause in case of fileNameMapping to no-version/full
+ // We use the original name, cause in case of outputFileNameMapping
// we could not not delete it and it will end up in the resulting EAR and the WAR
// will not be cleaned up.
// CHECKSTYLE_OFF: LineLength
@@ -753,7 +743,6 @@ public class EarMojo
// If WAR contains files with timestamps, but EAR strips them away (useBaseVersion=true)
// the artifact is not found. Therefore respect the current fileNameMapping additionally.
- // FIXME: Need to check this based on the new name mapping.!
if ( !artifact.exists() )
{
getLog().debug( "module does not exist with original file name." );
diff --git a/src/main/java/org/apache/maven/plugins/ear/util/ModuleIdentifierValidator.java b/src/main/java/org/apache/maven/plugins/ear/util/ModuleIdentifierValidator.java
deleted file mode 100644
index b2c7f21..0000000
--- a/src/main/java/org/apache/maven/plugins/ear/util/ModuleIdentifierValidator.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.apache.maven.plugins.ear.util;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.plugins.ear.EarModule;
-
-/**
- * This class will check the list of modules if there exist a duplicate artifactId. If we have such case it's necessary
- * to create a warning to the user otherwise it can happen to overwrite existing artifacts during the EAR creation
- * process. This is a temporary solution to keep backward compatibility with previous versions. For the next major
- * release 3.X the creation of the EAR archive should be done based on unique identifiers like
- * {@code groupId:artifactId:version}.
- *
- * @author Karl Heinz Marbaise <kh...@apache.org>
- */
-public class ModuleIdentifierValidator
-{
-
- private List<EarModule> earModules;
-
- private Map<String, List<EarModule>> result;
-
- /**
- * @param earModules The list of {@link EarModule} which will be checked.
- */
- public ModuleIdentifierValidator( List<EarModule> earModules )
- {
- if ( earModules == null )
- {
- throw new IllegalArgumentException( "Not allowed to give null for earModules." );
- }
- this.earModules = earModules;
- this.result = new HashMap<String, List<EarModule>>();
- }
-
- /**
- * You have to call {@link #checkForDuplicateArtifacts()} before
- * otherwise you will get always {@code false}.
- * @return true in case of existing duplicates false otherwise.
- */
- public boolean existDuplicateArtifacts()
- {
- return !result.isEmpty();
- }
-
- /**
- * Trigger the module list check.
- *
- * @return this for fluent usage.
- */
- public ModuleIdentifierValidator checkForDuplicateArtifacts()
- {
- analyze();
- return this;
- }
-
- private void analyze()
- {
- final Map<String, List<EarModule>> newList = new HashMap<String, List<EarModule>>();
-
- for ( EarModule earModule : earModules )
- {
- String earId = earModule.getArtifact().getArtifactId() + ":" + earModule.getArtifact().getVersion();
-
- if ( newList.containsKey( earId ) )
- {
- newList.get( earId ).add( earModule );
- }
- else
- {
- List<EarModule> list = new ArrayList<EarModule>();
- list.add( earModule );
- newList.put( earId, list );
- }
- }
-
- result.clear();
- for ( Map.Entry<String, List<EarModule>> item : newList.entrySet() )
- {
- if ( item.getValue().size() > 1 )
- {
- result.put( item.getKey(), item.getValue() );
- }
- }
-
- }
-
- /**
- * @return A map of duplicate artifacts.
- */
- public Map<String, List<EarModule>> getDuplicateArtifacts()
- {
- return result;
- }
-
- /**
- * @return The list of {@link EarModule}
- */
- public List<EarModule> getEarModules()
- {
- return earModules;
- }
-
- /**
- * @param paramEarModules {@link EarModule}
- * @return {@link ModuleIdentifierValidator}
- */
- public ModuleIdentifierValidator setEarModules( List<EarModule> paramEarModules )
- {
- if ( paramEarModules == null )
- {
- throw new IllegalArgumentException( "Not allowed to give null for earModules." );
- }
- this.earModules = paramEarModules;
- return this;
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/maven/plugins/ear/util/ModuleIdentifierValidatorTest.java b/src/test/java/org/apache/maven/plugins/ear/util/ModuleIdentifierValidatorTest.java
deleted file mode 100644
index 62de40c..0000000
--- a/src/test/java/org/apache/maven/plugins/ear/util/ModuleIdentifierValidatorTest.java
+++ /dev/null
@@ -1,211 +0,0 @@
-package org.apache.maven.plugins.ear.util;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugins.ear.EarModule;
-import org.apache.maven.plugins.ear.util.ModuleIdentifierValidator;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ModuleIdentifierValidatorTest
-{
- private List<EarModule> earModules;
-
- private ModuleIdentifierValidator miv;
-
- @Before
- public void before()
- {
- this.earModules = new ArrayList<EarModule>();
- this.miv = new ModuleIdentifierValidator( this.earModules );
- }
-
- private EarModule createMockEarModule( String groupId, String artifactId, String version )
- {
- EarModule earModule = mock( EarModule.class );
- Artifact artifact = mock( Artifact.class );
- when( earModule.getArtifact() ).thenReturn( artifact );
- when( earModule.getArtifact().getGroupId() ).thenReturn( groupId );
- when( earModule.getArtifact().getArtifactId() ).thenReturn( artifactId );
- when( earModule.getArtifact().getVersion() ).thenReturn( version );
- when( earModule.getArtifact().getId() ).thenReturn( groupId + ":" + artifactId + ":" + version );
- return earModule;
- }
-
- private EarModule createMockEarModule( String groupId, String artifactId, String classifier, String version )
- {
- EarModule earModule = mock( EarModule.class );
- Artifact artifact = mock( Artifact.class );
- when( earModule.getArtifact() ).thenReturn( artifact );
- when( earModule.getArtifact().getGroupId() ).thenReturn( groupId );
- when( earModule.getArtifact().getArtifactId() ).thenReturn( artifactId );
- when( earModule.getArtifact().getClassifier() ).thenReturn( classifier );
- when( earModule.getArtifact().getVersion() ).thenReturn( version );
- when( earModule.getArtifact().getId() ).thenReturn( groupId + ":" + artifactId + ":" + classifier + ":" + version );
- return earModule;
- }
-
- @Test
- public void existDuplicateShouldResultFalseWithEmptyList()
- {
- miv.checkForDuplicateArtifacts();
-
- assertFalse( miv.existDuplicateArtifacts() );
- }
-
- @Test
- public void shouldNotFailCauseTheArtifactIdsAreDifferentWithSameGroupId()
- {
- earModules.add( createMockEarModule( "org.apache.maven.test", "result-artifact", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven.test", "result-artifact-a", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven.test", "result-artifact-b", "1.0.0" ) );
-
- assertFalse( miv.checkForDuplicateArtifacts().existDuplicateArtifacts() );
-
- Map<String, List<EarModule>> result = miv.getDuplicateArtifacts();
-
- assertTrue( result.isEmpty() );
- }
-
- @Test
- public void shouldNotFailCauseTheArtifactIdsAreDifferent()
- {
- earModules.add( createMockEarModule( "org.apache", "artifact-1", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache", "artifact-2", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven", "aid-1", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven", "aid-2", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven.test", "result-artifact-a", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven.test", "result-artifact-b", "1.0.0" ) );
-
- assertFalse( miv.checkForDuplicateArtifacts().existDuplicateArtifacts() );
-
- Map<String, List<EarModule>> result = miv.getDuplicateArtifacts();
-
- assertTrue( result.isEmpty() );
- }
-
- @Test
- public void shouldNotFailCauseTheClassifiersAreDifferent()
- {
- earModules.add( createMockEarModule( "org.apache", "artifact-1", "first", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache", "artifact-2", "second", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven", "aid-1", "first", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven", "aid-2", "second", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven.test", "result-artifact-a", "first", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven.test", "result-artifact-b", "second", "1.0.0" ) );
-
- assertFalse( miv.checkForDuplicateArtifacts().existDuplicateArtifacts() );
-
- Map<String, List<EarModule>> result = miv.getDuplicateArtifacts();
-
- assertTrue( result.isEmpty() );
- }
-
- @Test
- public void shouldFailCauseTheArtifactIdsAreIdenticalWithDifferentGroupIds()
- {
- EarModule earModule1 = createMockEarModule( "org.apache.maven.test", "result-artifact", "1.0.0" );
- EarModule earModule2 = createMockEarModule( "org.apache.maven", "result-artifact", "1.0.0" );
- earModules.add( earModule1 );
- earModules.add( earModule2 );
-
- miv.checkForDuplicateArtifacts();
- Map<String, List<EarModule>> result = miv.getDuplicateArtifacts();
-
- assertFalse( result.isEmpty() );
- assertEquals( 1, result.size() );
- assertTrue( result.containsKey( "result-artifact:1.0.0" ) );
- assertEquals( 2, result.get( "result-artifact:1.0.0" ).size() );
- }
-
- @Test
- public void shouldFailCauseTheArtifactIdsAreIdenticalWithClassifiers()
- {
- EarModule earModule1 = createMockEarModule( "org.apache.maven.test", "result-artifact", "first", "1.0.0" );
- EarModule earModule2 = createMockEarModule( "org.apache.maven", "result-artifact", "second", "1.0.0" );
- earModules.add( earModule1 );
- earModules.add( earModule2 );
-
- miv.checkForDuplicateArtifacts();
- Map<String, List<EarModule>> result = miv.getDuplicateArtifacts();
-
- assertFalse( result.isEmpty() );
- assertEquals( 1, result.size() );
- assertTrue( result.containsKey( "result-artifact:1.0.0" ) );
- assertEquals( 2, result.get( "result-artifact:1.0.0" ).size() );
- }
-
- @Test
- public void shouldFailCauseTheArtifactIdsAreIdentical()
- {
- earModules.add( createMockEarModule( "org.apache", "artifact-1", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache", "artifact-2", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven", "aid-1", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven", "artifact-2", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven.test", "result-artifact-a", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven.test", "result-artifact-b", "1.0.0" ) );
-
- miv.checkForDuplicateArtifacts();
- Map<String, List<EarModule>> result = miv.getDuplicateArtifacts();
-
- assertFalse( result.isEmpty() );
- }
-
- @Test
- public void shouldFailWithAppropriateInformationAboutTheIdenticalArtifactIds()
- {
- EarModule earModule_1 = createMockEarModule( "org.apache", "artifact-2", "1.0.0" );
- EarModule earModule_2 = createMockEarModule( "org.apache.maven", "artifact-2", "1.0.0" );
-
- earModules.add( createMockEarModule( "org.apache", "artifact-1", "1.0.0" ) );
- earModules.add( earModule_1 );
- earModules.add( createMockEarModule( "org.apache.maven", "aid-1", "1.0.0" ) );
- earModules.add( earModule_2 );
- earModules.add( createMockEarModule( "org.apache.maven.test", "result-artifact-a", "1.0.0" ) );
- earModules.add( createMockEarModule( "org.apache.maven.test", "result-artifact-b", "1.0.0" ) );
-
- miv.checkForDuplicateArtifacts();
- Map<String, List<EarModule>> result = miv.getDuplicateArtifacts();
-
- assertFalse( result.isEmpty() );
- assertEquals( 1, result.size() );
-
- assertTrue( result.containsKey( "artifact-2:1.0.0" ) );
-
- List<EarModule> list = result.get( "artifact-2:1.0.0" );
-
- assertEquals( 2, list.size() );
- assertTrue( list.contains( earModule_1 ) );
- assertTrue( list.contains( earModule_2 ) );
-
- }
-
-}
--
To stop receiving notification emails like this one, please contact
khmarbaise@apache.org.