List of usage examples for org.apache.maven.artifact.handler ArtifactHandler getPackaging
String getPackaging();
From source file:org.apache.nifi.NarProvidedDependenciesMojo.java
License:Apache License
/** * Creates a new ArtifactHandler for the specified Artifact that overrides the includeDependencies flag. When set, this flag prevents transitive * dependencies from being printed in dependencies plugin. * * @param artifact The artifact//from w ww . j a v a 2 s. co m * @return The handler for the artifact */ private ArtifactHandler excludesDependencies(final Artifact artifact) { final ArtifactHandler orig = artifact.getArtifactHandler(); return new ArtifactHandler() { @Override public String getExtension() { return orig.getExtension(); } @Override public String getDirectory() { return orig.getDirectory(); } @Override public String getClassifier() { return orig.getClassifier(); } @Override public String getPackaging() { return orig.getPackaging(); } // mark dependencies has excluded so they will appear in tree listing @Override public boolean isIncludesDependencies() { return false; } @Override public String getLanguage() { return orig.getLanguage(); } @Override public boolean isAddedToClasspath() { return orig.isAddedToClasspath(); } }; }
From source file:org.jetbrains.maven.embedder.MavenEmbedder.java
License:Apache License
@SuppressWarnings({ "unchecked" }) private Map findArtifactTypeHandlers(MavenProject project) { // end copied from DefaultLifecycleExecutor.findExtensions Map result = new HashMap(); for (Object each : project.getBuildPlugins()) { Plugin eachPlugin = (Plugin) each; if (eachPlugin.isExtensions()) { try { PluginManager pluginManager = getComponent(PluginManager.class); pluginManager.verifyPlugin(eachPlugin, project, mySettings, myLocalRepository); result.putAll(pluginManager.getPluginComponents(eachPlugin, ArtifactHandler.ROLE)); } catch (Exception e) { MavenEmbedderLog.LOG.info(e); continue; }/* w w w .j a v a2 s .c o m*/ for (Object o : result.values()) { ArtifactHandler handler = (ArtifactHandler) o; if (project.getPackaging().equals(handler.getPackaging())) { project.getArtifact().setArtifactHandler(handler); } } } } return result; }
From source file:org.sourcepit.common.maven.artifact.MavenArtifactUtils.java
License:Apache License
@NotNull public static MavenArtifact toMavenArtifact(@NotNull Artifact artifact) { final MavenArtifact mavenArtifact = MavenModelFactory.eINSTANCE.createMavenArtifact(); mavenArtifact.setGroupId(artifact.getGroupId()); mavenArtifact.setArtifactId(artifact.getArtifactId()); mavenArtifact.setVersion(artifact.getVersion()); if (artifact.getClassifier() != null && !ObjectUtils.equals(mavenArtifact.getClassifier(), artifact.getClassifier())) { mavenArtifact.setClassifier(artifact.getClassifier()); }/* w ww .ja v a 2 s . c o m*/ if (artifact.getType() != null && !ObjectUtils.equals(mavenArtifact.getType(), artifact.getType())) { mavenArtifact.setType(artifact.getType()); } mavenArtifact.setFile(artifact.getFile()); final ArtifactHandler artifactHandler = artifact.getArtifactHandler(); final Annotation annotation = mavenArtifact.getAnnotation(ArtifactHandler.class.getName(), true); annotation.setData("packaging", artifactHandler.getPackaging()); annotation.setData("directory", artifactHandler.getDirectory()); annotation.setData("extension", artifactHandler.getExtension()); annotation.setData("language", artifactHandler.getLanguage()); annotation.setData("classifier", artifactHandler.getClassifier()); annotation.setData("includesDependencies", artifactHandler.isIncludesDependencies()); annotation.setData("addedToClasspath", artifactHandler.isAddedToClasspath()); return mavenArtifact; }