From 96e11e1c84c0dbc9bdd578df2d8315d3db7c6219 Mon Sep 17 00:00:00 2001 From: thelproad Date: Sat, 17 Aug 2019 17:04:15 +0800 Subject: [PATCH] [MNG-6855] Remove redundant code Closes #280 --- .../repository/metadata/AbstractRepositoryMetadata.java | 3 +-- .../apache/maven/classrealm/DefaultClassRealmManager.java | 5 ++--- .../maven/lifecycle/internal/MojoDescriptorCreator.java | 2 +- .../src/main/java/org/apache/maven/cli/MavenCli.java | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java index 46c41b94e7..196b4b7d60 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java @@ -123,8 +123,7 @@ public abstract class AbstractRepositoryMetadata // beware meta-versions! String version = metadata.getVersion(); - if ( version != null && ( Artifact.LATEST_VERSION.equals( version ) || Artifact.RELEASE_VERSION.equals( - version ) ) ) + if ( Artifact.LATEST_VERSION.equals( version ) || Artifact.RELEASE_VERSION.equals( version ) ) { // meta-versions are not valid values...don't write them. metadata.setVersion( null ); diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java index a4835fdd47..cf3d746f88 100644 --- a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java +++ b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java @@ -243,12 +243,11 @@ public class DefaultClassRealmManager { Objects.requireNonNull( plugin, "plugin cannot be null" ); - ClassLoader parent = PARENT_CLASSLOADER; - Map foreignImports = Collections.singletonMap( "", getMavenApiRealm() ); - return createRealm( getKey( plugin, true ), RealmType.Extension, parent, null, foreignImports, artifacts ); + return createRealm( getKey( plugin, true ), RealmType.Extension, PARENT_CLASSLOADER, null, + foreignImports, artifacts ); } private boolean isProvidedArtifact( Artifact artifact ) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java index edb8dceda0..4bafa30c69 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java @@ -190,7 +190,7 @@ public class MojoDescriptorCreator plugin.setArtifactId( tok.nextToken() ); goal = tok.nextToken(); } - else if ( numTokens <= 2 ) + else { // We have a prefix and goal // diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index 5ca060206c..79e1ffeac7 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -337,7 +337,7 @@ public class MavenCli "-D%s system property is not set.", MULTIMODULE_PROJECT_DIRECTORY ); throw new ExitException( 1 ); } - File basedir = basedirProperty != null ? new File( basedirProperty ) : new File( "" ); + File basedir = new File( basedirProperty ); try { cliRequest.multiModuleProjectDirectory = basedir.getCanonicalFile(); @@ -764,7 +764,7 @@ public class MavenCli MavenExecutionRequest request = DefaultMavenExecutionRequest.copy( cliRequest.request ); - request = populateRequest( cliRequest, request ); + populateRequest( cliRequest, request ); request = executionRequestPopulator.populateDefaults( request );