List of usage examples for org.apache.maven.artifact Artifact SCOPE_TEST
String SCOPE_TEST
To view the source code for org.apache.maven.artifact Artifact SCOPE_TEST.
Click Source Link
From source file:cn.wanghaomiao.maven.plugin.seimi.packaging.DependenciesAnalysisPackagingTask.java
License:Apache License
/** * {@inheritDoc}//ww w . j a v a2s .c om */ 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;/* w w w.jav a2 s. co 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.//from w ww . ja v a 2s . co 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.carrotgarden.maven.osgi.BaseMojo.java
License:BSD License
/** *///from w ww .ja va 2 s . c o m protected void addProjectDependencies(MavenProject project, String tab) { // getLog().warn("addProjectDependencies : " + project); @SuppressWarnings("unchecked") Set<Artifact> artifacts = project.getArtifacts(); // getLog().warn("artifacts.size : " + artifacts.size()); for (Artifact artifact : artifacts) { if (artifact.isOptional()) { continue; } if (Artifact.SCOPE_TEST.equals(artifact.getScope())) { continue; } provisionBundle(artifact, tab); } }
From source file:com.devexperts.qd.jspc.plugin.JspcMojo.java
License:Mozilla Public License
/** * Set up the execution classpath for Jasper. * /*www. ja v a2 s .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.dooioo.se.lorik.apidoclet.maven.plugin.JavadocUtil.java
License:Apache License
/** * Copy from {@link org.apache.maven.project.MavenProject#getCompileArtifacts()} * @param artifacts not null/*from w ww. j a v a 2 s. com*/ * @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; }/* ww w.jav a2s . c o m*/ if (artifact.isOptional()) { continue; } result.add(artifact); } return result; }
From source file:com.github.maven_nar.NarDownloadDependenciesMojo.java
License:Apache License
/** * List all the dependencies of the project. *//*from w w w.j a v a 2 s . com*/ @Override protected ScopeFilter getArtifactScopeFilter() { return new ScopeFilter(Artifact.SCOPE_TEST, null); }
From source file:com.github.maven_nar.NarIntegrationTestMojo.java
License:Apache License
private void addProvider(final SurefireBooter surefireBooter, final String provider, final String version, final Artifact filteredArtifact) throws ArtifactNotFoundException, ArtifactResolutionException { final Artifact providerArtifact = this.artifactFactory.createDependencyArtifact("org.apache.maven.surefire", provider, VersionRange.createFromVersion(version), "jar", null, Artifact.SCOPE_TEST); final ArtifactResolutionResult result = resolveArtifact(filteredArtifact, providerArtifact); for (final Object element : result.getArtifacts()) { final Artifact artifact = (Artifact) element; getLog().debug("Adding to surefire test classpath: " + artifact.getFile().getAbsolutePath()); surefireBooter.addSurefireClassPathUrl(artifact.getFile().getAbsolutePath()); }// www .j a v a 2s .c om }
From source file:com.github.maven_nar.NarTestCompileMojo.java
License:Apache License
/** * List the dependencies needed for tests compilations, those dependencies are * used to get the include paths needed//from w w w .j a v a 2s . c o m * for compilation and to get the libraries paths and names needed for * linking. */ @Override protected ScopeFilter getArtifactScopeFilter() { // Was Artifact.SCOPE_TEST - runtime?? return new ScopeFilter(Artifact.SCOPE_TEST, null); }