Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
Richard S. Hall | 01a56ce | 2007-05-20 22:31:11 +0000 | [diff] [blame] | 19 | package org.apache.felix.bundleplugin; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 20 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 21 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 22 | import java.io.File; |
| 23 | import java.io.FilenameFilter; |
| 24 | import java.util.Arrays; |
| 25 | import java.util.Collection; |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 26 | import java.util.HashSet; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 27 | import java.util.Iterator; |
Stuart McCulloch | d00f971 | 2009-07-13 10:06:47 +0000 | [diff] [blame] | 28 | import java.util.LinkedHashMap; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 29 | import java.util.List; |
| 30 | import java.util.Map; |
Stuart McCulloch | 2cb9a56 | 2008-04-23 11:00:42 +0000 | [diff] [blame] | 31 | import java.util.Properties; |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 32 | import java.util.Set; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 33 | import java.util.jar.Manifest; |
| 34 | import java.util.regex.Matcher; |
| 35 | import java.util.regex.Pattern; |
| 36 | |
| 37 | import org.apache.maven.artifact.Artifact; |
| 38 | import org.apache.maven.artifact.factory.ArtifactFactory; |
| 39 | import org.apache.maven.artifact.metadata.ArtifactMetadataSource; |
| 40 | import org.apache.maven.artifact.repository.ArtifactRepository; |
| 41 | import org.apache.maven.artifact.resolver.ArtifactCollector; |
| 42 | import org.apache.maven.artifact.resolver.ArtifactNotFoundException; |
| 43 | import org.apache.maven.artifact.resolver.ArtifactResolutionException; |
| 44 | import org.apache.maven.artifact.resolver.ArtifactResolver; |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 45 | import org.apache.maven.artifact.versioning.VersionRange; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 46 | import org.apache.maven.plugin.MojoExecutionException; |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 47 | import org.apache.maven.plugins.annotations.Component; |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 48 | import org.apache.maven.plugins.annotations.LifecyclePhase; |
| 49 | import org.apache.maven.plugins.annotations.Mojo; |
| 50 | import org.apache.maven.plugins.annotations.Parameter; |
| 51 | import org.apache.maven.plugins.annotations.ResolutionScope; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 52 | import org.apache.maven.project.MavenProject; |
| 53 | import org.apache.maven.project.MavenProjectBuilder; |
| 54 | import org.apache.maven.project.ProjectBuildingException; |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 55 | import org.apache.maven.project.artifact.InvalidDependencyVersionException; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 56 | import org.apache.maven.shared.dependency.tree.DependencyNode; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 57 | import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; |
| 58 | import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 59 | import org.codehaus.plexus.util.FileUtils; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 60 | |
Stuart McCulloch | 42151ee | 2012-07-16 13:43:38 +0000 | [diff] [blame] | 61 | import aQute.bnd.osgi.Analyzer; |
| 62 | import aQute.bnd.osgi.Jar; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 63 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 64 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 65 | /** |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 66 | * Build an OSGi bundle jar for all transitive dependencies. |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 67 | * |
Stuart McCulloch | 034e7b8 | 2011-06-16 17:41:18 +0000 | [diff] [blame] | 68 | * @deprecated The bundleall goal is no longer supported and may be removed in a future release |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 69 | */ |
Stuart McCulloch | 034e7b8 | 2011-06-16 17:41:18 +0000 | [diff] [blame] | 70 | @Deprecated |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 71 | @Mojo( name = "bundleall", requiresDependencyResolution = ResolutionScope.TEST, defaultPhase = LifecyclePhase.PACKAGE ) |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 72 | public class BundleAllPlugin extends ManifestPlugin |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 73 | { |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 74 | private static final String LS = System.getProperty( "line.separator" ); |
| 75 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 76 | private static final Pattern SNAPSHOT_VERSION_PATTERN = Pattern.compile( "[0-9]{8}_[0-9]{6}_[0-9]+" ); |
| 77 | |
| 78 | /** |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 79 | * Local repository. |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 80 | */ |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 81 | @Parameter( defaultValue = "${localRepository}", readonly = true, required = true ) |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 82 | private ArtifactRepository localRepository; |
| 83 | |
| 84 | /** |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 85 | * Remote repositories. |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 86 | */ |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 87 | @Parameter( defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true ) |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 88 | private List remoteRepositories; |
| 89 | |
| 90 | /** |
Stuart McCulloch | 2cb9a56 | 2008-04-23 11:00:42 +0000 | [diff] [blame] | 91 | * Import-Package to be used when wrapping dependencies. |
Stuart McCulloch | 2cb9a56 | 2008-04-23 11:00:42 +0000 | [diff] [blame] | 92 | */ |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 93 | @Parameter( property = "wrapImportPackage", defaultValue = "*" ) |
Stuart McCulloch | 2cb9a56 | 2008-04-23 11:00:42 +0000 | [diff] [blame] | 94 | private String wrapImportPackage; |
| 95 | |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 96 | @Component |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 97 | private ArtifactFactory m_factory; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 98 | |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 99 | @Component |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 100 | private ArtifactMetadataSource m_artifactMetadataSource; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 101 | |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 102 | @Component |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 103 | private ArtifactCollector m_collector; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 104 | |
| 105 | /** |
| 106 | * Artifact resolver, needed to download jars. |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 107 | */ |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 108 | @Component |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 109 | private ArtifactResolver m_artifactResolver; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 110 | |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 111 | @Component |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 112 | private DependencyTreeBuilder m_dependencyTreeBuilder; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 113 | |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 114 | @Component |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 115 | private MavenProjectBuilder m_mavenProjectBuilder; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 116 | |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 117 | /** |
| 118 | * Ignore missing artifacts that are not required by current project but are required by the |
| 119 | * transitive dependencies. |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 120 | */ |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 121 | @Parameter |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 122 | private boolean ignoreMissingArtifacts; |
| 123 | |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 124 | private Set m_artifactsBeingProcessed = new HashSet(); |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 125 | |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 126 | /** |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 127 | * Process up to some depth |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 128 | */ |
Carsten Ziegeler | 318c2cb | 2015-03-09 13:57:23 +0000 | [diff] [blame] | 129 | @Parameter |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 130 | private int depth = Integer.MAX_VALUE; |
| 131 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 132 | |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 133 | @Override |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 134 | public void execute() throws MojoExecutionException |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 135 | { |
Stuart McCulloch | b45e181 | 2011-06-27 17:38:53 +0000 | [diff] [blame] | 136 | getLog().warn( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ); |
| 137 | getLog().warn( "! The bundleall goal is no longer supported and may be removed in a future release !" ); |
| 138 | getLog().warn( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ); |
| 139 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 140 | BundleInfo bundleInfo = bundleAll( getProject() ); |
| 141 | logDuplicatedPackages( bundleInfo ); |
| 142 | } |
| 143 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 144 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 145 | /** |
| 146 | * Bundle a project and all its dependencies |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 147 | * |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 148 | * @param project |
| 149 | * @throws MojoExecutionException |
| 150 | */ |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 151 | private BundleInfo bundleAll( MavenProject project ) throws MojoExecutionException |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 152 | { |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 153 | return bundleAll( project, depth ); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 154 | } |
| 155 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 156 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 157 | /** |
| 158 | * Bundle a project and its transitive dependencies up to some depth level |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 159 | * |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 160 | * @param project |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 161 | * @param maxDepth how deep to process the dependency tree |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 162 | * @throws MojoExecutionException |
| 163 | */ |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 164 | protected BundleInfo bundleAll( MavenProject project, int maxDepth ) throws MojoExecutionException |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 165 | { |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 166 | if ( alreadyBundled( project.getArtifact() ) ) |
| 167 | { |
| 168 | getLog().debug( "Ignoring project already processed " + project.getArtifact() ); |
| 169 | return null; |
| 170 | } |
| 171 | |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 172 | if ( m_artifactsBeingProcessed.contains( project.getArtifact() ) ) |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 173 | { |
| 174 | getLog().warn( "Ignoring artifact due to dependency cycle " + project.getArtifact() ); |
| 175 | return null; |
| 176 | } |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 177 | m_artifactsBeingProcessed.add( project.getArtifact() ); |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 178 | |
Stuart McCulloch | de88f0c | 2007-10-04 13:12:06 +0000 | [diff] [blame] | 179 | DependencyNode dependencyTree; |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 180 | |
| 181 | try |
| 182 | { |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 183 | dependencyTree = m_dependencyTreeBuilder.buildDependencyTree( project, localRepository, m_factory, |
| 184 | m_artifactMetadataSource, null, m_collector ); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 185 | } |
| 186 | catch ( DependencyTreeBuilderException e ) |
| 187 | { |
| 188 | throw new MojoExecutionException( "Unable to build dependency tree", e ); |
| 189 | } |
| 190 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 191 | BundleInfo bundleInfo = new BundleInfo(); |
| 192 | |
Stuart McCulloch | de88f0c | 2007-10-04 13:12:06 +0000 | [diff] [blame] | 193 | if ( !dependencyTree.hasChildren() ) |
| 194 | { |
| 195 | /* no need to traverse the tree */ |
| 196 | return bundleRoot( project, bundleInfo ); |
| 197 | } |
| 198 | |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 199 | getLog().debug( "Will bundle the following dependency tree" + LS + dependencyTree ); |
| 200 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 201 | for ( Iterator it = dependencyTree.inverseIterator(); it.hasNext(); ) |
| 202 | { |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 203 | DependencyNode node = ( DependencyNode ) it.next(); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 204 | if ( !it.hasNext() ) |
| 205 | { |
| 206 | /* this is the root, current project */ |
| 207 | break; |
| 208 | } |
| 209 | |
Stuart McCulloch | de88f0c | 2007-10-04 13:12:06 +0000 | [diff] [blame] | 210 | if ( node.getState() != DependencyNode.INCLUDED ) |
| 211 | { |
| 212 | continue; |
| 213 | } |
| 214 | |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 215 | if ( Artifact.SCOPE_SYSTEM.equals( node.getArtifact().getScope() ) ) |
| 216 | { |
| 217 | getLog().debug( "Ignoring system scoped artifact " + node.getArtifact() ); |
| 218 | continue; |
| 219 | } |
| 220 | |
| 221 | Artifact artifact; |
| 222 | try |
| 223 | { |
| 224 | artifact = resolveArtifact( node.getArtifact() ); |
| 225 | } |
| 226 | catch ( ArtifactNotFoundException e ) |
| 227 | { |
| 228 | if ( ignoreMissingArtifacts ) |
| 229 | { |
| 230 | continue; |
| 231 | } |
Stuart McCulloch | f806f86 | 2008-02-04 07:57:09 +0000 | [diff] [blame] | 232 | |
| 233 | throw new MojoExecutionException( "Artifact was not found in the repo" + node.getArtifact(), e ); |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 234 | } |
| 235 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 236 | node.getArtifact().setFile( artifact.getFile() ); |
| 237 | |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 238 | int nodeDepth = node.getDepth(); |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 239 | if ( nodeDepth > maxDepth ) |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 240 | { |
| 241 | /* node is deeper than we want */ |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 242 | getLog().debug( |
| 243 | "Ignoring " + node.getArtifact() + ", depth is " + nodeDepth + ", bigger than " + maxDepth ); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 244 | continue; |
| 245 | } |
| 246 | |
| 247 | MavenProject childProject; |
| 248 | try |
| 249 | { |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 250 | childProject = m_mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, |
| 251 | localRepository, true ); |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 252 | if ( childProject.getDependencyArtifacts() == null ) |
| 253 | { |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 254 | childProject.setDependencyArtifacts( childProject.createArtifacts( m_factory, null, null ) ); |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 255 | } |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 256 | } |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 257 | catch ( InvalidDependencyVersionException e ) |
| 258 | { |
| 259 | throw new MojoExecutionException( "Invalid dependency version for artifact " + artifact ); |
| 260 | } |
Stuart McCulloch | d3003ed | 2011-10-26 12:24:15 +0000 | [diff] [blame] | 261 | catch ( ProjectBuildingException e ) |
| 262 | { |
| 263 | throw new MojoExecutionException( "Unable to build project object for artifact " + artifact, e ); |
| 264 | } |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 265 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 266 | childProject.setArtifact( artifact ); |
| 267 | getLog().debug( "Child project artifact location: " + childProject.getArtifact().getFile() ); |
| 268 | |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 269 | if ( ( Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) ) |
| 270 | || ( Artifact.SCOPE_RUNTIME.equals( artifact.getScope() ) ) ) |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 271 | { |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 272 | BundleInfo subBundleInfo = bundleAll( childProject, maxDepth - 1 ); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 273 | if ( subBundleInfo != null ) |
| 274 | { |
| 275 | bundleInfo.merge( subBundleInfo ); |
| 276 | } |
| 277 | } |
| 278 | else |
| 279 | { |
| 280 | getLog().debug( |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 281 | "Not processing due to scope (" + childProject.getArtifact().getScope() + "): " |
| 282 | + childProject.getArtifact() ); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 283 | } |
| 284 | } |
| 285 | |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 286 | return bundleRoot( project, bundleInfo ); |
| 287 | } |
| 288 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 289 | |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 290 | /** |
| 291 | * Bundle the root of a dependency tree after all its children have been bundled |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 292 | * |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 293 | * @param project |
| 294 | * @param bundleInfo |
| 295 | * @return |
| 296 | * @throws MojoExecutionException |
| 297 | */ |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 298 | private BundleInfo bundleRoot( MavenProject project, BundleInfo bundleInfo ) throws MojoExecutionException |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 299 | { |
| 300 | /* do not bundle the project the mojo was called on */ |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 301 | if ( getProject() != project ) |
| 302 | { |
| 303 | getLog().debug( "Project artifact location: " + project.getArtifact().getFile() ); |
| 304 | |
| 305 | BundleInfo subBundleInfo = bundle( project ); |
| 306 | if ( subBundleInfo != null ) |
| 307 | { |
| 308 | bundleInfo.merge( subBundleInfo ); |
| 309 | } |
| 310 | } |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 311 | return bundleInfo; |
| 312 | } |
| 313 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 314 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 315 | /** |
| 316 | * Bundle one project only without building its childre |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 317 | * |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 318 | * @param project |
| 319 | * @throws MojoExecutionException |
| 320 | */ |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 321 | protected BundleInfo bundle( MavenProject project ) throws MojoExecutionException |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 322 | { |
| 323 | Artifact artifact = project.getArtifact(); |
| 324 | getLog().info( "Bundling " + artifact ); |
| 325 | |
| 326 | try |
| 327 | { |
Stuart McCulloch | d00f971 | 2009-07-13 10:06:47 +0000 | [diff] [blame] | 328 | Map instructions = new LinkedHashMap(); |
Stuart McCulloch | 2cb9a56 | 2008-04-23 11:00:42 +0000 | [diff] [blame] | 329 | instructions.put( Analyzer.IMPORT_PACKAGE, wrapImportPackage ); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 330 | |
| 331 | project.getArtifact().setFile( getFile( artifact ) ); |
Guillaume Nodet | ed7b110 | 2015-07-09 19:45:09 +0000 | [diff] [blame] | 332 | File outputFile = getOutputFile(artifact); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 333 | |
| 334 | if ( project.getArtifact().getFile().equals( outputFile ) ) |
| 335 | { |
| 336 | /* TODO find the cause why it's getting here */ |
| 337 | return null; |
| 338 | // getLog().error( |
| 339 | // "Trying to read and write " + artifact + " to the same file, try cleaning: " |
| 340 | // + outputFile ); |
| 341 | // throw new IllegalStateException( "Trying to read and write " + artifact |
| 342 | // + " to the same file, try cleaning: " + outputFile ); |
| 343 | } |
| 344 | |
Guillaume Nodet | ed7b110 | 2015-07-09 19:45:09 +0000 | [diff] [blame] | 345 | org.apache.maven.shared.dependency.graph.DependencyNode dependencyGraph = buildDependencyGraph( project ); |
| 346 | Analyzer analyzer = getAnalyzer( project, dependencyGraph, instructions, new Properties(), getClasspath( project, dependencyGraph ) ); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 347 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 348 | Jar osgiJar = new Jar( project.getArtifactId(), project.getArtifact().getFile() ); |
Richard S. Hall | ea2e9e0 | 2007-05-17 13:05:50 +0000 | [diff] [blame] | 349 | |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 350 | outputFile.getAbsoluteFile().getParentFile().mkdirs(); |
| 351 | |
Richard S. Hall | ea2e9e0 | 2007-05-17 13:05:50 +0000 | [diff] [blame] | 352 | Collection exportedPackages; |
| 353 | if ( isOsgi( osgiJar ) ) |
| 354 | { |
| 355 | /* if it is already an OSGi jar copy it as is */ |
| 356 | getLog().info( |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 357 | "Using existing OSGi bundle for " + project.getGroupId() + ":" + project.getArtifactId() + ":" |
| 358 | + project.getVersion() ); |
Richard S. Hall | ea2e9e0 | 2007-05-17 13:05:50 +0000 | [diff] [blame] | 359 | String exportHeader = osgiJar.getManifest().getMainAttributes().getValue( Analyzer.EXPORT_PACKAGE ); |
| 360 | exportedPackages = analyzer.parseHeader( exportHeader ).keySet(); |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 361 | FileUtils.copyFile( project.getArtifact().getFile(), outputFile ); |
Richard S. Hall | ea2e9e0 | 2007-05-17 13:05:50 +0000 | [diff] [blame] | 362 | } |
| 363 | else |
| 364 | { |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 365 | /* else generate the manifest from the packages */ |
Richard S. Hall | ea2e9e0 | 2007-05-17 13:05:50 +0000 | [diff] [blame] | 366 | exportedPackages = analyzer.getExports().keySet(); |
| 367 | Manifest manifest = analyzer.getJar().getManifest(); |
| 368 | osgiJar.setManifest( manifest ); |
Stuart McCulloch | d6e642f | 2008-03-03 02:19:21 +0000 | [diff] [blame] | 369 | osgiJar.write( outputFile ); |
Richard S. Hall | ea2e9e0 | 2007-05-17 13:05:50 +0000 | [diff] [blame] | 370 | } |
| 371 | |
Richard S. Hall | ea2e9e0 | 2007-05-17 13:05:50 +0000 | [diff] [blame] | 372 | BundleInfo bundleInfo = addExportedPackages( project, exportedPackages ); |
| 373 | |
Stuart McCulloch | d8a04c5 | 2008-08-06 16:05:23 +0000 | [diff] [blame] | 374 | // cleanup... |
| 375 | analyzer.close(); |
| 376 | osgiJar.close(); |
| 377 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 378 | return bundleInfo; |
| 379 | } |
| 380 | /* too bad Jar.write throws Exception */ |
| 381 | catch ( Exception e ) |
| 382 | { |
| 383 | throw new MojoExecutionException( "Error generating OSGi bundle for project " |
| 384 | + getArtifactKey( project.getArtifact() ), e ); |
| 385 | } |
| 386 | } |
| 387 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 388 | |
Stuart McCulloch | 35c25c3 | 2011-04-02 10:24:03 +0000 | [diff] [blame] | 389 | private boolean isOsgi( Jar jar ) throws Exception |
Richard S. Hall | ea2e9e0 | 2007-05-17 13:05:50 +0000 | [diff] [blame] | 390 | { |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 391 | if ( jar.getManifest() != null ) |
| 392 | { |
| 393 | return jar.getManifest().getMainAttributes().getValue( Analyzer.BUNDLE_NAME ) != null; |
| 394 | } |
| 395 | return false; |
Richard S. Hall | ea2e9e0 | 2007-05-17 13:05:50 +0000 | [diff] [blame] | 396 | } |
| 397 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 398 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 399 | private BundleInfo addExportedPackages( MavenProject project, Collection packages ) |
| 400 | { |
| 401 | BundleInfo bundleInfo = new BundleInfo(); |
| 402 | for ( Iterator it = packages.iterator(); it.hasNext(); ) |
| 403 | { |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 404 | String packageName = ( String ) it.next(); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 405 | bundleInfo.addExportedPackage( packageName, project.getArtifact() ); |
| 406 | } |
| 407 | return bundleInfo; |
| 408 | } |
| 409 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 410 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 411 | private String getArtifactKey( Artifact artifact ) |
| 412 | { |
| 413 | return artifact.getGroupId() + ":" + artifact.getArtifactId(); |
| 414 | } |
| 415 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 416 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 417 | private String getBundleName( Artifact artifact ) |
| 418 | { |
Richard S. Hall | 17b8e3d | 2007-06-13 16:20:40 +0000 | [diff] [blame] | 419 | return getMaven2OsgiConverter().getBundleFileName( artifact ); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 420 | } |
| 421 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 422 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 423 | private boolean alreadyBundled( Artifact artifact ) |
| 424 | { |
| 425 | return getBuiltFile( artifact ) != null; |
| 426 | } |
| 427 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 428 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 429 | /** |
| 430 | * Use previously built bundles when available. |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 431 | * |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 432 | * @param artifact |
| 433 | */ |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 434 | @Override |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 435 | protected File getFile( final Artifact artifact ) |
| 436 | { |
| 437 | File bundle = getBuiltFile( artifact ); |
| 438 | |
| 439 | if ( bundle != null ) |
| 440 | { |
| 441 | getLog().debug( "Using previously built OSGi bundle for " + artifact + " in " + bundle ); |
| 442 | return bundle; |
| 443 | } |
| 444 | return super.getFile( artifact ); |
| 445 | } |
| 446 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 447 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 448 | private File getBuiltFile( final Artifact artifact ) |
| 449 | { |
| 450 | File bundle = null; |
| 451 | |
| 452 | /* if bundle was already built use it instead of jar from repo */ |
| 453 | File outputFile = getOutputFile( artifact ); |
| 454 | if ( outputFile.exists() ) |
| 455 | { |
| 456 | bundle = outputFile; |
| 457 | } |
| 458 | |
| 459 | /* |
| 460 | * Find snapshots in output folder, eg. 2.1-SNAPSHOT will match 2.1.0.20070207_193904_2 |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 461 | * TODO there has to be another way to do this using Maven libs |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 462 | */ |
| 463 | if ( ( bundle == null ) && artifact.isSnapshot() ) |
| 464 | { |
| 465 | final File buildDirectory = new File( getBuildDirectory() ); |
| 466 | if ( !buildDirectory.exists() ) |
| 467 | { |
| 468 | buildDirectory.mkdirs(); |
| 469 | } |
| 470 | File[] files = buildDirectory.listFiles( new FilenameFilter() |
| 471 | { |
| 472 | public boolean accept( File dir, String name ) |
| 473 | { |
| 474 | if ( dir.equals( buildDirectory ) && snapshotMatch( artifact, name ) ) |
| 475 | { |
| 476 | return true; |
| 477 | } |
| 478 | return false; |
| 479 | } |
| 480 | } ); |
| 481 | if ( files.length > 1 ) |
| 482 | { |
| 483 | throw new RuntimeException( "More than one previously built bundle matches for artifact " + artifact |
| 484 | + " : " + Arrays.asList( files ) ); |
| 485 | } |
| 486 | if ( files.length == 1 ) |
| 487 | { |
| 488 | bundle = files[0]; |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | return bundle; |
| 493 | } |
| 494 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 495 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 496 | /** |
| 497 | * Check that the bundleName provided correspond to the artifact provided. |
| 498 | * Used to determine when the bundle name is a timestamped snapshot and the artifact is a snapshot not timestamped. |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 499 | * |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 500 | * @param artifact artifact with snapshot version |
Carsten Ziegeler | 0a4eff1 | 2015-05-12 06:04:41 +0000 | [diff] [blame] | 501 | * @param bundleName bundle file name |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 502 | * @return if both represent the same artifact and version, forgetting about the snapshot timestamp |
| 503 | */ |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 504 | protected boolean snapshotMatch( Artifact artifact, String bundleName ) |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 505 | { |
| 506 | String artifactBundleName = getBundleName( artifact ); |
| 507 | int i = artifactBundleName.indexOf( "SNAPSHOT" ); |
| 508 | if ( i < 0 ) |
| 509 | { |
| 510 | return false; |
| 511 | } |
| 512 | artifactBundleName = artifactBundleName.substring( 0, i ); |
| 513 | |
| 514 | if ( bundleName.startsWith( artifactBundleName ) ) |
| 515 | { |
| 516 | /* it's the same artifact groupId and artifactId */ |
| 517 | String timestamp = bundleName.substring( artifactBundleName.length(), bundleName.lastIndexOf( ".jar" ) ); |
| 518 | Matcher m = SNAPSHOT_VERSION_PATTERN.matcher( timestamp ); |
| 519 | return m.matches(); |
| 520 | } |
| 521 | return false; |
| 522 | } |
| 523 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 524 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 525 | protected File getOutputFile( Artifact artifact ) |
| 526 | { |
Richard S. Hall | 420d278 | 2007-06-14 12:31:48 +0000 | [diff] [blame] | 527 | return new File( getOutputDirectory(), getBundleName( artifact ) ); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 528 | } |
| 529 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 530 | |
| 531 | private Artifact resolveArtifact( Artifact artifact ) throws MojoExecutionException, ArtifactNotFoundException |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 532 | { |
Stuart McCulloch | e024581 | 2007-09-25 14:54:09 +0000 | [diff] [blame] | 533 | VersionRange versionRange; |
| 534 | if ( artifact.getVersion() != null ) |
| 535 | { |
| 536 | versionRange = VersionRange.createFromVersion( artifact.getVersion() ); |
| 537 | } |
| 538 | else |
| 539 | { |
| 540 | versionRange = artifact.getVersionRange(); |
| 541 | } |
| 542 | |
| 543 | /* |
| 544 | * there's a bug with ArtifactFactory#createDependencyArtifact(String, String, VersionRange, |
| 545 | * String, String, String) that ignores the scope parameter, that's why we use the one with |
| 546 | * the extra null parameter |
| 547 | */ |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 548 | Artifact resolvedArtifact = m_factory.createDependencyArtifact( artifact.getGroupId(), |
| 549 | artifact.getArtifactId(), versionRange, artifact.getType(), artifact.getClassifier(), artifact.getScope(), |
| 550 | null ); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 551 | |
| 552 | try |
| 553 | { |
Stuart McCulloch | 9366a82 | 2008-01-29 07:45:57 +0000 | [diff] [blame] | 554 | m_artifactResolver.resolve( resolvedArtifact, remoteRepositories, localRepository ); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 555 | } |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 556 | catch ( ArtifactResolutionException e ) |
| 557 | { |
| 558 | throw new MojoExecutionException( "Error resolving artifact " + resolvedArtifact, e ); |
| 559 | } |
| 560 | |
| 561 | return resolvedArtifact; |
| 562 | } |
| 563 | |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 564 | |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 565 | /** |
| 566 | * Log what packages are exported in more than one bundle |
| 567 | */ |
| 568 | protected void logDuplicatedPackages( BundleInfo bundleInfo ) |
| 569 | { |
| 570 | Map duplicatedExports = bundleInfo.getDuplicatedExports(); |
| 571 | |
| 572 | for ( Iterator it = duplicatedExports.entrySet().iterator(); it.hasNext(); ) |
| 573 | { |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 574 | Map.Entry entry = ( Map.Entry ) it.next(); |
| 575 | String packageName = ( String ) entry.getKey(); |
| 576 | Collection artifacts = ( Collection ) entry.getValue(); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 577 | |
| 578 | getLog().warn( "Package " + packageName + " is exported in more than a bundle: " ); |
| 579 | for ( Iterator it2 = artifacts.iterator(); it2.hasNext(); ) |
| 580 | { |
Stuart McCulloch | 5ae5914 | 2008-01-29 06:21:05 +0000 | [diff] [blame] | 581 | Artifact artifact = ( Artifact ) it2.next(); |
Richard S. Hall | 6cf6f0b | 2007-04-10 16:50:31 +0000 | [diff] [blame] | 582 | getLog().warn( " " + artifact ); |
| 583 | } |
| 584 | |
| 585 | } |
| 586 | } |
| 587 | } |