List of usage examples for org.apache.maven.project MavenProject getDescription
public String getDescription()
From source file:aQute.bnd.maven.reporter.plugin.entries.mavenproject.CommonInfoPlugin.java
private String extractDescription(MavenProject project) { return project.getDescription() != null && !project.getDescription().isEmpty() ? project.getDescription() : null;/*from w ww. jav a 2s. co m*/ }
From source file:com.ardoq.mavenImport.ProjectSync.java
private String buildProjectDescription(MavenProject project) { // TODO: add url, organization, developers, contributors, mailing lists, etc.. String description = ""; if (project.getDescription() != null && project.getDescription().trim().length() > 0) { description += "#Description\n\n" + project.getDescription(); }//w w w . ja va2 s. c o m if (!project.getLicenses().isEmpty()) { description += "\nLicenses\n----\n\n"; for (License license : project.getLicenses()) { description += " * " + license.getName() + "\n"; } } if (!project.getDevelopers().isEmpty()) { description += "\nDevelopers\n----\n\n"; for (Developer developer : project.getDevelopers()) { description += " * " + developer.getName() + " (" + developer.getEmail() + ")\n"; } } return description; }
From source file:com.effectivemaven.centrepoint.maven.repository.CentralRepositoryService.java
License:Apache License
public Project retrieveProject(String groupId, String artifactId, String version) throws RepositoryException { // get the project from the repository Artifact artifact = artifactFactory.createProjectArtifact(groupId, artifactId, version); MavenProject mavenProject; try {/*from w w w .j av a 2s .co m*/ mavenProject = projectBuilder.buildFromRepository(artifact, Collections.singletonList(repository), localRepository); } catch (ProjectBuildingException e) { throw new RepositoryException(e.getMessage(), e); } // populate the Centrepoint model from the Maven project Project project = new Project(); project.setId(MavenCoordinates.constructProjectId(groupId, artifactId)); project.setVersion(version); MavenCoordinates coordinates = new MavenCoordinates(); coordinates.setGroupId(groupId); coordinates.setArtifactId(artifactId); project.addExtensionModel(coordinates); project.setDescription(mavenProject.getDescription()); project.setName(mavenProject.getName()); if (mavenProject.getCiManagement() != null) { project.setCiManagementUrl(mavenProject.getCiManagement().getUrl()); } if (mavenProject.getIssueManagement() != null) { project.setIssueTrackerUrl(mavenProject.getIssueManagement().getUrl()); } if (mavenProject.getScm() != null) { project.setScmUrl(mavenProject.getScm().getUrl()); } project.setUrl(mavenProject.getUrl()); DistributionManagement distMgmt = mavenProject.getDistributionManagement(); if (distMgmt != null) { project.setRepositoryUrl(distMgmt.getRepository().getUrl()); project.setSnapshotRepositoryUrl(distMgmt.getSnapshotRepository().getUrl()); } return project; }
From source file:com.groupcdg.maven.tidesdk.GenerateMojo.java
License:Apache License
private Collection<String> createManifest() { MavenProject project = getProject(); return Arrays.asList("#appname: " + getEscapedName(), "#publisher: " + getPublisher(project), "#url: " + getUrl(project), "#image: " + getIcon(), "#appid: " + project.getGroupId() + '.' + project.getArtifactId(), "#desc: " + project.getDescription(), "#type: desktop", "#guid: " + UUID.randomUUID(), "runtime:" + getSdkVersion(), "app:" + getSdkVersion(), "codec:" + getSdkVersion(), "database:" + getSdkVersion(), "filesystem:" + getSdkVersion(), "media:" + getSdkVersion(), "monkey:" + getSdkVersion(), "network:" + getSdkVersion(), "platform:" + getSdkVersion(), "process:" + getSdkVersion(), "ui:" + getSdkVersion(), "worker:" + getSdkVersion()); }
From source file:com.rodiontsev.maven.plugins.buildinfo.providers.ProjectInfoProvider.java
License:Apache License
public Map<String, String> getInfo(MavenProject project, BuildInfoMojo mojo) { // finite set of project properties we expose final Map<String, String> props = new LinkedHashMap<String, String>(65); props.put("project.id", project.getId()); props.put("project.groupId", project.getGroupId()); props.put("project.artifactId", project.getArtifactId()); props.put("project.version", project.getVersion()); props.put("project.name", project.getName()); props.put("project.description", project.getDescription()); props.put("project.modelVersion", project.getModelVersion()); props.put("project.inceptionYear", project.getInceptionYear()); props.put("project.packaging", project.getPackaging()); props.put("project.url", project.getUrl()); final MavenProject parent = project.getParent(); if (parent != null) { props.put("project.parent.id", parent.getId()); props.put("project.parent.groupId", parent.getGroupId()); props.put("project.parent.artifactId", parent.getArtifactId()); props.put("project.parent.version", parent.getVersion()); props.put("project.parent.name", parent.getName()); props.put("project.parent.description", parent.getDescription()); props.put("project.parent.modelVersion", parent.getModelVersion()); props.put("project.parent.inceptionYear", parent.getInceptionYear()); props.put("project.parent.packaging", parent.getPackaging()); props.put("project.parent.url", parent.getUrl()); }/*from ww w. j a va 2 s . c o m*/ // properties the user wants Map<String, String> info = new LinkedHashMap<String, String>(); for (String propertyName : mojo.getProjectProperties()) { String prop = props.get(propertyName); if (prop != null) { info.put(propertyName, prop); } } info.put("build.time", DateFormatUtils.format(new Date(), "d MMMM yyyy, HH:mm:ss ZZ", Locale.ENGLISH)); return info; }
From source file:com.rodiontsev.maven.plugins.buildinfo.providers.ProjectPropertiesProvider.java
License:Apache License
public Map<String, String> getInfo(MavenProject project, BuildInfoMojo mojo) { // finite set of project properties we expose final Map<String, String> projectProperties = new LinkedHashMap<String, String>(65); projectProperties.put("project.id", project.getId()); projectProperties.put("project.groupId", project.getGroupId()); projectProperties.put("project.artifactId", project.getArtifactId()); projectProperties.put("project.version", project.getVersion()); projectProperties.put("project.name", project.getName()); projectProperties.put("project.description", project.getDescription()); projectProperties.put("project.modelVersion", project.getModelVersion()); projectProperties.put("project.inceptionYear", project.getInceptionYear()); projectProperties.put("project.packaging", project.getPackaging()); projectProperties.put("project.url", project.getUrl()); MavenProject parent = project.getParent(); if (parent != null) { projectProperties.put("project.parent.id", parent.getId()); projectProperties.put("project.parent.groupId", parent.getGroupId()); projectProperties.put("project.parent.artifactId", parent.getArtifactId()); projectProperties.put("project.parent.version", parent.getVersion()); projectProperties.put("project.parent.name", parent.getName()); projectProperties.put("project.parent.description", parent.getDescription()); projectProperties.put("project.parent.modelVersion", parent.getModelVersion()); projectProperties.put("project.parent.inceptionYear", parent.getInceptionYear()); projectProperties.put("project.parent.packaging", parent.getPackaging()); projectProperties.put("project.parent.url", parent.getUrl()); }/* w w w. j a v a2 s.c o m*/ Map<String, String> info = new LinkedHashMap<String, String>(); new InfoWriter().write(info, mojo.getProjectProperties(), new PropertyMapper() { @Override public String mapProperty(String propertyName) { return projectProperties.get(propertyName); } }); return info; }
From source file:com.sun.enterprise.module.maven.OSGiPackager.java
License:Open Source License
/** * Reads information from the POM and the artifact archive to configure * the OSGi manifest entries. Returns a new set of entries if the archive * does not already have manifest entries, else it uses the existing entries * map. If any of the attribute already exists, then * it skips its processing honoring user's request. It uses the following * rules:/* w w w .java 2 s.c o m*/ * * Bundle-SymbolicName is assumed to be "${groupId}.${artifactId}" * Bundle-Version is derived from "${pom.version}" * using {@link VersionTranslator#MavenToOSGi(String)} * Bundle-Description is assumed to be "${pom.description}". * Bundle-Vendor is assumed to be "${pom.organization.name}". * Require-Bundle is populated by values read from pom dependencies * Note: * There is no support for Export-Package yet. * It sets Bundle-ManifestVersion as 2 which indicates OSGi r4 bundle. * * @param pom The Maven project object * @param archive The archive that is being built * @param classesDirectory output for javac * @return Manifest entries * @throws java.io.IOException */ public Map<String, String> configureOSGiManifest(MavenProject pom, MavenArchiveConfiguration archive, File classesDirectory) throws IOException { Map<String, String> entries; if (archive != null) entries = archive.getManifestEntries(); else entries = new HashMap<String, String>(); if (entries.get(BUNDLE_MANIFESTVERSION) == null) { // 2 indicates compliance with r4, note: there is no value called 1 entries.put(BUNDLE_MANIFESTVERSION, "2"); } if (entries.get(BUNDLE_NAME) == null) { // Bundle-Name is a human readable localizable name that can contain spaces entries.put(BUNDLE_NAME, pom.getName()); } if (entries.get(BUNDLE_SYMBOLICNAME) == null) { // OSGi convention is to use reverse domain name for SymbolicName, hence use . entries.put(BUNDLE_SYMBOLICNAME, pom.getGroupId() + '.' + pom.getArtifactId()); } if (entries.get(BUNDLE_VERSION) == null) { entries.put(BUNDLE_VERSION, VersionTranslator.MavenToOSGi(pom.getVersion())); } if (entries.get(BUNDLE_DESCRIPTION) == null) { if (pom.getDescription() != null) entries.put(BUNDLE_DESCRIPTION, pom.getDescription()); } if (entries.get(BUNDLE_VENDOR) == null) { if (pom.getOrganization() != null && pom.getOrganization().getName() != null) entries.put(BUNDLE_VENDOR, pom.getOrganization().getName()); } // Handle Require-Bundle. if (entries.get(REQUIRE_BUNDLE) == null) { String requiredBundles = generateRequireBundleHeader(discoverRequiredBundles(pom)); if (requiredBundles.length() > 0) { entries.put(REQUIRE_BUNDLE, requiredBundles); } } // Handle Export-Package if (entries.get(EXPORT_PACKAGE) == null) { List<ExportedPackage> packages = discoverPackages(classesDirectory); // don't use version until we resolve split package issues in GF String exportPackages = generateExportPackageHeader(packages, null); if (exportPackages.length() > 0) { entries.put(EXPORT_PACKAGE, exportPackages); } } return entries; }
From source file:com.torchmind.maven.plugins.attribution.AttributionMojo.java
License:Apache License
/** * Creates an attribution object using a root artifact and its listed dependencies. * @param artifact the maven project.//from w ww . ja va 2s. c o m * @param dependencies the dependencies. * @return the attribution. */ @Nonnull public static AttributionDocument createAttribution(@Nonnull MavenProject artifact, @Nonnull List<Artifact> dependencies, @Nonnull List<Artifact> plugins) { return new AttributionDocument(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getName(), artifact.getDescription(), artifact.getUrl(), artifact.getLicenses().stream().map(AttributionMojo::createLicense).collect(Collectors.toList()), artifact.getDevelopers().stream().map(AttributionMojo::createDeveloper) .collect(Collectors.toList()), artifact.getContributors().stream().map(AttributionMojo::createDeveloper) .collect(Collectors.toList()), dependencies, plugins); }
From source file:com.torchmind.maven.plugins.attribution.AttributionMojo.java
License:Apache License
/** * Creates an artifact using a maven project. * @param artifact the maven project.//from w w w .j a v a2 s . c o m * @return the artifact. */ @Nonnull public static Artifact createArtifact(@Nonnull MavenProject artifact) { return new Artifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getName(), artifact.getDescription(), artifact.getUrl(), artifact.getLicenses().stream().map(AttributionMojo::createLicense).collect(Collectors.toList()), artifact.getDevelopers().stream().map(AttributionMojo::createDeveloper) .collect(Collectors.toList()), artifact.getContributors().stream().map(AttributionMojo::createDeveloper) .collect(Collectors.toList())); }
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 w w w .j a v a2s .c om*/ 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(); }