List of usage examples for org.apache.maven.project MavenProject getBuild
public Build getBuild()
From source file:com.citytechinc.cq.component.maven.util.ComponentMojoUtil.java
License:Apache License
/** * Create a temporary archive file which will live alongside the constructed * project CQ5 Package archive./* ww w .java 2 s .com*/ * * @param project * @return The temporary archive file */ protected static File getTempArchiveFileForProject(MavenProject project) { File buildDirectory = new File(project.getBuild().getDirectory()); String zipFileName = project.getArtifactId() + "-" + project.getVersion() + "-temp.zip"; getLog().debug("Temp archive file name " + zipFileName); return new File(buildDirectory, zipFileName); }
From source file:com.collir24.policyextractor.PolicyExtractorReport.java
License:Apache License
@Override protected void executeReport(Locale locale) throws MavenReportException { ResourceBundle localizedResources = getBundle(locale); Set<String> policySet = new TreeSet<String>(); Sink sink = getSink();/* ww w. j a v a 2 s . c o m*/ sink.head(); sink.title(); sink.text(localizedResources.getString("report.pagetitle")); sink.title_(); sink.head_(); sink.body(); MavenProject project = getProject(); sink.sectionTitle1(); sink.text(localizedResources.getString("report.sectiontitle")); sink.sectionTitle1_(); Build build = project.getBuild(); sink.sectionTitle2(); sink.text(MessageFormat.format(localizedResources.getString("report.reportfor"), project.getName())); sink.sectionTitle2_(); sink.paragraph(); sink.text(localizedResources.getString("report.local.description")); sink.lineBreak(); sink.italic(); sink.text(localizedResources.getString("report.disclaimer")); sink.italic_(); sink.paragraph_(); Set<String> localProjectPolicySet = generateProjectPermissions(sink, project, build); generatePolicy(localProjectPolicySet, sink, null); policySet.addAll(localProjectPolicySet); sink.sectionTitle2(); sink.text(localizedResources.getString("report.allpermissions.title")); sink.sectionTitle2_(); sink.paragraph(); sink.text(localizedResources.getString("report.dependencies.description")); sink.paragraph_(); @SuppressWarnings("unchecked") Set<Artifact> artefacts = project.getArtifacts(); for (Artifact a : artefacts) { if (a.getScope().equals("test")) { continue; } JarFile jf; try { jf = new JarFile(a.getFile().getAbsolutePath()); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Can't open file at: " + a.getFile().getAbsolutePath(), e); continue; } localProjectPolicySet = generateArtifactPermissions(sink, a, jf); generatePolicy(localProjectPolicySet, sink, a.getFile().getName()); policySet.addAll(localProjectPolicySet); } sink.sectionTitle2(); sink.text(localizedResources.getString("report.generatedpolicy.title")); sink.sectionTitle2_(); sink.paragraph(); sink.text(localizedResources.getString("report.generatedpolicy.description")); sink.paragraph_(); generatePolicy(policySet, sink, null); sink.sectionTitle2(); sink.text(localizedResources.getString("report.visualization.title")); sink.sectionTitle2_(); sink.paragraph(); String graphFilePath = outputDirectory + "/policyextractor.png"; new VisualizationGenerator(new File(graphFilePath)).generateVisualization(permissionList); sink.rawText("<img src=\"policyextractor.png\" width=\"300\">"); // sink.figure(); // sink.figureGraphics("policyextractor.png"); // sink.figure_(); sink.link("policyextractor.gexf"); sink.text("Graph Source"); sink.link_(); sink.paragraph_(); sink.body_(); sink.flush(); sink.close(); }
From source file:com.datacoper.maven.util.MavenUtil.java
public static String getPathForPackage(MavenProject project, String packag) { String defaultPackage = project.getBuild().getSourceDirectory(); defaultPackage = ".".concat(defaultPackage != null ? defaultPackage : "src.main.java").concat("."); //defaultPackage = project.getBasedir().getPath().concat(".").concat(project.getArtifactId()).concat(defaultPackage); String path = defaultPackage.concat(packag).replace('.', File.separatorChar); return path;/*from ww w .j a va 2 s. co m*/ }
From source file:com.edugility.jpa.maven.plugin.ListEntityClassnamesMojo.java
License:Open Source License
/** * Returns this {@link ListEntityClassnamesMojo}'s best guess as to * its {@linkplain #getProject() related Maven project}'s * {@linkplain Build#getDirectory() build directory}. If this * {@link ListEntityClassnamesMojo} actually has a {@link * MavenProject} {@linkplain AbstractJPAMojo#getProject() * installed}, it will use the return value of that {@link * MavenProject}'s {@link MavenProject#getBuild() Build}'s * {@link Build#getDirectory() getDirectory()} method. Otherwise, it will * return the following://from w w w . j a v a 2 s.c o m * * <pre>System.getProperty("maven.project.build.directory", * System.getProperty("project.build.directory", * String.format("%1$s%2$starget", * System.getProperty("basedir", * System.getProperty("user.dir", ".")), * File.separator)));</pre> * * <p>This method never returns {@code null}.</p> * * @return the current project's <i>build directory</i> name; never * {@code null} */ public final String getProjectBuildDirectoryName() { String returnValue = null; final MavenProject project = this.getProject(); if (project != null) { final Build build = project.getBuild(); if (build != null) { final String buildDirectoryName = build.getDirectory(); if (buildDirectoryName != null) { returnValue = buildDirectoryName; } } } if (returnValue == null) { returnValue = System.getProperty("maven.project.build.directory", System.getProperty("project.build.directory", String.format("%1$s%2$starget", System.getProperty("basedir", System.getProperty("user.dir", ".")), File.separator))); } return returnValue; }
From source file:com.edugility.liquibase.maven.AssembleChangeLogMojo.java
License:Open Source License
/** * Returns a {@link Collection} of {@link URL}s representing the * locations of the given {@link Artifact}. * * <p>This method never returns {@code null}.</p> * * <h4>Design Notes</h4>//w ww . ja v a2 s .c o m * * <p>This method returns a {@link Collection} of {@link URL}s * instead of a single {@link URL} because an {@link Artifact} * representing the {@linkplain #getProject() current project being * built} has two conceptual locations for our purposes: the test * output directory and the build output directory. All other * {@link Artifact}s have exactly one location, <em>viz.</em> {@link * Artifact#getFile()}.</p> * * @param artifact the {@link Artifact} for which {@link URL}s * should be returned; may be {@code null} in which case an * {@linkplain Collection#emptySet() empty <code>Collection</code>} * will be returned * * @return a {@link Collection} of {@link URL}s; never {@code null} * * @exception MalformedURLException if an {@link Artifact}'s * {@linkplain Artifact#getFile() associated <code>File</code>} * could not be {@linkplain URI#toURL() converted into a * <code>URL</code>} * * @see Artifact#getFile() * * @see Build#getTestOutputDirectory() * * @see Build#getOutputDirectory() * * @see File#toURI() * * @see URI#toURL() */ private final Collection<? extends URL> toURLs(final Artifact artifact) throws MalformedURLException { Collection<URL> urls = null; if (artifact != null) { // If the artifact represents the current project itself, then // we need to look in the reactor first (i.e. the // project.build.testOutpuDirectory and the // project.build.outputDirectory areas), since a .jar file for // the project in all likelihood has not yet been created. final String groupId = artifact.getGroupId(); if (groupId != null) { final MavenProject project = this.getProject(); if (project != null && groupId.equals(project.getGroupId())) { final String artifactId = artifact.getArtifactId(); if (artifactId != null && artifactId.equals(project.getArtifactId())) { final Build build = project.getBuild(); if (build != null) { urls = new ArrayList<URL>(); urls.add(new File(build.getTestOutputDirectory()).toURI().toURL()); urls.add(new File(build.getOutputDirectory()).toURI().toURL()); } } } } // If on the other hand the artifact was just a garden-variety // direct or transitive dependency, then just add its file: URL // directly. if (urls == null) { final File file = artifact.getFile(); if (file != null) { final URI uri = file.toURI(); if (uri != null) { urls = Collections.singleton(uri.toURL()); } } } } if (urls == null) { urls = Collections.emptySet(); } return urls; }
From source file:com.edugility.maven.liquibase.LiquibaseChangeLogArtifactsProcessor.java
License:Open Source License
private final Collection<? extends URL> gatherProjectUrls(final MavenProject project, final Log log) throws ArtifactsProcessingException { Collection<URL> urls = null; if (project != null) { final Build build = project.getBuild(); if (build != null) { final Collection<? extends String> names = this.getChangeLogResourceNames(); if (names != null && !names.isEmpty()) { final String[] directoryNames = new String[] { build.getOutputDirectory(), build.getTestOutputDirectory() }; for (final String directoryName : directoryNames) { if (directoryName != null) { final File directory = new File(directoryName); if (directory.isDirectory()) { for (final String resourceName : names) { if (resourceName != null) { final File changeLogFile = new File(directory, resourceName); if (changeLogFile.isFile() && changeLogFile.canRead()) { if (urls == null) { urls = new ArrayList<URL>(2 * names.size()); } try { urls.add(changeLogFile.toURI().toURL()); } catch (final MalformedURLException wrapMe) { throw new ArtifactsProcessingException(wrapMe); } }/*from ww w .j a v a 2s.c o m*/ } } } } } } } } return urls; }
From source file:com.ericsson.tools.cpp.tools.settings.PluginSettingsImpl.java
License:Apache License
public PluginSettingsImpl(final MavenProject project, final Map<String, String> configuredSources, final File outputDirectory, final File testOutputDirectory) { this.project = project; this.outputDirectory = outputDirectory; this.testOutputDirectory = testOutputDirectory; this.sources = createSourcesMapping(configuredSources); this.extractedDependenciesDirectory = new File(project.getBuild().getDirectory(), "extracted-dependencies"); this.objBaseDirectory = new File(project.getBuild().getDirectory(), "obj"); this.testObjBaseDirectory = new File(project.getBuild().getDirectory(), "test-obj"); this.attachedOutputDirectory = new File(project.getBuild().getDirectory(), "attached"); this.testAttachedOutputDirectory = new File(project.getBuild().getDirectory(), "test-attached"); }
From source file:com.github.htfv.maven.plugins.buildconfigurator.extension.BuildConfiguratorExtension.java
License:Apache License
/** * Looks for Build Configurator plugin in the specified project. * * @param project//from www . j a v a 2s .c o m * project for which Build Configurator plugin shall be return. * * @return reference to the Build Configurator plugin or {@code null} if * Build Configurator was not configured for this project. */ private Plugin getPlugin(final MavenProject project) { for (final Plugin projectPlugin : project.getBuild().getPlugins()) { if (BUILD_CONFIGURATOR_GROUP_ID.equals(projectPlugin.getGroupId()) && BUILD_CONFIGURATOR_ARTIFACT_ID.equals(projectPlugin.getArtifactId())) { return projectPlugin; } } return null; }
From source file:com.github.lukaszkusek.maven.cobertura.files.WorkingDirectory.java
License:Open Source License
public WorkingDirectory(MavenProject project) { this.outputDirectory = new File(project.getBuild().getOutputDirectory()); this.coberturaDirectory = new File(project.getBuild().getDirectory(), COBERTURA_DIRECTORY_NAME); this.instrumentedClassesDirectory = new File(coberturaDirectory, INSTRUMENTED_CLASSES_DIRECTORY_NAME); this.dataFile = new File(coberturaDirectory, DATA_FILE_NAME); }
From source file:com.github.maven_nar.AbstractNarLayout.java
License:Apache License
protected final void attachNar(final ArchiverManager archiverManager, final MavenProjectHelper projectHelper, final MavenProject project, final String classifier, final File dir, final String include) throws MojoExecutionException { final File narFile = new File(project.getBuild().getDirectory(), project.getBuild().getFinalName() + "-" + classifier + "." + NarConstants.NAR_EXTENSION); if (narFile.exists()) { narFile.delete();/* www.j av a2 s . c om*/ } try { final Archiver archiver = archiverManager.getArchiver(NarConstants.NAR_ROLE_HINT); archiver.addDirectory(dir, new String[] { include }, null); archiver.setDestFile(narFile); archiver.createArchive(); } catch (final NoSuchArchiverException e) { throw new MojoExecutionException("NAR: cannot find archiver", e); } catch (final ArchiverException e) { throw new MojoExecutionException("NAR: cannot create NAR archive '" + narFile + "'", e); } catch (final IOException e) { throw new MojoExecutionException("NAR: cannot create NAR archive '" + narFile + "'", e); } projectHelper.attachArtifact(project, NarConstants.NAR_TYPE, classifier, narFile); }