List of usage examples for org.apache.maven.project MavenProject getGroupId
public String getGroupId()
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.RadPlugin.java
License:Open Source License
/** * Utility method that locates a project producing the given artifact. * * @param artifact the artifact a project should produce. * @return <code>true</code> if the artifact is produced by a reactor projectart. */// w w w.j a v a 2 s. c o m protected boolean isAvailableAsAReactorProject(Artifact artifact) { if (this.reactorProjects != null && (Constants.PROJECT_PACKAGING_JAR.equals(artifact.getType()) || Constants.PROJECT_PACKAGING_EJB.equals(artifact.getType()) || Constants.PROJECT_PACKAGING_WAR.equals(artifact.getType()))) { for (Iterator iter = this.reactorProjects.iterator(); iter.hasNext();) { MavenProject reactorProject = (MavenProject) iter.next(); if (reactorProject.getGroupId().equals(artifact.getGroupId()) && reactorProject.getArtifactId().equals(artifact.getArtifactId())) { if (reactorProject.getVersion().equals(artifact.getVersion())) { return true; } else { getLog().info("Artifact " + artifact.getId() + " already available as a reactor project, but with different version. Expected: " + artifact.getVersion() + ", found: " + reactorProject.getVersion()); } } } } return false; }
From source file:com.alibaba.citrus.maven.eclipse.base.ide.AbstractIdeSupportMojo.java
License:Apache License
/** * Checks the list of reactor projects to see if the artifact is included. * * @param artifact the artifact to check if it is in the reactor * @return the reactor project or null if it is not in the reactor *///from w w w . jav a 2 s. co m protected MavenProject getReactorProject(Artifact artifact) { if (reactorProjects != null) { for (Iterator iter = reactorProjects.iterator(); iter.hasNext();) { MavenProject reactorProject = (MavenProject) iter.next(); if (reactorProject.getGroupId().equals(artifact.getGroupId()) && reactorProject.getArtifactId().equals(artifact.getArtifactId())) { if (reactorProject.getVersion().equals(artifact.getVersion())) { return reactorProject; } else { getLog().info("Artifact " + artifact.getId() + " already available as a reactor project, but with different version. Expected: " + artifact.getVersion() + ", found: " + reactorProject.getVersion()); } } } } return null; }
From source file:com.alibaba.citrus.maven.eclipse.base.ide.IdeUtils.java
License:Apache License
public static String getProjectName(String template, MavenProject project) { return getProjectName(template, project.getGroupId(), project.getArtifactId(), project.getVersion()); }
From source file:com.ardoq.mavenImport.ProjectSync.java
/** * Returns Ardoq project component ID/*from w w w.ja v a 2 s .c o m*/ * @param project * @return */ private String syncProject(MavenProject project) { String componentName = project.getName(); if (componentNameIdMap.containsKey(componentName)) { return componentNameIdMap.get(componentName); } Component ardoqProjectComponent = new Component(componentName, ardoqSync.getWorkspace().getId(), "", COMPONENT_TYPE_PROJECT); ardoqProjectComponent.setDescription(buildProjectDescription(project)); Map<String, Object> fields = new HashMap<String, Object>(); fields.put("groupId", project.getGroupId()); fields.put("artifactId", project.getArtifactId()); fields.put("version", project.getVersion()); mavenUtil.addLicense(project, fields); ardoqProjectComponent.setFields(fields); ardoqProjectComponent = ardoqSync.addComponent(ardoqProjectComponent); componentNameIdMap.put(componentName, ardoqProjectComponent.getId()); Map<String, Integer> refTypes = ardoqSync.getModel().getReferenceTypes(); syncProjectArtifact(project, ardoqProjectComponent, refTypes); syncProjectParent(project, ardoqProjectComponent, refTypes); syncProjectModules(project, ardoqProjectComponent, refTypes); return ardoqProjectComponent.getId(); }
From source file:com.ardoq.mavenImport.ProjectSync.java
/** * NB! only modules named the same as the artifact will be synced * @param project/*from w w w. j a v a 2s. c om*/ * @param ardoqProjectComponent * @param refTypes * @throws DependencyCollectionException */ private void syncProjectModules(MavenProject project, Component ardoqProjectComponent, Map<String, Integer> refTypes) { for (String module : project.getModules()) { try { String groupId = project.getGroupId(); String artifactId = module; String version = project.getVersion(); String id = groupId + ":" + artifactId + ":" + version; String moduleComponentId = syncProject(id); if (moduleComponentId != null) { int refType = refTypes.get("Module"); Reference ref = new Reference(ardoqSync.getWorkspace().getId(), "artifact", ardoqProjectComponent.getId(), moduleComponentId, refType); ardoqSync.addReference(ref); } else { System.err.println("Error adding reference from " + ardoqProjectComponent.getId() + " " + moduleComponentId); } } catch (ArtifactResolutionException e) { System.out.println("***************************************************************"); System.out.println("* Error syncing Maven module " + module + " of " + project.getName()); System.out.println("* This tool assumes that the module name equals the artifactId. "); System.out.println("* -> ignoring and carrying on.. "); System.out.println("***************************************************************"); } } }
From source file:com.ardoq.mavenImport.ProjectSync.java
private void syncProjectArtifact(MavenProject project, Component ardoqProjectComponent, Map<String, Integer> refTypes) { int refType = refTypes.get("Dependency"); DefaultArtifact artifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), "pom", project.getVersion());/*from w ww . j a v a 2 s .com*/ syncProjectDependencies(artifact); String sourceId = ardoqProjectComponent.getId(); String targetId = artifactSync.getComponentIdFromArtifact(artifact); if (sourceId != null && targetId != null) { System.out.println("adding reference from project to artifact " + sourceId + " " + ardoqProjectComponent.getName() + " " + targetId + " " + artifact.getArtifactId()); Reference ref = new Reference(ardoqSync.getWorkspace().getId(), "artifact", ardoqProjectComponent.getId(), targetId, refType); ardoqSync.addReference(ref); } else { System.err.println("Error creating reference from " + ardoqProjectComponent.getName() + " to " + artifact.getArtifactId() + ".. sourceId: " + sourceId + ", targetId: " + targetId); } }
From source file:com.blackducksoftware.integration.hub.jenkins.maven.HubMavenReporter.java
License:Open Source License
private BuildArtifact createBuildArtifact(final MavenProject pom) { final BuildArtifact artifact = new BuildArtifact(); artifact.setType("org.apache.maven"); artifact.setGroup(pom.getGroupId()); artifact.setArtifact(pom.getArtifactId()); artifact.setVersion(pom.getVersion()); artifact.setId(pom.getId());//from w w w. j av a2s. c om return artifact; }
From source file:com.ccoe.build.profiler.profile.DiscoveryProfile.java
License:Apache License
private MavenProject getParentProject(final MavenProject project, final String groupId, final String artifactId) { if (project == null) { return null; }/* w w w. j a v a 2 s. com*/ if (project.getGroupId().equals(groupId) && project.getArtifactId().equals(artifactId)) { return project; } if (project.getParent() == null) { return null; } return getParentProject(project.getParent(), groupId, artifactId); }
From source file:com.ccoe.build.profiler.profile.ProjectProfile.java
License:Apache License
public ProjectProfile(Context c, MavenProject project, ExecutionEvent event) { super(new Timer(), event, c); this.project = project; this.phaseProfiles = new ArrayList<PhaseProfile>(); this.projectGroupId = project.getGroupId(); this.projectArtifactId = project.getArtifactId(); this.projectVersion = project.getVersion(); if (event != null) { projectName = event.getProject().getName(); projectId = event.getProject().getId(); }/*from w ww.j a v a2 s .co m*/ if (getSession() != null) { p.setName(projectName); p.setPayload(projectId); p.setStartTime(new Date(this.getTimer().getStartTime())); ProcessHelper.praseProjectPayload(projectId, p); getSession().getProjects().put(projectName, p); getSession().setCurrentProject(p); } }
From source file:com.cloudbees.maven.license.CompleterDelegate.java
License:Open Source License
private String toString(MavenProject p) { return p.getGroupId() + ":" + p.getArtifactId() + ":" + p.getVersion(); }