List of usage examples for org.apache.maven.project MavenProject getGroupId
public String getGroupId()
From source file:br.com.anteros.restdoc.maven.plugin.util.ResourceResolver.java
License:Apache License
@SuppressWarnings("unchecked") public static List<JavadocBundle> resolveDependencyJavadocBundles(final SourceResolverConfig config) throws IOException { final List<JavadocBundle> bundles = new ArrayList<JavadocBundle>(); final Map<String, MavenProject> projectMap = new HashMap<String, MavenProject>(); if (config.reactorProjects() != null) { for (final MavenProject p : config.reactorProjects()) { projectMap.put(key(p.getGroupId(), p.getArtifactId()), p); }//w w w . j av a 2 s . c om } final List<Artifact> artifacts = config.project().getTestArtifacts(); final List<Artifact> forResourceResolution = new ArrayList<Artifact>(artifacts.size()); for (final Artifact artifact : artifacts) { final String key = key(artifact.getGroupId(), artifact.getArtifactId()); final MavenProject p = projectMap.get(key); if (p != null) { bundles.addAll(resolveBundleFromProject(config, p, artifact)); } else { forResourceResolution.add(artifact); } } bundles.addAll(resolveBundlesFromArtifacts(config, forResourceResolution)); return bundles; }
From source file:br.com.anteros.restdoc.maven.plugin.util.ResourceResolver.java
License:Apache License
@SuppressWarnings("unchecked") public static List<String> resolveDependencySourcePaths(final SourceResolverConfig config) throws ArtifactResolutionException, ArtifactNotFoundException { final List<String> dirs = new ArrayList<String>(); final Map<String, MavenProject> projectMap = new HashMap<String, MavenProject>(); if (config.reactorProjects() != null) { for (final MavenProject p : config.reactorProjects()) { projectMap.put(key(p.getGroupId(), p.getArtifactId()), p); }//from ww w . j av a 2 s .com } final List<Artifact> artifacts = config.project().getTestArtifacts(); final List<Artifact> forResourceResolution = new ArrayList<Artifact>(artifacts.size()); for (final Artifact artifact : artifacts) { final String key = key(artifact.getGroupId(), artifact.getArtifactId()); final MavenProject p = projectMap.get(key); if (p != null) { dirs.addAll(resolveFromProject(config, p, artifact)); } else { forResourceResolution.add(artifact); } } dirs.addAll(resolveFromArtifacts(config, forResourceResolution)); return dirs; }
From source file:ch.sourcepond.maven.release.pom.UpdateModel.java
License:Apache License
@Override public void alterModel(final Context updateContext) { final MavenProject project = updateContext.getProject(); final Model model = updateContext.getModel(); final boolean needsOwnVersion = isBlank(model.getVersion()) && updateContext.hasNotChanged(model.getParent()) && updateContext.dependencyUpdated(); updateContext.setNeedsOwnVersion(needsOwnVersion); // Do only update version on model when it is explicitly set. Otherwise, // the version of the parent is used. if (isNotBlank(model.getVersion()) || needsOwnVersion) { try {/*w w w.ja v a 2 s . c om*/ model.setVersion(updateContext.getVersionToDependOn(project.getGroupId(), project.getArtifactId())); } catch (final UnresolvedSnapshotDependencyException e) { updateContext.addError(ERROR_FORMAT, project); } } }
From source file:ch.sourcepond.maven.release.pom.UpdateParent.java
License:Apache License
@Override public void alterModel(final Context updateContext) { final MavenProject project = updateContext.getProject(); final Model model = updateContext.getModel(); final MavenProject parent = project.getParent(); if (parent != null && isSnapshot(parent.getVersion())) { try {// w ww .ja va 2 s . c o m final String versionToDependOn = updateContext.getVersionToDependOn(parent.getGroupId(), parent.getArtifactId()); model.getParent().setVersion(versionToDependOn); log.debug(format(" Parent %s rewritten to version %s", parent.getArtifactId(), versionToDependOn)); } catch (final UnresolvedSnapshotDependencyException e) { updateContext.addError(ERROR_FORMAT, project.getArtifactId(), e.artifactId, parent.getVersion()); } } }
From source file:ch.sventschui.maven.visualizer.VisualizerMojo.java
License:Apache License
public void execute() throws MojoExecutionException { this.createOutputDir(); for (String directory : this.directories) { this.poms.addAll(FileUtils.listFiles(new File(directory), new PomFileFilter(), new TargetFileFilter())); }/*ww w. j ava 2s . c o m*/ for (File pom : this.poms) { Model model = null; FileReader reader = null; MavenXpp3Reader mavenreader = new MavenXpp3Reader(); try { reader = new FileReader(pom); model = mavenreader.read(reader); model.setPomFile(pom); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (XmlPullParserException e) { // TODO Auto-generated catch block e.printStackTrace(); } MavenProject project = new MavenProject(model); MavenArtifact base = new MavenArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion()); if (this.filter.matches(base)) { this.store.addArtifact(base); for (Dependency artifact : project.getDependencies()) { MavenArtifact dependency = new MavenArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()); if (this.filter.matches(dependency)) { this.store.addArtifact(dependency); this.store.addRelationship(base, dependency); } } } } try { FileWriter fstream = new FileWriter(new File(this.outputDir, "test.json")); BufferedWriter out = new BufferedWriter(fstream); out.write(this.store.toJSON()); out.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:cn.wanghaomiao.maven.plugin.seimi.packaging.ClassesPackagingTask.java
License:Apache License
/** * @param context The warPackingContext. * @throws MojoExecutionException In casae of an error. *///from ww w . j a v a2s. co m protected void generateJarArchive(WarPackagingContext context) throws MojoExecutionException { MavenProject project = context.getProject(); ArtifactFactory factory = context.getArtifactFactory(); Artifact artifact = factory.createBuildArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), "jar"); String archiveName; try { archiveName = getArtifactFinalName(context, artifact); } catch (InterpolationException e) { throw new MojoExecutionException("Could not get the final name of the artifact [" + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + "]", e); } final String targetFilename = LIB_PATH + archiveName; if (context.getWebappStructure().registerFile(currentProjectOverlay.getId(), targetFilename)) { final File libDirectory = new File(context.getWebappDirectory(), LIB_PATH); final File jarFile = new File(libDirectory, archiveName); final ClassesPackager packager = new ClassesPackager(); packager.packageClasses(context.getClassesDirectory(), jarFile, context.getJarArchiver(), context.getSession(), project, context.getArchive()); } else { context.getLog().warn( "Could not generate archive classes file [" + targetFilename + "] has already been copied."); } }
From source file:co.leantechniques.maven.BuildInformation.java
License:Apache License
public Artifact getTopLevelProject() { MavenProject project = session.getTopLevelProject(); return new Project(project.getGroupId(), project.getArtifactId(), project.getVersion()); }
From source file:co.leantechniques.maven.BuildInformation.java
License:Apache License
private Project projectOf(ExecutionEvent event) { MavenProject mavenProject = event.getProject(); Project currentProject = new Project(mavenProject.getGroupId(), mavenProject.getArtifactId(), mavenProject.getVersion());//from w ww. j a v a2 s .com return projects.get(projects.indexOf(currentProject)); }
From source file:co.leantechniques.maven.BuildInformation.java
License:Apache License
private void initializeProjects(MavenSession session) { for (MavenProject mavenProject : session.getProjects()) { projects.add(new Project(mavenProject.getGroupId(), mavenProject.getArtifactId(), mavenProject.getVersion())); }//from ww w .ja v a 2s.co m }
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.EclipsePlugin.java
License:Apache License
/** * If this is a war module peek into the reactor an search for an ear module that defines the context root of this * module./*from w ww . jav a 2s . c om*/ * * @param config config to save the context root. */ private void collectWarContextRootsFromReactorEarConfiguration(EclipseWriterConfig config) { if (reactorProjects != null && wtpContextName == null && Constants.PROJECT_PACKAGING_WAR.equals(project.getPackaging())) { for (Iterator iter = reactorProjects.iterator(); iter.hasNext();) { MavenProject reactorProject = (MavenProject) iter.next(); if (Constants.PROJECT_PACKAGING_EAR.equals(reactorProject.getPackaging())) { Xpp3Dom[] warDefinitions = IdeUtils.getPluginConfigurationDom(reactorProject, JeeUtils.ARTIFACT_MAVEN_EAR_PLUGIN, new String[] { "modules", "webModule" }); for (int index = 0; index < warDefinitions.length; index++) { Xpp3Dom groupId = warDefinitions[index].getChild("groupId"); Xpp3Dom artifactId = warDefinitions[index].getChild("artifactId"); Xpp3Dom contextRoot = warDefinitions[index].getChild("contextRoot"); if (groupId != null && artifactId != null && contextRoot != null && groupId.getValue() != null && artifactId.getValue() != null && contextRoot.getValue() != null) { getLog().info("Found context root definition for " + groupId.getValue() + ":" + artifactId.getValue() + " " + contextRoot.getValue()); if (project.getArtifactId().equals(artifactId.getValue()) && project.getGroupId().equals(groupId.getValue())) { config.setContextName(contextRoot.getValue()); } } else { getLog().info("Found incomplete ear configuration in " + reactorProject.getGroupId() + ":" + reactorProject.getGroupId() + " found " + warDefinitions[index].toString()); } } } } } if (config.getContextName() == null && Constants.PROJECT_PACKAGING_WAR.equals(project.getPackaging())) { if (wtpContextName == null) { config.setContextName(project.getArtifactId()); } else if ("ROOT".equals(wtpContextName)) { config.setContextName(""); } else { config.setContextName(wtpContextName); } } }