List of usage examples for org.apache.maven.project MavenProject getArtifactId
public String getArtifactId()
From source file:io.reactiverse.vertx.maven.plugin.mojos.PackageMojo.java
License:Apache License
public static String computeOutputName(MavenProject project, String classifier) { String finalName = project.getBuild().getFinalName(); if (finalName != null) { if (finalName.endsWith(".jar")) { finalName = finalName.substring(0, finalName.length() - 4); }//from www. j a va 2s . c om if (classifier != null && !classifier.isEmpty()) { finalName += "-" + classifier; } finalName += ".jar"; return finalName; } else { finalName = project.getArtifactId() + "-" + project.getVersion(); if (classifier != null && !classifier.isEmpty()) { finalName += "-" + classifier; } finalName += ".jar"; return finalName; } }
From source file:io.sarl.maven.docs.AbstractDocumentationMojo.java
License:Apache License
private Properties createProjectProperties() { final Properties props = new Properties(); final MavenProject prj = this.session.getCurrentProject(); props.put("project.groupId", prj.getGroupId()); //$NON-NLS-1$ props.put("project.artifactId", prj.getArtifactId()); //$NON-NLS-1$ props.put("project.basedir", prj.getBasedir()); //$NON-NLS-1$ props.put("project.description", prj.getDescription()); //$NON-NLS-1$ props.put("project.id", prj.getId()); //$NON-NLS-1$ props.put("project.inceptionYear", prj.getInceptionYear()); //$NON-NLS-1$ props.put("project.name", prj.getName()); //$NON-NLS-1$ props.put("project.version", prj.getVersion()); //$NON-NLS-1$ props.put("project.url", prj.getUrl()); //$NON-NLS-1$ props.put("project.encoding", this.encoding); //$NON-NLS-1$ return props; }
From source file:io.siddhi.doc.gen.core.MkdocsGitHubPagesDeployMojo.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { // Finding the root maven project MavenProject rootMavenProject = mavenProject; while (rootMavenProject.getParent() != null && rootMavenProject.getParent().getBasedir() != null) { rootMavenProject = rootMavenProject.getParent(); }//from ww w . j a va 2 s. c o m // Setting the relevant modules target directory if not set by user String moduleTargetPath; if (moduleTargetDirectory != null) { moduleTargetPath = moduleTargetDirectory.getAbsolutePath(); } else { moduleTargetPath = mavenProject.getBuild().getDirectory(); } // Setting the mkdocs config file path if not set by user if (mkdocsConfigFile == null) { mkdocsConfigFile = new File(rootMavenProject.getBasedir() + File.separator + Constants.MKDOCS_CONFIG_FILE_NAME + Constants.YAML_FILE_EXTENSION); } // Setting the documentation output directory if not set by user String docGenBasePath; if (docGenBaseDirectory != null) { docGenBasePath = docGenBaseDirectory.getAbsolutePath(); } else { docGenBasePath = rootMavenProject.getBasedir() + File.separator + Constants.DOCS_DIRECTORY; } // Setting the home page file name if not set by user File homePageFile; if (homePageFileName == null) { homePageFile = new File(docGenBasePath + File.separator + Constants.HOMEPAGE_FILE_NAME + Constants.MARKDOWN_FILE_EXTENSION); } else { homePageFile = new File(docGenBasePath + File.separator + homePageFileName); } // Setting the readme file name if not set by user if (readmeFile == null) { readmeFile = new File(rootMavenProject.getBasedir() + File.separator + Constants.README_FILE_NAME + Constants.MARKDOWN_FILE_EXTENSION); } // Setting the home page template file path if not set by user if (homePageTemplateFile == null) { homePageTemplateFile = new File(rootMavenProject.getBasedir() + File.separator + Constants.README_FILE_NAME + Constants.MARKDOWN_FILE_EXTENSION); } // Retrieving metadata List<NamespaceMetaData> namespaceMetaDataList; try { namespaceMetaDataList = DocumentationUtils.getExtensionMetaData(moduleTargetPath, mavenProject.getRuntimeClasspathElements(), getLog()); } catch (DependencyResolutionRequiredException e) { throw new MojoFailureException("Unable to resolve dependencies of the project", e); } // Generating the documentation if (namespaceMetaDataList.size() > 0) { DocumentationUtils.generateDocumentation(namespaceMetaDataList, docGenBasePath, mavenProject.getVersion(), getLog()); DocumentationUtils.updateHeadingsInMarkdownFile(homePageTemplateFile, homePageFile, rootMavenProject.getArtifactId(), mavenProject.getVersion(), namespaceMetaDataList); DocumentationUtils.updateHeadingsInMarkdownFile(readmeFile, readmeFile, rootMavenProject.getArtifactId(), mavenProject.getVersion(), namespaceMetaDataList); } // Delete snapshot files DocumentationUtils.removeSnapshotAPIDocs(mkdocsConfigFile, docGenBasePath, getLog()); // Updating the links in the home page to the mkdocs config try { updateAPIPagesInMkdocsConfig(mkdocsConfigFile, docGenBasePath); } catch (FileNotFoundException e) { getLog().warn("Unable to find mkdocs configuration file: " + mkdocsConfigFile.getAbsolutePath() + ". Mkdocs configuration file not updated."); } // Deploying the documentation if (DocumentationUtils.generateMkdocsSite(mkdocsConfigFile, getLog())) { // Creating the credential provider fot Git String scmUsername = System.getenv(Constants.SYSTEM_PROPERTY_SCM_USERNAME_KEY); String scmPassword = System.getenv(Constants.SYSTEM_PROPERTY_SCM_PASSWORD_KEY); if (scmUsername == null && scmPassword == null) { getLog().info("SCM_USERNAME and SCM_PASSWORD not defined!"); } String url = null; Scm scm = rootMavenProject.getScm(); if (scm != null) { url = scm.getUrl(); } // Deploying documentation DocumentationUtils.updateDocumentationOnGitHub(docGenBasePath, mkdocsConfigFile, readmeFile, mavenProject.getVersion(), getLog()); DocumentationUtils.deployMkdocsOnGitHubPages(mavenProject.getVersion(), rootMavenProject.getBasedir(), url, scmUsername, scmPassword, getLog()); } else { getLog().warn("Unable to generate documentation. Skipping documentation deployment."); } }
From source file:io.sundr.maven.GenerateBomMojo.java
License:Apache License
private void build(MavenSession session, MavenProject project, List<MavenProject> allProjects, GoalSet goals) throws MojoExecutionException { session.setProjects(allProjects);// w w w .j a v a 2 s .c om ProjectIndex projectIndex = new ProjectIndex(session.getProjects()); try { ReactorBuildStatus reactorBuildStatus = new ReactorBuildStatus( new BomDependencyGraph(session.getProjects())); ReactorContext reactorContext = new ReactorContextFactory(new MavenVersion(mavenVersion)).create( session.getResult(), projectIndex, Thread.currentThread().getContextClassLoader(), reactorBuildStatus, builder); List<TaskSegment> segments = segmentCalculator.calculateTaskSegments(session); for (TaskSegment segment : segments) { builder.buildProject(session, reactorContext, project, filterSegment(segment, goals)); } } catch (Throwable t) { throw new MojoExecutionException("Error building generated bom:" + project.getArtifactId(), t); } }
From source file:io.takari.maven.builder.smart.SmartBuilderImpl.java
License:Apache License
private String projectGA(MavenProject project) { return project.getGroupId() + ":" + project.getArtifactId(); }
From source file:io.takari.maven.builder.smart.SmartBuilderImpl.java
License:Apache License
private void appendBuildMetrics(StringBuilder result, List<MavenProject> projects) { for (MavenProject project : projects) { if (result.length() > 0) { result.append("\n "); }// ww w.j a va2s . c om final BuildMetrics metrics = projectsBuildMetrics.getBuildMetrics(project); final long serviceTime = metrics.getMetricMillis(Timer.SERVICETIME_MS); final long queueTime = metrics.getMetricMillis(Timer.QUEUETIME_MS); result.append(project.getGroupId()).append(':').append(project.getArtifactId()); result.append(' ').append(serviceTime).append(' ').append(queueTime); } }
From source file:io.takari.maven.plugins.jar.Jar.java
License:Open Source License
private Iterable<Entry> jarManifestSource(MavenProject project) throws IOException { Manifest manifest = new Manifest(); Attributes main = manifest.getMainAttributes(); main.putValue("Manifest-Version", "1.0"); main.putValue("Archiver-Version", "Provisio Archiver"); main.putValue("Created-By", "Takari Inc."); main.putValue("Built-By", System.getProperty("user.name")); main.putValue("Build-Jdk", System.getProperty("java.version")); main.putValue("Specification-Title", project.getArtifactId()); main.putValue("Specification-Version", project.getVersion()); main.putValue("Implementation-Title", project.getArtifactId()); main.putValue("Implementation-Version", project.getVersion()); main.putValue("Implementation-Vendor-Id", project.getGroupId()); File manifestFile = new File(project.getBuild().getDirectory(), "MANIFEST.MF"); if (!manifestFile.getParentFile().exists()) { manifestFile.getParentFile().mkdirs(); }/* w ww . ja va 2 s.c o m*/ ByteArrayOutputStream buf = new ByteArrayOutputStream(); manifest.write(buf); return singleton((Entry) new BytesEntry(MANIFEST_PATH, buf.toByteArray())); }
From source file:io.takari.maven.plugins.jar.Jar.java
License:Open Source License
protected Entry pomPropertiesSource(MavenProject project) throws IOException { String entryName = String.format("META-INF/maven/%s/%s/pom.properties", project.getGroupId(), project.getArtifactId()); ByteArrayOutputStream buf = new ByteArrayOutputStream(); Properties properties = new Properties(); properties.setProperty("groupId", project.getGroupId()); properties.setProperty("artifactId", project.getArtifactId()); properties.setProperty("version", project.getVersion()); PropertiesWriter.write(properties, null, buf); return new BytesEntry(entryName, buf.toByteArray()); }
From source file:io.takari.maven.timeline.buildevents.BuildEventListener.java
License:Apache License
private Execution key(ExecutionEvent event) { final MojoExecution mojo = event.getMojoExecution(); final MavenProject project = event.getProject(); return new Execution(project.getGroupId(), project.getArtifactId(), mojo.getLifecyclePhase(), mojo.getGoal(), mojo.getExecutionId()); }
From source file:io.takari.maven.workspace.GenerationsWorkspaceReader.java
License:Apache License
@Inject public GenerationsWorkspaceReader(MavenSession session) { String forceArtifactResolutionFromReactor = session.getSystemProperties() .getProperty("maven.forceArtifactResolutionFromReactor"); if (forceArtifactResolutionFromReactor != null && forceArtifactResolutionFromReactor.equals("true")) { allowArtifactsWithoutAFileToBeResolvedInTheReactor = Boolean .parseBoolean(forceArtifactResolutionFromReactor); }// w w w.ja va 2 s. c o m // // Right now this is only enabled for the maven-eclipse-plugin // String resolveFromWorkspaceProperty = session.getSystemProperties() .getProperty("maven.workspaceResolutionEnabled"); if (resolveFromWorkspaceProperty != null && resolveFromWorkspaceProperty.equals("true")) { workspaceResolutionEnabled = Boolean.parseBoolean(resolveFromWorkspaceProperty); } // // Buildspace // buildProjects = session.getProjectMap(); buildProjectsByGA = new HashMap<String, List<MavenProject>>(); for (MavenProject project : buildProjects.values()) { String key = ArtifactUtils.versionlessKey(project.getGroupId(), project.getArtifactId()); List<MavenProject> projects = buildProjectsByGA.get(key); if (projects == null) { projects = new ArrayList<MavenProject>(1); buildProjectsByGA.put(key, projects); } projects.add(project); } // // Workspace // workspaceProjects = getProjectMap(session.getAllProjects()); workspaceProjectsByGA = new HashMap<String, List<MavenProject>>(); for (MavenProject project : workspaceProjects.values()) { String key = ArtifactUtils.versionlessKey(project.getGroupId(), project.getArtifactId()); List<MavenProject> projects = workspaceProjectsByGA.get(key); if (projects == null) { projects = new ArrayList<MavenProject>(1); workspaceProjectsByGA.put(key, projects); } projects.add(project); } repository = new WorkspaceRepository("reactor", new HashSet<String>(buildProjects.keySet())); }