List of usage examples for org.apache.maven.project MavenProject getArtifactId
public String getArtifactId()
From source file:ar.com.fluxit.jqa.JQAMavenPlugin.java
License:Open Source License
private void doExecute(File buildDirectory, File outputDirectory, File testOutputDirectory, MavenProject project, File sourceDir, String sourceJavaVersion) throws IntrospectionException, TypeFormatException, FileNotFoundException, IOException, RulesContextFactoryException, ExporterException { // Add project dependencies to classpath getLog().debug("Adding project dependencies to classpath"); final Collection<File> classPath = new ArrayList<File>(); @SuppressWarnings("unchecked") final Set<Artifact> artifacts = project.getArtifacts(); for (final Artifact artifact : artifacts) { classPath.add(artifact.getFile()); }//from w ww.j av a 2s .c o m // Add project classes to classpath if (outputDirectory != null) { classPath.add(outputDirectory); } if (testOutputDirectory != null) { classPath.add(testOutputDirectory); } getLog().debug("Adding project classes to classpath"); final Collection<File> classFiles = FileUtils.listFiles(buildDirectory, new SuffixFileFilter(RulesContextChecker.CLASS_SUFFIX), TrueFileFilter.INSTANCE); // Reads the config file getLog().debug("Reading rules context"); final RulesContext rulesContext = RulesContextFactoryLocator.getRulesContextFactory() .getRulesContext(getRulesContextFile().getPath()); getLog().debug("Checking rules for " + classFiles.size() + " files"); final CheckingResult checkingResult = RulesContextChecker.INSTANCE.check(project.getArtifactId(), classFiles, classPath, rulesContext, new File[] { sourceDir }, sourceJavaVersion, getLogger()); CheckingResultExporter.INSTANCE.export(checkingResult, project.getArtifactId(), getResultsDirectory(), this.xslt, getLogger()); }
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 ww . j a v a2 s . c o m*/ } 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 w ww .j ava 2s . 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.UpdateDependencies.java
License:Apache License
@Override public final void alterModel(final Context updateContext) { final MavenProject project = updateContext.getProject(); final Model model = updateContext.getModel(); for (final Dependency dependency : determineDependencies(model)) { if (isNotBlank(dependency.getVersion())) { final String substitutedVersionOrNull = substitution.getActualVersionOrNull(project, dependency); if (isSnapshot(substitutedVersionOrNull)) { try { final String versionToDependOn = updateContext.getVersionToDependOn(dependency.getGroupId(), dependency.getArtifactId()); dependency.setVersion(versionToDependOn); updateContext.setDependencyUpdated(); log.debug(format(" Dependency on %s rewritten to version %s", dependency.getArtifactId(), versionToDependOn)); } catch (final UnresolvedSnapshotDependencyException e) { updateContext.addError(ERROR_FORMAT, project.getArtifactId(), e.artifactId, substitutedVersionOrNull); }//from w w w. j a va2s.c o m } else { log.debug(format(" Dependency on %s kept at version %s", dependency.getArtifactId(), substitutedVersionOrNull)); } } } }
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 {//from ww w.j ava 2s . 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 .jav a 2s . com 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.sourcepond.maven.release.pom.ValidateNoSnapshotPlugins.java
License:Apache License
@Override public void alterModel(final Context updateContext) { final MavenProject project = updateContext.getProject(); for (final Plugin plugin : project.getModel().getBuild().getPlugins()) { final String substitutedVersionOrNull = substitution.getActualVersionOrNull(project, plugin); if (isSnapshot(substitutedVersionOrNull) && !isMultiModuleReleasePlugin(plugin)) { updateContext.addError(ERROR_FORMAT, project.getArtifactId(), plugin.getArtifactId(), substitutedVersionOrNull); }/*from w w w . ja va 2 s. c om*/ } }
From source file:ch.sourcepond.maven.release.reactor.DefaultReactorFactory.java
License:Apache License
@Override public Reactor newReactor() throws ReactorException { final DefaultReactor reactor = new DefaultReactor(log); final List<String> modulesToForceRelease = configuration.getModulesToForceRelease(); for (final MavenProject project : projects) { try {/*from w w w .ja v a 2s . c o m*/ final String relativePathToModule = rootProject.calculateModulePath(project); final String changedDependencyOrNull = reactor.getChangedDependencyOrNull(project); final VersionBuilder versionBuilder = versionBuilderFactory.newBuilder(); versionBuilder.setProject(project); versionBuilder.setChangedDependency(changedDependencyOrNull); if (!modulesToForceRelease.contains(project.getArtifactId())) { versionBuilder.setRelativePath(relativePathToModule); } reactor.addReleasableModule( new ReleasableModule(project, versionBuilder.build(), relativePathToModule)); } catch (final VersionException e) { throw new ReactorException(e, "Version could be created for project %s", project); } } return reactor.finalizeReleaseVersions(); }
From source file:ch.sourcepond.maven.release.version.BuildNumberFinder.java
License:Apache License
public long findBuildNumber(final MavenProject project, final String businessVersion) throws VersionException { final SortedSet<Long> prev = new TreeSet<>(); try {/*w w w . j ava 2 s. c om*/ for (final ProposedTag previousTag : repository.tagsForVersion(project.getArtifactId(), businessVersion)) { prev.add(previousTag.getBuildNumber()); } prev.addAll(repository.getRemoteBuildNumbers(project.getArtifactId(), businessVersion)); return prev.isEmpty() ? 0l : prev.last() + 1; } catch (final SCMException e) { throw new VersionException(e, "Build number could not be determined!"); } }
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 .java 2 s . 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(); } }