[maven-bundle-plugin] 02/02: Adopt a patch from Fedora to fix the compatibility of maven-dependency-tree 3.x

Kai-Chung Yan seamlik-guest at moszumanska.debian.org
Tue Mar 20 15:16:17 GMT 2018


This is an automated email from the git hooks/post-receive script.

seamlik-guest pushed a commit to branch master
in repository maven-bundle-plugin.

commit 529924b1ba341ce78525a8d6b6e92a27edd93dc0
Author: 殷啟聰 | Kai-Chung Yan <seamlikok at gmail.com>
Date:   Tue Mar 20 23:15:54 2018 +0800

    Adopt a patch from Fedora to fix the compatibility of maven-dependency-tree 3.x
---
 debian/copyright                                   |  23 ++
 ...001-Port-to-current-maven-dependency-tree.patch | 253 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 3 files changed, 277 insertions(+)

diff --git a/debian/copyright b/debian/copyright
index 89ef7c2..c9bb289 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -12,6 +12,10 @@ Files: debian/*
 Copyright: 2011, Damien Raude-Morvan <drazzib at debian.org>
 License: Apache-2.0
 
+Files: debian/patches/0001-Port-to-current-maven-dependency-tree.patch
+Copyright: 2016, Michael Simacek
+License: MIT
+
 License: Apache-2.0
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
@@ -27,3 +31,22 @@ License: Apache-2.0
  .
  On Debian GNU/Linux system you can find the complete text of the
  Apache-2.0 license in '/usr/share/common-licenses/Apache-2.0'.
+
+License: MIT
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ .
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
\ No newline at end of file
diff --git a/debian/patches/0001-Port-to-current-maven-dependency-tree.patch b/debian/patches/0001-Port-to-current-maven-dependency-tree.patch
new file mode 100644
index 0000000..d989f8b
--- /dev/null
+++ b/debian/patches/0001-Port-to-current-maven-dependency-tree.patch
@@ -0,0 +1,253 @@
+From ac9f85cd5fdab1d51defa363b31235c45560c7f6 Mon Sep 17 00:00:00 2001
+From: Michael Simacek <msimacek at redhat.com>
+Date: Fri, 12 Feb 2016 09:45:20 +0100
+Subject: [PATCH 1/4] Port to current maven-dependency-tree
+
+---
+ pom.xml                                            |  2 +-
+ .../apache/felix/bundleplugin/BundleAllPlugin.java | 54 ++++++++++++----------
+ .../apache/felix/bundleplugin/BundlePlugin.java    | 30 ++++++------
+ 3 files changed, 46 insertions(+), 40 deletions(-)
+
+--- a/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java
++++ b/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java
+@@ -21,8 +21,10 @@
+ 
+ import java.io.File;
+ import java.io.FilenameFilter;
++import java.util.ArrayDeque;
+ import java.util.Arrays;
+ import java.util.Collection;
++import java.util.Deque;
+ import java.util.HashSet;
+ import java.util.Iterator;
+ import java.util.LinkedHashMap;
+@@ -38,7 +40,6 @@
+ import org.apache.maven.artifact.factory.ArtifactFactory;
+ import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+ import org.apache.maven.artifact.repository.ArtifactRepository;
+-import org.apache.maven.artifact.resolver.ArtifactCollector;
+ import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+ import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+ import org.apache.maven.artifact.resolver.ArtifactResolver;
+@@ -49,13 +50,14 @@
+ import org.apache.maven.plugins.annotations.Mojo;
+ import org.apache.maven.plugins.annotations.Parameter;
+ import org.apache.maven.plugins.annotations.ResolutionScope;
++import org.apache.maven.project.DefaultProjectBuildingRequest;
+ import org.apache.maven.project.MavenProject;
+ import org.apache.maven.project.MavenProjectBuilder;
+ import org.apache.maven.project.ProjectBuildingException;
++import org.apache.maven.project.ProjectBuildingRequest;
+ import org.apache.maven.project.artifact.InvalidDependencyVersionException;
+-import org.apache.maven.shared.dependency.tree.DependencyNode;
+-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
+-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
++import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException;
++import org.apache.maven.shared.dependency.graph.DependencyNode;
+ import org.codehaus.plexus.util.FileUtils;
+ 
+ import aQute.bnd.osgi.Analyzer;
+@@ -92,24 +94,18 @@
+      */
+     @Parameter( property = "wrapImportPackage", defaultValue = "*" )
+     private String wrapImportPackage;
+-
+     @Component
+     private ArtifactFactory m_factory;
+ 
+     @Component
+     private ArtifactMetadataSource m_artifactMetadataSource;
+ 
+-    @Component
+-    private ArtifactCollector m_collector;
+-
+     /**
+      * Artifact resolver, needed to download jars.
+      */
+     @Component
+     private ArtifactResolver m_artifactResolver;
+ 
+-    @Component
+-    private DependencyTreeBuilder m_dependencyTreeBuilder;
+ 
+     @Component
+     private MavenProjectBuilder m_mavenProjectBuilder;
+@@ -180,17 +176,19 @@
+ 
+         try
+         {
+-            dependencyTree = m_dependencyTreeBuilder.buildDependencyTree( project, localRepository, m_factory,
+-                m_artifactMetadataSource, null, m_collector );
++            ProjectBuildingRequest request = new DefaultProjectBuildingRequest();
++            request.setProject(getProject());
++            request.setRepositorySession(session.getRepositorySession());
++            dependencyTree = m_dependencyGraphBuilder.buildDependencyGraph(request, null);
+         }
+-        catch ( DependencyTreeBuilderException e )
++        catch ( DependencyGraphBuilderException e )
+         {
+             throw new MojoExecutionException( "Unable to build dependency tree", e );
+         }
+ 
+         BundleInfo bundleInfo = new BundleInfo();
+ 
+-        if ( !dependencyTree.hasChildren() )
++        if ( dependencyTree.getChildren().isEmpty())
+         {
+             /* no need to traverse the tree */
+             return bundleRoot( project, bundleInfo );
+@@ -198,20 +196,27 @@
+ 
+         getLog().debug( "Will bundle the following dependency tree" + LS + dependencyTree );
+ 
+-        for ( Iterator it = dependencyTree.inverseIterator(); it.hasNext(); )
++        Deque<DependencyNode> stack = new ArrayDeque<DependencyNode>();
++        stack.push(dependencyTree);
++        Set<DependencyNode> visited = new HashSet<DependencyNode>();
++        while (!stack.isEmpty())
+         {
+-            DependencyNode node = ( DependencyNode ) it.next();
+-            if ( !it.hasNext() )
++            DependencyNode node = stack.pop();
++            if (visited.contains(node))
+             {
+-                /* this is the root, current project */
+-                break;
++                continue;
+             }
+-
+-            if ( node.getState() != DependencyNode.INCLUDED )
++            visited.add(node);
++            if (node.getChildren() != null)
+             {
+-                continue;
++                stack.addAll(node.getChildren());
+             }
+ 
++            //if ( node.getState() != DependencyNode.INCLUDED )
++            //{
++            //    continue;
++            //}
++
+             if ( Artifact.SCOPE_SYSTEM.equals( node.getArtifact().getScope() ) )
+             {
+                 getLog().debug( "Ignoring system scoped artifact " + node.getArtifact() );
+@@ -235,12 +240,11 @@
+ 
+             node.getArtifact().setFile( artifact.getFile() );
+ 
+-            int nodeDepth = node.getDepth();
+-            if ( nodeDepth > maxDepth )
++            if ( stack.size() > maxDepth )
+             {
+                 /* node is deeper than we want */
+                 getLog().debug(
+-                    "Ignoring " + node.getArtifact() + ", depth is " + nodeDepth + ", bigger than " + maxDepth );
++                    "Ignoring " + node.getArtifact() + ", depth is " + stack.size() + ", bigger than " + maxDepth );
+                 continue;
+             }
+ 
+--- a/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
++++ b/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+@@ -72,15 +72,15 @@
+ import org.apache.maven.plugins.annotations.Mojo;
+ import org.apache.maven.plugins.annotations.Parameter;
+ import org.apache.maven.plugins.annotations.ResolutionScope;
++import org.apache.maven.project.DefaultProjectBuildingRequest;
+ import org.apache.maven.project.MavenProject;
+ import org.apache.maven.project.MavenProjectBuilder;
+ import org.apache.maven.project.MavenProjectHelper;
+ import org.apache.maven.project.ProjectBuildingException;
++import org.apache.maven.project.ProjectBuildingRequest;
+ import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
+ import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException;
+ import org.apache.maven.shared.dependency.graph.DependencyNode;
+-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
+-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
+ import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
+ import org.apache.maven.shared.osgi.Maven2OsgiConverter;
+ import org.codehaus.plexus.archiver.UnArchiver;
+@@ -224,9 +224,6 @@
+     @Component
+     protected MavenProjectBuilder mavenProjectBuilder;
+ 
+-    @Component
+-    private DependencyTreeBuilder dependencyTreeBuilder;
+-
+     /**
+      * The dependency graph builder to use.
+      */
+@@ -346,7 +343,10 @@
+         DependencyNode dependencyGraph;
+         try
+         {
+-            dependencyGraph = m_dependencyGraphBuilder.buildDependencyGraph( mavenProject, null );
++            ProjectBuildingRequest request = new DefaultProjectBuildingRequest();
++            request.setProject(mavenProject);
++            request.setRepositorySession(session.getRepositorySession());
++            dependencyGraph = m_dependencyGraphBuilder.buildDependencyGraph( request, null );
+         }
+         catch ( DependencyGraphBuilderException e )
+         {
+@@ -757,7 +757,7 @@
+     // We need to find the direct dependencies that have been included in the uber JAR so that we can modify the
+     // POM accordingly.
+     private void createDependencyReducedPom( Set<String> artifactsToRemove )
+-            throws IOException, DependencyTreeBuilderException, ProjectBuildingException
++            throws IOException, DependencyGraphBuilderException, ProjectBuildingException
+     {
+         Model model = project.getOriginalModel();
+         List<Dependency> dependencies = new ArrayList<Dependency>();
+@@ -900,24 +900,26 @@
+     }
+ 
+     public boolean updateExcludesInDeps( MavenProject project, List<Dependency> dependencies, List<Dependency> transitiveDeps )
+-            throws DependencyTreeBuilderException
++    throws DependencyGraphBuilderException
+     {
+-        org.apache.maven.shared.dependency.tree.DependencyNode node = dependencyTreeBuilder.buildDependencyTree(project, localRepository, artifactFactory,
+-                artifactMetadataSource, null,
+-                artifactCollector);
++        ProjectBuildingRequest request = new DefaultProjectBuildingRequest();
++        request.setProject(project);
++        request.setRepositorySession(session.getRepositorySession());
++        DependencyNode node = dependencyGraphBuilder.buildDependencyGraph(request, null);
+         boolean modified = false;
+         Iterator it = node.getChildren().listIterator();
+         while ( it.hasNext() )
+         {
+-            org.apache.maven.shared.dependency.tree.DependencyNode n2 = (org.apache.maven.shared.dependency.tree.DependencyNode) it.next();
++            DependencyNode n2 = (DependencyNode) it.next();
+             Iterator it2 = n2.getChildren().listIterator();
+             while ( it2.hasNext() )
+             {
+-                org.apache.maven.shared.dependency.tree.DependencyNode n3 = (org.apache.maven.shared.dependency.tree.DependencyNode) it2.next();
++                DependencyNode n3 = (DependencyNode) it2.next();
+                 //anything two levels deep that is marked "included"
+                 //is stuff that was excluded by the original poms, make sure it
+                 //remains excluded IF promoting transitives.
+-                if ( n3.getState() == org.apache.maven.shared.dependency.tree.DependencyNode.INCLUDED )
++                //if ( n3.getState() == org.apache.maven.shared.dependency.tree.DependencyNode.INCLUDED )
++                if (true)
+                 {
+                     //check if it really isn't in the list of original dependencies.  Maven
+                     //prior to 2.0.8 may grab versions from transients instead of
+--- a/pom.xml
++++ b/pom.xml
+@@ -115,6 +115,15 @@
+    </plugins>
+   </pluginManagement>
+   <plugins>
++    <plugin>
++      <groupId>org.apache.maven.plugins</groupId>
++      <artifactId>maven-compiler-plugin</artifactId>
++      <configuration>
++        <excludes>
++          <exclude>org/apache/maven/shared/dependency/tree/**/*.java</exclude>
++        </excludes>
++      </configuration>
++    </plugin>
+    <plugin>
+     <groupId>org.apache.maven.plugins</groupId>
+     <artifactId>maven-plugin-plugin</artifactId>
diff --git a/debian/patches/series b/debian/patches/series
index ba3cbc8..e4428d6 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,3 +3,4 @@ support_plexus_utils_1_5.diff
 use-changelog-date-as-pom.properties-timestamp.patch
 maven-archiver3-869361.patch
 maven3-compatibility.patch
+0001-Port-to-current-maven-dependency-tree.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/maven-bundle-plugin.git



More information about the pkg-java-commits mailing list