List of usage examples for org.apache.maven.project MavenProject getArtifacts
public Set<Artifact> getArtifacts()
From source file:org.sonatype.m2e.webby.internal.launch.ProjectClasspathContributor.java
License:Open Source License
@Override public void contribute(WarClasspath classpath, IProgressMonitor monitor) throws CoreException { SubMonitor pm = SubMonitor.convert(monitor, 100); try {/*from w ww . ja v a2s. c om*/ if (overlayConfig.getTargetPath().length() > 0) { return; } MavenProject mvnProject = mvnFacade.getMavenProject(pm.newChild(30)); IMaven mvn = MavenPlugin.getMaven(); MavenExecutionRequest mvnRequest = mvn.createExecutionRequest(pm.newChild(10)); MavenSession mvnSession = mvn.createSession(mvnRequest, mvnProject); WarConfiguration warConfig; try { warConfig = new WarConfigurationExtractor().getConfiguration(mvnFacade, mvnProject, mvnSession, pm.newChild(10)); } catch (CoreException e) { throw WebbyPlugin .newError("Could not read configuration of maven-war-plugin for overlay from project " + mvnProject.getId(), e); } PathSelector overlaySelector = new PathSelector(overlayConfig.getIncludes(), overlayConfig.getExcludes()); PathSelector packagingSelector = new PathSelector(warConfig.getPackagingIncludes(), warConfig.getPackagingExcludes()); PathCollector pathCollector = new PathCollector(null, null); String classesDir = warConfig.getClassesDirectory(); for (String classFile : pathCollector.collectFiles(classesDir)) { String targetPath = "WEB-INF/classes/" + classFile; if (packagingSelector.isSelected(targetPath)) { if (overlaySelector.isSelected(targetPath)) { classpath.addRuntimeClasspathEntry(new File(classesDir)); break; } } } OverlayClasspath overlayClasspath = new OverlayClasspath(classpath, packagingSelector, overlaySelector); FilenameMapper filenameMapper = new FilenameMapper(warConfig.getFilenameMapping()); Map<String, Artifact> targetPaths = filenameMapper.getTargetPaths(mvnProject.getArtifacts()); for (Map.Entry<String, Artifact> e : targetPaths.entrySet()) { File file = e.getValue().getFile(); if (file == null) { continue; } String targetPath = e.getKey(); if (overlayClasspath.registerTargetPath(targetPath, 0)) { classpath.addRuntimeClasspathEntry(file); } } new WarClasspathPopulator().populate(overlayClasspath, mvnProject, warConfig, false, pm.newChild(50)); } finally { if (monitor != null) { monitor.done(); } } }
From source file:org.sonatype.m2e.webby.internal.util.WarUtils.java
License:Open Source License
public static Map<String, Artifact> getOverlayArtifacts(MavenProject mvnProject) { Map<String, Artifact> overlayArtifacts = new LinkedHashMap<String, Artifact>(); for (Artifact artifact : mvnProject.getArtifacts()) { String type = artifact.getType(); if ("war".equals(type) || "zip".equals(type)) { overlayArtifacts.put(artifact.getDependencyConflictId(), artifact); }//from w ww.j a va 2 s . co m } return overlayArtifacts; }
From source file:org.sourcepit.osgifier.maven.GenerateManifestMojo.java
License:Apache License
private ArtifactManifestBuilderRequest newManifestRequest(final MavenProject project) { final ArtifactManifestBuilderRequest request = new ArtifactManifestBuilderRequest(); request.setArtifact(project.getArtifact()); if (!skipSource) { request.setSourceArtifact(newProjectArtifact(project, sourceClassifier, "jar")); }/*from w ww.j ava 2 s.c om*/ request.getDependencies().addAll(project.getArtifacts()); final PropertiesSource options = chainOptions(getMojoConfigurationOptions(), toOptions(project.getProperties()), toOptions(System.getProperties())); request.setOptions(options); request.setSymbolicName(symbolicName); request.setTimestamp(buildContext.getSession().getStartTime()); request.setHeaderModifications(headerModifications); return request; }
From source file:org.springframework.ide.eclipse.boot.properties.editor.maven.EnableJdtAptM2EProjectConfigurator.java
License:Open Source License
protected boolean shouldEnableApt(MavenProject mp) { for (Artifact a : mp.getArtifacts()) { if ("org.springframework.boot".equals(a.getGroupId()) && "spring-boot-configuration-processor".equals(a.getArtifactId())) { return true; }/*from w w w.java 2 s .co m*/ } return false; }
From source file:org.springframework.ide.eclipse.maven.internal.core.SpringProjectConfigurator.java
License:Open Source License
/** * {@inheritDoc}//from www . jav a2s .co m */ @Override protected void doConfigure(MavenProject mavenProject, IProject project, ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { // first look for a dependency on spring-core boolean found = false; for (Artifact art : mavenProject.getArtifacts()) { if (art.getArtifactId().equals("spring-core") && art.getGroupId().equals("org.springframework")) { SpringCoreUtils.addProjectNature(project, SpringCore.NATURE_ID, monitor); found = true; } } // if none, then look for the eclipse maven plugin if (!found) { configureNature(project, mavenProject, SpringCore.NATURE_ID, true, monitor); } }
From source file:org.springframework.ide.eclipse.roo.ui.internal.maven.LegacyRooProjectConfigurator.java
License:Open Source License
/** * {@inheritDoc}//w w w .j a v a 2 s . c o m */ @Override protected void doConfigure(MavenProject mavenProject, IProject project, ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { // first apply Roo project nature boolean hasNature = false; for (Artifact art : mavenProject.getArtifacts()) { if (art.getArtifactId().startsWith("org.springframework.roo") && art.getGroupId().equals("org.springframework.roo")) { SpringCoreUtils.addProjectNature(project, SpringCore.NATURE_ID, monitor); SpringCoreUtils.addProjectNature(project, RooCoreActivator.NATURE_ID, monitor); hasNature = true; } } if (!hasNature) { hasNature = (configureNature(project, mavenProject, SpringCore.NATURE_ID, true, monitor) && configureNature(project, mavenProject, RooCoreActivator.NATURE_ID, true, monitor)); } if (hasNature) { Artifact parent = mavenProject.getParentArtifact(); if (parent != null) { // traverse the parent chain IMavenProjectFacade facade = projectManager.getMavenProject(parent.getGroupId(), parent.getArtifactId(), parent.getVersion()); doConfigure(facade.getMavenProject(), facade.getProject(), request, monitor); } else { // open the Roo Shell for the project new OpenShellJob(project).schedule(); } } }
From source file:org.springframework.ide.eclipse.roo.ui.internal.maven.RooProjectConfigurator.java
License:Open Source License
/** * {@inheritDoc}//from w w w. j a va2s .c o m */ @Override protected void doConfigure(MavenProject mavenProject, IProject project, ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { // first apply Roo project nature boolean hasNature = false; for (Artifact art : mavenProject.getArtifacts()) { if (art.getArtifactId().startsWith("org.springframework.roo") && art.getGroupId().equals("org.springframework.roo")) { SpringCoreUtils.addProjectNature(project, SpringCore.NATURE_ID, monitor); SpringCoreUtils.addProjectNature(project, RooCoreActivator.NATURE_ID, monitor); hasNature = true; } } if (!hasNature) { hasNature = (configureNature(project, mavenProject, SpringCore.NATURE_ID, true, monitor) && configureNature(project, mavenProject, RooCoreActivator.NATURE_ID, true, monitor)); } if (hasNature) { Artifact parent = mavenProject.getParentArtifact(); if (parent != null) { // traverse the parent chain IMavenProjectFacade facade = projectManager.getMavenProject(parent.getGroupId(), parent.getArtifactId(), parent.getVersion()); if (facade != null && facade.getMavenProject() != null && facade.getProject() != null) { doConfigure(facade.getMavenProject(), facade.getProject(), request, monitor); } } else { // open the Roo Shell for the project new OpenShellJob(project).schedule(); } } }
From source file:org.springframework.ide.vscode.commons.maven.java.MavenProjectClasspath.java
License:Open Source License
private Set<Artifact> projectDependencies(MavenProject project) { return project == null ? Collections.emptySet() : project.getArtifacts(); }
From source file:org.vaadin.netbeans.impl.VaadinSupportImpl.java
License:Apache License
static Set<Artifact> getDependecies(Project project) { NbMavenProject nbMvnProject = project.getLookup().lookup(NbMavenProject.class); MavenProject mavenProject = nbMvnProject.getMavenProject(); return mavenProject.getArtifacts(); }
From source file:org.vaadin.netbeans.impl.WebVaadinSupportImpl.java
License:Apache License
private static Set<Artifact> getDependencies(Project project) { NbMavenProject nbMvnProject = project.getLookup().lookup(NbMavenProject.class); MavenProject mavenProject = nbMvnProject.getMavenProject(); return mavenProject.getArtifacts(); }