List of usage examples for org.apache.maven.artifact.handler ArtifactHandler isAddedToClasspath
boolean isAddedToClasspath();
From source file:com.liferay.maven.plugins.AbstractToolsLiferayMojo.java
License:Open Source License
protected List<String> getProjectClassPath() throws Exception { List<String> projectClassPath = new ArrayList<String>(); projectClassPath.addAll(getToolsClassPath()); List<MavenProject> classPathMavenProjects = new ArrayList<MavenProject>(); classPathMavenProjects.add(project); for (Object object : project.getDependencyArtifacts()) { Artifact artifact = (Artifact) object; ArtifactHandler artifactHandler = artifact.getArtifactHandler(); if (!artifactHandler.isAddedToClasspath()) { continue; }//w w w . j a v a2 s . co m MavenProject dependencyMavenProject = resolveProject(artifact); if (dependencyMavenProject == null) { continue; } else { getLog().debug("Resolved dependency project " + dependencyMavenProject); } List<String> compileSourceRoots = dependencyMavenProject.getCompileSourceRoots(); if (compileSourceRoots.isEmpty()) { continue; } getLog().debug("Adding project to class path " + dependencyMavenProject); classPathMavenProjects.add(dependencyMavenProject); } for (MavenProject classPathMavenProject : classPathMavenProjects) { for (Object object : classPathMavenProject.getCompileClasspathElements()) { String path = (String) object; getLog().debug("Class path element " + path); File file = new File(path); URI uri = file.toURI(); URL url = uri.toURL(); projectClassPath.add(url.toString()); } } getLog().debug("Project class path:"); for (String path : projectClassPath) { getLog().debug("\t" + path); } return projectClassPath; }
From source file:com.rebaze.maven.support.AetherUtils.java
License:Open Source License
public static ArtifactType newArtifactType(String id, ArtifactHandler handler) { return new DefaultArtifactType(id, handler.getExtension(), handler.getClassifier(), handler.getLanguage(), handler.isAddedToClasspath(), handler.isIncludesDependencies()); }
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 av a 2s. 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.fluidity.deployment.maven.DependenciesSupportImpl.java
License:Apache License
/** * Converts a Aether artifact to a Maven artifact. * * @param original the Maven artifact.//from www .j a v a 2 s. co m * * @return the Aether artifact. */ private static org.eclipse.aether.artifact.Artifact aetherArtifact(final Artifact original) { final String explicitVersion = original.getVersion(); final VersionRange versionRange = original.getVersionRange(); final String version = explicitVersion == null && versionRange != null ? versionRange.toString() : explicitVersion; final boolean isSystem = Artifact.SCOPE_SYSTEM.equals(original.getScope()); final String path = (original.getFile() != null) ? original.getFile().getPath() : ""; final Map<String, String> properties = isSystem ? Collections.singletonMap(ArtifactProperties.LOCAL_PATH, path) : null; final ArtifactHandler handler = original.getArtifactHandler(); final String extension = handler.getExtension(); final DefaultArtifactType type = new DefaultArtifactType(original.getType(), extension, handler.getClassifier(), handler.getLanguage(), handler.isAddedToClasspath(), handler.isIncludesDependencies()); final org.eclipse.aether.artifact.Artifact artifact = new org.eclipse.aether.artifact.DefaultArtifact( original.getGroupId(), original.getArtifactId(), original.getClassifier(), extension, version, properties, type); return artifact.setFile(original.getFile()); }
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()); }/*ww w . ja va 2s . c om*/ 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; }
From source file:org.sourcepit.common.maven.artifact.MavenArtifactUtils.java
License:Apache License
private static ArtifactType newArtifactType(String id, ArtifactHandler handler) { return new DefaultArtifactType(id, handler.getExtension(), handler.getClassifier(), handler.getLanguage(), handler.isAddedToClasspath(), handler.isIncludesDependencies()); }
From source file:ws.epigraph.maven.AbstractCompilingMojo.java
License:Apache License
private Collection<Source> getDependencySources() throws MojoExecutionException, IOException { Collection<Source> sources = new ArrayList<Source>(); for (Artifact artifact : project.getArtifacts()) { ArtifactHandler artifactHandler = artifact.getArtifactHandler(); if (artifactHandler.isAddedToClasspath()) { File artifactFile = artifact.getFile(); // TODO check artifact.getScope(); ??? if (artifactFile.canRead()) { if (artifactFile.isDirectory()) { Collection<FileSource> fileSources = new ArrayList<FileSource>(); addDirectorySources(fileSources, new File(artifactFile, ARTIFACTS_PATH_PREFIX)); sources.addAll(fileSources); } else if ("jar".equals(artifactHandler.getExtension())) { addSourcesFromJar(artifactFile, sources); } else { ; // ignore non-jar artifacts since epigraph is not producing these }//from www. j a v a 2 s.com } else { getLog().warn("Skipping " + artifact + " - '" + artifactFile + "' is not readable"); } } } if (dependsOnMainOutput()) { Collection<FileSource> fileSources = new ArrayList<FileSource>(); addDirectorySources(fileSources, new File(project.getBuild().getOutputDirectory(), ARTIFACTS_PATH_PREFIX)); sources.addAll(fileSources); } return sources; }