List of usage examples for org.apache.maven.project MavenProject getArtifactId
public String getArtifactId()
From source file:com.willowtreeapps.saguaro.maven.MavenLicenseResolver.java
License:Apache License
@Override public Set<LicenseDependency> resolveLicenseDependencies() throws PluginException { Set<Artifact> deps = projectHelper.getArtifacts(); Set<LicenseDependency> licenseDependencies = new LinkedHashSet<LicenseDependency>(); for (Artifact artifact : deps) { MavenProject depProject = projectHelper.buildFromRepository(artifact); Dependency dependency = new Dependency(depProject.getGroupId(), depProject.getArtifactId()); List<org.apache.maven.model.License> licenseList = depProject.getLicenses(); Set<LicenseInfo> licenses = new LinkedHashSet<LicenseInfo>(); for (org.apache.maven.model.License license : licenseList) { licenses.add(LicenseInfo.withUrl(license.getName(), license.getUrl())); }//from ww w . java 2s . c om licenseDependencies.add(new LicenseDependency(depProject.getName(), dependency, licenses)); } return licenseDependencies; }
From source file:com.xebia.mojo.dashboard.util.DashboardUtil.java
License:Apache License
/** * Determines the complete directory path to a module in the build, by traversing up the {@link MavenProject} tree. * The recursion stops if there is no parent, or if it has arrived at the execution root * ({@link MavenProject#isExecutionRoot()}). * * @param mavenProject The {@link MavenProject} to determine the path of. * * @return A String containing the directory path to the {@link MavenProject}. *///from w w w .j a va2 s. com public static String determineCompletePath(MavenProject mavenProject) { if ((mavenProject.getParent() != null) && mavenProject.getParent().getCollectedProjects().contains(mavenProject)) { return determineCompletePath(mavenProject.getParent()) + mavenProject.getArtifactId() + "/"; } return ""; }
From source file:de.adorsys.cmer.ProjectNamingConverntions.java
License:Apache License
private void checkGroupIdAndArifactOverlapping(MavenProject project, EnforcerRuleHelper helper) throws EnforcerRuleException { String[] groupParts = project.getGroupId().split("[.]"); String[] artifactParts = project.getArtifactId().split("[.]"); String lastPartGroup = groupParts[groupParts.length - 1]; String firstPartArtifactId = artifactParts[0]; if (!lastPartGroup.equals(firstPartArtifactId)) { throw new EnforcerRuleException( "The last fragment of the groupId does not macht the first part of the artifactId of artifact " + project.getArtifactId()); }// w w w . jav a 2s . c o m }
From source file:de.akquinet.innovation.continuous.UniqueVersionMojo.java
License:Apache License
public void updateReleaseProperties(String newVersion) throws IOException { Properties properties = new Properties(); File releaseFile = new File(project.getBasedir(), "release.properties"); if (releaseFile.exists()) { FileInputStream fis = new FileInputStream(releaseFile); properties.load(fis);//from ww w. j a va2 s . c o m IOUtils.closeQuietly(fis); } properties.put("scm.tag", project.getArtifactId() + "-" + newVersion); String oldVersion = project.getVersion(); // For all projects set: //project.rel.org.myCompany\:projectA=1.2 //project.dev.org.myCompany\:projectA=1.3-SNAPSHOT for (MavenProject project : reactor) { properties.put("project.rel." + project.getGroupId() + ":" + project.getArtifactId(), newVersion); properties.put("project.dev." + project.getGroupId() + ":" + project.getArtifactId(), oldVersion); } FileOutputStream fos = new FileOutputStream(releaseFile); properties.store(fos, "File edited by the continuous-version-maven-plugin"); IOUtils.closeQuietly(fos); }
From source file:de.eacg.ecs.plugin.ScanAndTransferMojo.java
private boolean isPrivateComponent(MavenProject project) { for (String pc : getPrivateComponents()) { String compareString = project.getGroupId(); if (pc.contains(":")) { compareString += ':' + project.getArtifactId(); }//from www .j a v a2 s .c o m boolean result = pc.equals(compareString); if (result) { return true; } } return false; }
From source file:de.eacg.ecs.plugin.ScanAndTransferMojo.java
private Dependency mapDependency(DependencyNode node, Map<ComponentId, Map.Entry<MavenProject, String[]>> projectLookup) { Dependency.Builder builder = new Dependency.Builder(); Artifact artifact = node.getArtifact(); ComponentId artifactId = ComponentId.create(artifact); Map.Entry<MavenProject, String[]> projectLicensesPair = projectLookup.get(artifactId); // try fallback to artifact baseVersion, (for example because a snapshot is locked ) if (projectLicensesPair == null) { projectLicensesPair = projectLookup.get(ComponentId.createFallback(artifact)); }//from www . j av a 2 s. c o m if (projectLicensesPair == null) { getLog().error("Something weird happened: no Project found for artifact: " + artifactId); return null; } MavenProject project = projectLicensesPair.getKey(); String[] licensesArr = projectLicensesPair.getValue(); builder.setName(project.getName()).setDescription(project.getDescription()) .setKey("mvn:" + project.getGroupId() + ':' + project.getArtifactId()) .addVersion(project.getVersion()).setHomepageUrl(project.getUrl()); if (isPrivateComponent(project)) { builder.setPrivate(true); } try { File file = artifact.getFile(); if (file != null) { builder.setChecksum("sha-1:" + ChecksumCreator.createChecksum(file)); } else { Artifact af = findProjectArtifact(artifact); if (af != null && af.getFile() != null) { builder.setChecksum("sha-1:" + ChecksumCreator.createChecksum(af.getFile())); } else { getLog().warn( "Could not generate checksum - no file specified: " + ComponentId.create(artifact)); } } } catch (NoSuchAlgorithmException | IOException e) { getLog().warn("Could not generate checksum: " + e.getMessage()); } if (licensesArr != null && (licensesArr.length != 1 || !LicenseMap.UNKNOWN_LICENSE_MESSAGE.equals(licensesArr[0]))) { for (String license : licensesArr) { builder.addLicense(license); } } for (DependencyNode childNode : node.getChildren()) { Dependency dep = mapDependency(childNode, projectLookup); if (dep != null) { builder.addDependency(dep); } } return builder.buildDependency(); }
From source file:de.lightful.maven.plugins.drools.impl.dependencies.DependencyLoader.java
License:Apache License
private Dependency createDependencyFrom(MavenProject project) { final String artifactType = project.getPackaging(); org.sonatype.aether.artifact.Artifact artifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), EMPTY_CLASSIFIER, fileExtensionOf(artifactType), project.getVersion()); return new Dependency(artifact, WellKnownNames.SCOPE_COMPILE); }
From source file:fr.brouillard.oss.jgitver.GAV.java
License:Apache License
/** * Builds a GAV object from the given MavenProject object. * // ww w. j av a 2 s . co m * @param project the project to extract info from * @return a new GAV object */ public static GAV from(MavenProject project) { return new GAV(project.getGroupId(), project.getArtifactId(), project.getVersion()); }
From source file:fr.fastconnect.factory.tibco.bw.maven.BWLifecycleParticipant.java
License:Apache License
private List<MavenProject> prepareProjects(List<MavenProject> projects, MavenSession session) throws MavenExecutionException { List<MavenProject> result = new ArrayList<MavenProject>(); ProjectBuildingRequest projectBuildingRequest = session.getProjectBuildingRequest(); for (MavenProject mavenProject : projects) { logger.debug("project: " + mavenProject.getGroupId() + ":" + mavenProject.getArtifactId()); List<String> oldActiveProfileIds = projectBuildingRequest.getActiveProfileIds(); try {// ww w. ja v a 2 s.com List<String> activeProfileIds = activateProfilesWithProperties(mavenProject, oldActiveProfileIds); if (activeProfileIds.size() != oldActiveProfileIds.size()) { projectBuildingRequest.setActiveProfileIds(activeProfileIds); if (mavenProject.getFile() != null) { List<File> files = new ArrayList<File>(); files.add(mavenProject.getFile()); List<ProjectBuildingResult> results = null; try { results = projectBuilder.build(files, true, projectBuildingRequest); } catch (ProjectBuildingException e) { } for (ProjectBuildingResult projectBuildingResult : results) { mavenProject = projectBuildingResult.getProject(); } } } } finally { projectBuildingRequest.setActiveProfileIds(oldActiveProfileIds); } if (mavenProject.getPackaging().startsWith(AbstractBWMojo.BWEAR_TYPE) || "true".equals(propertiesManager.getPropertyValue("enableBWLifecycle"))) { addTIBCODependenciesToPlugin(mavenProject, logger); } result.add(mavenProject); } return result; }
From source file:fr.fastconnect.factory.tibco.bw.maven.InitializeMojo.java
License:Apache License
protected static File getParent(MavenProject project, Log logger) throws IOException, XmlPullParserException { File result = null;//from w w w.j ava2s . c o m MavenProject parent = project.getParent(); if (parent == null) { return result; // no parent: return null } File parentPOM = parent.getFile(); File parentBasedir = null; if (parentPOM != null && parentPOM.getParentFile() != null && parentPOM.getParentFile().exists() && parentPOM.getParentFile().isDirectory()) { parentBasedir = parentPOM.getParentFile(); } if (parentPOM != null) { logger.debug("parentPOM: " + parentPOM.getAbsolutePath()); } while (parentBasedir != null && parentBasedir.exists()) { logger.debug("parentBasedir: " + parentBasedir.getAbsolutePath()); if (findParentPath(parentBasedir, logger)) { logger.debug("parentFound"); result = parentBasedir; break; } logger.debug("parentNotFound"); if (parent != null) { logger.debug(parent.getArtifactId()); parentBasedir = parent.getParentFile(); // use <relativePath> to retrieve real parent file if (parentBasedir == null && parent.getParent() != null) { parentBasedir = parent.getParent().getFile(); } if (parentBasedir != null) { logger.debug(parentBasedir.getAbsolutePath()); } if (parentBasedir != null && parentBasedir.exists() && parentBasedir.isFile()) { parentBasedir = parentBasedir.getParentFile(); } parent = parent.getParent(); } } return result; }