You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2019/05/25 11:14:02 UTC
[maven] branch MNG-6633 updated (7a227b0 -> 790dc0f)
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a change to branch MNG-6633
in repository https://gitbox.apache.org/repos/asf/maven.git.
discard 7a227b0 [MNG-6633] - Reduce memory usage of excludes
new 790dc0f [MNG-6633] - Reduce memory usage of excludes
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (7a227b0)
\
N -- N -- N refs/heads/MNG-6633 (790dc0f)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 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.
Summary of changes:
.../repository/legacy/LegacyRepositorySystem.java | 18 +++--
.../resolver/filter/ExcludesArtifactFilter.java | 23 +-----
.../resolver/filter/ExclusionArtifactFilter.java | 30 ++++++++
.../resolver/filter/IncludesArtifactFilter.java | 45 ++++++------
.../artifact/resolver/filter/ModuleIdentifier.java | 81 ----------------------
.../apache/maven/bridge/MavenRepositorySystem.java | 4 +-
.../project/artifact/MavenMetadataSource.java | 4 +-
7 files changed, 72 insertions(+), 133 deletions(-)
create mode 100644 maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilter.java
delete mode 100644 maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ModuleIdentifier.java
[maven] 01/01: [MNG-6633] - Reduce memory usage of excludes
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch MNG-6633
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 790dc0f2b73c07a478802cbd0183fc8bd2f3fe78
Author: Stefan Oehme <st...@gmail.com>
AuthorDate: Mon Apr 29 15:31:34 2019 +0200
[MNG-6633] - Reduce memory usage of excludes
ExcludesArtifactFilter was highly inefficient.
It took the group and artifact ID of an Exclusion, concatenated them into
a new String, which was kept in memory for the whole duration
of the build and then compared that String against the concatenation
of group and artifact ID of each incoming artifact, adding more
CPU cycles than necessary.
Instead we now just wrap the existing Exclusion object and check its
groupId and artifactId against the artifact to tell whether it should
be excluded.
The old class is kept around for binary compatibility, but is now unused.
Closes #243
---
.../resolver/filter/ExclusionArtifactFilter.java | 30 ++++++++++++++++++++++
.../apache/maven/bridge/MavenRepositorySystem.java | 12 ++-------
.../project/artifact/MavenMetadataSource.java | 12 ++-------
3 files changed, 34 insertions(+), 20 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilter.java b/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilter.java
new file mode 100644
index 0000000..b51350d
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilter.java
@@ -0,0 +1,30 @@
+package org.apache.maven.artifact.resolver.filter;
+
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Exclusion;
+
+public class ExclusionArtifactFilter implements ArtifactFilter
+{
+ private final List<Exclusion> exclusions;
+
+ public ExclusionArtifactFilter( List<Exclusion> exclusions )
+ {
+ this.exclusions = exclusions;
+ }
+
+ @Override
+ public boolean include( Artifact artifact )
+ {
+ for ( Exclusion exclusion : exclusions )
+ {
+ if ( exclusion.getGroupId().equals( artifact.getGroupId() )
+ && exclusion.getArtifactId().equals( artifact.getArtifactId() ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
index 8558ae4..730b428 100644
--- a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
+++ b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
@@ -44,12 +44,11 @@ import org.apache.maven.artifact.repository.MavenArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout2;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
-import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ExclusionArtifactFilter;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Plugin;
import org.apache.maven.repository.Proxy;
import org.apache.maven.repository.RepositorySystem;
@@ -116,14 +115,7 @@ public class MavenRepositorySystem
if ( !d.getExclusions().isEmpty() )
{
- List<String> exclusions = new ArrayList<>();
-
- for ( Exclusion exclusion : d.getExclusions() )
- {
- exclusions.add( exclusion.getGroupId() + ':' + exclusion.getArtifactId() );
- }
-
- artifact.setDependencyFilter( new ExcludesArtifactFilter( exclusions ) );
+ artifact.setDependencyFilter( new ExclusionArtifactFilter( d.getExclusions() ) );
}
return artifact;
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
index 2dc9372..d002f17 100644
--- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
@@ -47,7 +47,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException;
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ExclusionArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
@@ -55,7 +55,6 @@ import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.DistributionManagement;
-import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Relocation;
import org.apache.maven.model.building.ModelBuildingException;
import org.apache.maven.model.building.ModelBuildingRequest;
@@ -394,14 +393,7 @@ public class MavenMetadataSource
if ( !dependency.getExclusions().isEmpty() )
{
- List<String> exclusions = new ArrayList<>();
-
- for ( Exclusion e : dependency.getExclusions() )
- {
- exclusions.add( e.getGroupId() + ':' + e.getArtifactId() );
- }
-
- effectiveFilter = new ExcludesArtifactFilter( exclusions );
+ effectiveFilter = new ExclusionArtifactFilter( dependency.getExclusions() );
if ( inheritedFilter != null )
{