List of usage examples for org.apache.maven.artifact Artifact SCOPE_PROVIDED
String SCOPE_PROVIDED
To view the source code for org.apache.maven.artifact Artifact SCOPE_PROVIDED.
Click Source Link
From source file:cn.wanghaomiao.maven.plugin.seimi.packaging.DependenciesAnalysisPackagingTask.java
License:Apache License
/** * {@inheritDoc}/* w w w . ja v a2 s . co m*/ */ protected void handleDependency(WarPackagingContext context, Dependency dependency, String notBundledMessage, String warOrZipMessage, String standardMessage, boolean removeFile) { if (Artifact.SCOPE_PROVIDED.equals(dependency.getScope()) || Artifact.SCOPE_TEST.equals(dependency.getScope()) || dependency.isOptional()) { context.getLog().debug(notBundledMessage); } else { handleDependencyScope(context, dependency, warOrZipMessage, standardMessage, removeFile); } }
From source file:com.adviser.maven.GraphArtifactCollector.java
License:Apache License
private void checkScopeUpdate(ResolutionNode farthest, ResolutionNode nearest, List listeners) { boolean updateScope = false; Artifact farthestArtifact = farthest.getArtifact(); Artifact nearestArtifact = nearest.getArtifact(); if (Artifact.SCOPE_RUNTIME.equals(farthestArtifact.getScope()) && (Artifact.SCOPE_TEST.equals(nearestArtifact.getScope()) || Artifact.SCOPE_PROVIDED.equals(nearestArtifact.getScope()))) { updateScope = true;//from w w w. j a v a2 s.c o m } if (Artifact.SCOPE_COMPILE.equals(farthestArtifact.getScope()) && !Artifact.SCOPE_COMPILE.equals(nearestArtifact.getScope())) { updateScope = true; } // current POM rules all if (nearest.getDepth() < 2 && updateScope) { updateScope = false; fireEvent(ResolutionListener.UPDATE_SCOPE_CURRENT_POM, listeners, nearest, farthestArtifact); } if (updateScope) { fireEvent(ResolutionListener.UPDATE_SCOPE, listeners, nearest, farthestArtifact); // previously we cloned the artifact, but it is more effecient to // just update the scope // if problems are later discovered that the original object needs // its original scope value, cloning may // again be appropriate nearestArtifact.setScope(farthestArtifact.getScope()); } }
From source file:com.alibaba.citrus.maven.eclipse.base.ide.AbstractIdeSupportMojo.java
License:Apache License
/** * Resolve project dependencies. Manual resolution is needed in order to avoid resolution of multiproject artifacts * (if projects will be linked each other an installed jar is not needed) and to avoid a failure when a jar is * missing./* w w w . ja v a 2 s . c o m*/ * * @return resolved IDE dependencies, with attached jars for non-reactor dependencies * @throws MojoExecutionException if dependencies can't be resolved */ protected IdeDependency[] doDependencyResolution() throws MojoExecutionException { if (ideDeps == null) { if (resolveDependencies) { MavenProject project = getProject(); ArtifactRepository localRepo = getLocalRepository(); List deps = getProject().getDependencies(); // Collect the list of resolved IdeDependencies. List dependencies = new ArrayList(); if (deps != null) { Map managedVersions = createManagedVersionMap(getArtifactFactory(), project.getId(), project.getDependencyManagement()); ArtifactResolutionResult artifactResolutionResult = null; try { List listeners = new ArrayList(); if (logger.isDebugEnabled()) { listeners.add(new DebugResolutionListener(logger)); } listeners.add(new WarningResolutionListener(logger)); artifactResolutionResult = artifactCollector.collect(getProjectArtifacts(), project.getArtifact(), managedVersions, localRepo, project.getRemoteArtifactRepositories(), getArtifactMetadataSource(), null, listeners); } catch (ArtifactResolutionException e) { getLog().debug(e.getMessage(), e); getLog().error( Messages.getString("AbstractIdeSupportMojo.artifactresolution", new Object[] { //$NON-NLS-1$ e.getGroupId(), e.getArtifactId(), e.getVersion(), e.getMessage() })); // if we are here artifactResolutionResult is null, create a project without dependencies but // don't fail // (this could be a reactor projects, we don't want to fail everything) // Causes MECLIPSE-185. Not sure if it should be handled this way?? return new IdeDependency[0]; } // keep track of added reactor projects in order to avoid duplicates Set emittedReactorProjectId = new HashSet(); for (Iterator i = artifactResolutionResult.getArtifactResolutionNodes().iterator(); i .hasNext();) { ResolutionNode node = (ResolutionNode) i.next(); int dependencyDepth = node.getDepth(); Artifact art = node.getArtifact(); // don't resolve jars for reactor projects if (hasToResolveJar(art)) { try { artifactResolver.resolve(art, node.getRemoteRepositories(), localRepository); } catch (ArtifactNotFoundException e) { getLog().debug(e.getMessage(), e); getLog().warn(Messages.getString("AbstractIdeSupportMojo.artifactdownload", //$NON-NLS-1$ new Object[] { e.getGroupId(), e.getArtifactId(), e.getVersion(), e.getMessage() })); } catch (ArtifactResolutionException e) { getLog().debug(e.getMessage(), e); getLog().warn(Messages.getString("AbstractIdeSupportMojo.artifactresolution", new Object[] { //$NON-NLS-1$ e.getGroupId(), e.getArtifactId(), e.getVersion(), e.getMessage() })); } } boolean includeArtifact = true; if (getExcludes() != null) { String artifactFullId = art.getGroupId() + ":" + art.getArtifactId(); if (getExcludes().contains(artifactFullId)) { getLog().info("excluded: " + artifactFullId); includeArtifact = false; } } if (includeArtifact && (!(getUseProjectReferences() && isAvailableAsAReactorProject(art)) || emittedReactorProjectId.add(art.getGroupId() + '-' + art.getArtifactId()))) { // the following doesn't work: art.getArtifactHandler().getPackaging() always returns "jar" // also // if the packaging specified in pom.xml is different. // osgi-bundle packaging is provided by the felix osgi plugin // eclipse-plugin packaging is provided by this eclipse plugin // String packaging = art.getArtifactHandler().getPackaging(); // boolean isOsgiBundle = "osgi-bundle".equals( packaging ) || "eclipse-plugin".equals( // packaging ); // we need to check the manifest, if "Bundle-SymbolicName" is there the artifact can be // considered // an osgi bundle boolean isOsgiBundle = false; String osgiSymbolicName = null; if (art.getFile() != null) { JarFile jarFile = null; try { jarFile = new JarFile(art.getFile(), false, ZipFile.OPEN_READ); Manifest manifest = jarFile.getManifest(); if (manifest != null) { osgiSymbolicName = manifest.getMainAttributes() .getValue(new Attributes.Name("Bundle-SymbolicName")); } } catch (IOException e) { getLog().info("Unable to read jar manifest from " + art.getFile()); } finally { if (jarFile != null) { try { jarFile.close(); } catch (IOException e) { // ignore } } } } isOsgiBundle = osgiSymbolicName != null; IdeDependency dep = new IdeDependency(art.getGroupId(), art.getArtifactId(), art.getVersion(), art.getClassifier(), useProjectReference(art), Artifact.SCOPE_TEST.equals(art.getScope()), Artifact.SCOPE_SYSTEM.equals(art.getScope()), Artifact.SCOPE_PROVIDED.equals(art.getScope()), art.getArtifactHandler().isAddedToClasspath(), art.getFile(), art.getType(), isOsgiBundle, osgiSymbolicName, dependencyDepth, getProjectNameForArifact(art)); // no duplicate entries allowed. System paths can cause this problem. if (!dependencies.contains(dep)) { dependencies.add(dep); } } } // @todo a final report with the list of // missingArtifacts? } ideDeps = (IdeDependency[]) dependencies.toArray(new IdeDependency[dependencies.size()]); } else { ideDeps = new IdeDependency[0]; } } return ideDeps; }
From source file:com.atlassian.maven.plugin.clover.CloverInstrumentInternalMojo.java
License:Apache License
private void addCloverDependencyToCompileClasspath() throws MojoExecutionException { Artifact cloverArtifact = findCloverArtifact(this.pluginArtifacts); if (cloverArtifact == null) { throw new MojoExecutionException("Couldn't find [" + CLOVER_CORE_GROUP_ID + ":" + CLOVER_CORE_ARTIFACT_ID + "] artifact in plugin dependencies"); }/*from w w w. j ava2s.c om*/ final String jarScope = scope == null ? Artifact.SCOPE_PROVIDED : scope; cloverArtifact = artifactFactory.createArtifact(cloverArtifact.getGroupId(), cloverArtifact.getArtifactId(), cloverArtifact.getVersion(), jarScope, cloverArtifact.getType()); try { this.artifactResolver.resolve(cloverArtifact, repositories, localRepository); } catch (AbstractArtifactResolutionException e) { throw new MojoExecutionException("Could not resolve the clover artifact ( " + cloverArtifact.getId() + " ) in the localRepository: " + localRepository.getUrl(), e); } addArtifactDependency(cloverArtifact); }
From source file:com.cubeia.maven.plugin.firebase.FirebaseRunPlugin.java
License:Apache License
private boolean isScopeProvided(Artifact a) { return a.getScope().equals(Artifact.SCOPE_PROVIDED); }
From source file:com.devexperts.qd.jspc.plugin.JspcMojo.java
License:Mozilla Public License
/** * Set up the execution classpath for Jasper. * //from w ww . j ava2s . c om * Put everything in the classesDirectory and all of the dependencies on the * classpath. * * @returns a list of the urls of the dependencies * @throws Exception */ private List<URL> setUpWebAppClassPath() throws Exception { //add any classes from the webapp List<URL> urls = new ArrayList<URL>(); String classesDir = classesDirectory.getCanonicalPath(); classesDir = classesDir + (classesDir.endsWith(File.pathSeparator) ? "" : File.separator); urls.add(Resource.toURL(new File(classesDir))); if (getLog().isDebugEnabled()) getLog().debug("Adding to classpath classes dir: " + classesDir); //add the dependencies of the webapp (which will form WEB-INF/lib) for (Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext();) { Artifact artifact = (Artifact) iter.next(); // Include runtime and compile time libraries if (!Artifact.SCOPE_TEST.equals(artifact.getScope()) && !Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) { String filePath = artifact.getFile().getCanonicalPath(); if (getLog().isDebugEnabled()) getLog().debug("Adding to classpath dependency file: " + filePath); urls.add(Resource.toURL(artifact.getFile())); } } return urls; }
From source file:com.devexperts.qd.jspc.plugin.JspcMojo.java
License:Mozilla Public License
private String setUpSysClassPath() throws Exception { StringBuffer buff = new StringBuffer(); //Put each of the plugin's artifacts onto the system classpath for jspc for (Iterator<Artifact> iter = pluginArtifacts.iterator(); iter.hasNext();) { Artifact pluginArtifact = iter.next(); if ("jar".equalsIgnoreCase(pluginArtifact.getType())) { if (getLog().isDebugEnabled()) { getLog().debug("Adding plugin artifact " + pluginArtifact); }/*from ww w. j av a2s . c o m*/ buff.append(pluginArtifact.getFile().getAbsolutePath()); if (iter.hasNext()) buff.append(File.pathSeparator); } } if (useProvidedScope) { for (Iterator<Artifact> iter = projectArtifacts.iterator(); iter.hasNext();) { Artifact artifact = iter.next(); if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) { //test to see if the provided artifact was amongst the plugin artifacts String path = artifact.getFile().getAbsolutePath(); if (!buff.toString().contains(path)) { if (buff.length() != 0) buff.append(File.pathSeparator); buff.append(path); if (getLog().isDebugEnabled()) { getLog().debug("Adding provided artifact: " + artifact); } } else { if (getLog().isDebugEnabled()) { getLog().debug("Skipping provided artifact: " + artifact); } } } } } return buff.toString(); }
From source file:com.dooioo.se.lorik.apidoclet.maven.plugin.JavadocUtil.java
License:Apache License
/** * Copy from {@link org.apache.maven.project.MavenProject#getCompileArtifacts()} * @param artifacts not null// w ww .j a va 2s. c om * @param withTestScope flag to include or not the artifacts with test scope * @return list of compile artifacts with or without test scope. */ protected static List<Artifact> getCompileArtifacts(Set<Artifact> artifacts, boolean withTestScope) { List<Artifact> list = new ArrayList<Artifact>(artifacts.size()); for (Artifact a : artifacts) { // TODO: classpath check doesn't belong here - that's the other method if (a.getArtifactHandler().isAddedToClasspath()) { // TODO: let the scope handler deal with this if (withTestScope) { if (Artifact.SCOPE_COMPILE.equals(a.getScope()) || Artifact.SCOPE_PROVIDED.equals(a.getScope()) || Artifact.SCOPE_SYSTEM.equals(a.getScope()) || Artifact.SCOPE_TEST.equals(a.getScope())) { list.add(a); } } else { if (Artifact.SCOPE_COMPILE.equals(a.getScope()) || Artifact.SCOPE_PROVIDED.equals(a.getScope()) || Artifact.SCOPE_SYSTEM.equals(a.getScope())) { list.add(a); } } } } return list; }
From source file:com.enonic.cms.maven.plugin.PackagePluginMojo.java
License:Apache License
private Set<Artifact> getNotProvidedDependencies() throws Exception { final Set<Artifact> result = new HashSet<Artifact>(); for (final Artifact artifact : getIncludedArtifacts()) { if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) || Artifact.SCOPE_TEST.equals(artifact.getScope())) { continue; }// w ww . j ava2 s .c om if (artifact.isOptional()) { continue; } result.add(artifact); } return result; }
From source file:com.github.lukaszkusek.maven.cobertura.project.ProjectHandler.java
License:Open Source License
private Artifact withProvidedScope(Artifact artifact) { return repositorySystem.createArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), Artifact.SCOPE_PROVIDED, artifact.getType()); }