This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository i18n. See http://git.nuiton.org/i18n.git commit c61491e26190de0bb5d8a655e35786108ea399af Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Feb 27 12:32:03 2016 +0100 Use maven 3 API + maven-dependency-tree 3.0 and snapshot of maven-helper-plugin (See #3893) --- i18n-maven-plugin/pom.xml | 8 ++- .../org/nuiton/i18n/plugin/AbstractI18nMojo.java | 4 ++ .../plugin/bundle/CollectI18nArtifactsMojo.java | 75 ++++++++-------------- pom.xml | 22 +++++-- 4 files changed, 57 insertions(+), 52 deletions(-) diff --git a/i18n-maven-plugin/pom.xml b/i18n-maven-plugin/pom.xml index 1430c4f..659eeb2 100644 --- a/i18n-maven-plugin/pom.xml +++ b/i18n-maven-plugin/pom.xml @@ -100,7 +100,12 @@ <dependency> <groupId>org.apache.maven</groupId> - <artifactId>maven-project</artifactId> + <artifactId>maven-core</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-model</artifactId> </dependency> <dependency> @@ -111,6 +116,7 @@ <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> + <scope>compile</scope> </dependency> <!-- dependencies to mojo annotations --> diff --git a/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java b/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java index 8895a7d..8934acb 100644 --- a/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java +++ b/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java @@ -25,6 +25,7 @@ package org.nuiton.i18n.plugin; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.nuiton.i18n.I18nUtil; @@ -50,6 +51,9 @@ import java.util.TreeSet; */ public abstract class AbstractI18nMojo extends AbstractPlugin implements PluginWithEncoding { + @Parameter( defaultValue = "${session}", readonly = true ) + protected MavenSession mavenSession; + /** * Dependance du projet. * diff --git a/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java b/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java index 62e03b5..020077a 100644 --- a/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java +++ b/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java @@ -26,10 +26,7 @@ package org.nuiton.i18n.plugin.bundle; import org.apache.maven.artifact.Artifact; -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.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.plugins.annotations.Component; @@ -37,9 +34,11 @@ import org.apache.maven.plugins.annotations.LifecyclePhase; 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.shared.dependency.tree.DependencyNode; -import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; -import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; +import org.apache.maven.project.DefaultProjectBuildingRequest; +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.nuiton.i18n.bundle.I18nBundleEntry; import org.nuiton.plugin.DependencyUtil; @@ -63,9 +62,9 @@ import java.util.Map; * @since 1.0.2 */ @Mojo(name = "collect-i18n-artifacts", - defaultPhase = LifecyclePhase.GENERATE_RESOURCES, - requiresProject = true, - requiresDependencyResolution = ResolutionScope.RUNTIME) + defaultPhase = LifecyclePhase.GENERATE_RESOURCES, + requiresProject = true, + requiresDependencyResolution = ResolutionScope.RUNTIME) public class CollectI18nArtifactsMojo extends AbstractI18nBundleMojo { /** Directory where to find project i18n files. */ @@ -86,31 +85,7 @@ public class CollectI18nArtifactsMojo extends AbstractI18nBundleMojo { * @since 1.0.2 */ @Component - protected DependencyTreeBuilder dependencyTreeBuilder; - - /** - * Artifact Factory component. - * - * @since 1.0.2 - */ - @Component - protected ArtifactFactory factory; - - /** - * Artifact metadata source component. - * - * @since 1.0.2 - */ - @Component - protected ArtifactMetadataSource artifactMetadataSource; - - /** - * Artifact collector component. - * - * @since 1.0.2 - */ - @Component - protected ArtifactCollector collector; + protected DependencyGraphBuilder dependencyTreeBuilder; I18nArtifact[] i18nArtifacts; @@ -136,7 +111,7 @@ public class CollectI18nArtifactsMojo extends AbstractI18nBundleMojo { if (!silent) { getLog().info("generate collected i18n artifacts for locale " + - locale); + locale); } URL[] urls = getCollectI18nResources(locale); @@ -150,14 +125,14 @@ public class CollectI18nArtifactsMojo extends AbstractI18nBundleMojo { storeCollectI18nResources(bundleOut, urls); getLog().info("collected " + urls.length + - " i18n artifacts for locale " + locale + - " stored in " + bundleOut); + " i18n artifacts for locale " + locale + + " stored in " + bundleOut); } } @Override protected URL[] getCollectI18nResources(Locale locale) - throws IOException, DependencyTreeBuilderException { + throws IOException { // la locale par defaut est la première Locale defaultLocale = locales[0]; @@ -199,14 +174,11 @@ public class CollectI18nArtifactsMojo extends AbstractI18nBundleMojo { * artifacts. * * @return les artifacts i18nables triés par leur ordre de chargement dans - * le système i18n. - * @throws IOException while detecting bundles from - * artifacts - * @throws DependencyTreeBuilderException if any error while building the - * depencendy tree + * le système i18n. + * @throws IOException while detecting bundles from artifacts */ protected I18nArtifact[] detectI18nArtifacts() - throws IOException, DependencyTreeBuilderException { + throws IOException, DependencyGraphBuilderException { Map<Artifact, I18nArtifact> dico = new HashMap<Artifact, I18nArtifact>(); @@ -220,9 +192,18 @@ public class CollectI18nArtifactsMojo extends AbstractI18nBundleMojo { ArtifactFilter artifactFilter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME); - DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree( - project, localRepository, factory, - artifactMetadataSource, artifactFilter, collector); + ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(); + buildingRequest.setLocalRepository(localRepository); + buildingRequest.setProject(project); + buildingRequest.setRepositorySession(mavenSession.getRepositorySession()); + + DependencyNode rootNode = dependencyTreeBuilder.buildDependencyGraph( + buildingRequest, artifactFilter); + + +// DependencyNode rootNode = dependencyTreeBuilder.buildDependencyGraph( +// project, localRepository, factory, +// artifactMetadataSource, artifactFilter, collector); List<Artifact> artifacts = new ArrayList<Artifact>(dico.keySet()); diff --git a/pom.xml b/pom.xml index 3077f0d..50c9da4 100644 --- a/pom.xml +++ b/pom.xml @@ -66,8 +66,8 @@ <!--Multilanguage maven-site --> <locales>fr,en</locales> - <mavenVersion>2.2.1</mavenVersion> - <pluginPluginVersion>3.3</pluginPluginVersion> + <mavenVersion>3.3.9</mavenVersion> + <helperPluginVersion>2.3-SNAPSHOT</helperPluginVersion> </properties> @@ -166,13 +166,27 @@ <dependency> <groupId>org.apache.maven.shared</groupId> <artifactId>maven-dependency-tree</artifactId> - <version>2.1</version> + <version>3.0</version> </dependency> <!-- provided dependencies --> <dependency> <groupId>org.apache.maven</groupId> - <artifactId>maven-project</artifactId> + <artifactId>maven-core</artifactId> + <version>${mavenVersion}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-compat</artifactId> + <version>${mavenVersion}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-model</artifactId> <version>${mavenVersion}</version> <scope>provided</scope> </dependency> -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.