List of usage examples for org.apache.maven.project MavenProject getBuild
public Build getBuild()
From source file:org.phpmaven.project.impl.ProjectPhpExecution.java
License:Apache License
/** * Adds the default includes to the executable configuration. * @param execConfig executable configuration. * @param buildConfig the build configuration. * @param mojoConfig the mojo configuration. * @param project the project.//ww w.j ava 2s . co m * @param mavenSession the maven session. * @throws ExpressionEvaluationException thrown on maven property errors */ private void addIncludes(IPhpExecutableConfiguration execConfig, Xpp3Dom buildConfig, Xpp3Dom mojoConfig, MavenProject project, MavenSession mavenSession, IDependencyConfiguration depConfig) throws ExpressionEvaluationException, MojoExecutionException { execConfig.getIncludePath().add(project.getBuild().getOutputDirectory()); File depsDir; if (buildConfig == null || buildConfig.getChild("dependenciesDir") == null) { depsDir = this.componentFactory.filterString(mavenSession, "${project.build.directory}/php-deps", File.class); } else { depsDir = this.componentFactory.filterString(mavenSession, buildConfig.getChild("dependenciesDir").getValue(), File.class); } if (mojoConfig != null && mojoConfig.getChild("dependenciesDir") != null) { depsDir = this.componentFactory.filterString(mavenSession, mojoConfig.getChild("dependenciesDir").getValue(), File.class); } execConfig.getIncludePath().add(depsDir.getAbsolutePath()); // TODO: Bad hack for broken pear libraries. execConfig.getIncludePath().add(new File(depsDir, "pear").getAbsolutePath()); addFromDepConfig(execConfig, project, Artifact.SCOPE_COMPILE, depConfig, depsDir); // add the project dependencies of multi-project-poms addProjectDependencies(execConfig, project, Artifact.SCOPE_COMPILE, depConfig); }
From source file:org.phpmaven.project.impl.ProjectPhpExecution.java
License:Apache License
/** * Adds the test includes to the executable configuration. * @param execConfig executable configuration. * @param buildConfig //w w w . jav a2 s. com * @param mojoConfig * @param project the project. * @param mavenSession the maven session. * @throws ExpressionEvaluationException thrown on maven property errors */ private void addTestIncludes(IPhpExecutableConfiguration execConfig, Xpp3Dom buildConfig, Xpp3Dom mojoConfig, MavenProject project, MavenSession mavenSession, IDependencyConfiguration depConfig) throws ExpressionEvaluationException, MojoExecutionException { execConfig.getIncludePath().add(project.getBuild().getTestOutputDirectory()); File depsDir; if (buildConfig == null || buildConfig.getChild("testDependenciesDir") == null) { depsDir = this.componentFactory.filterString(mavenSession, "${project.build.directory}/php-test-deps", File.class); } else { depsDir = this.componentFactory.filterString(mavenSession, buildConfig.getChild("testDependenciesDir").getValue(), File.class); } if (mojoConfig != null && mojoConfig.getChild("testDependenciesDir") != null) { depsDir = this.componentFactory.filterString(mavenSession, mojoConfig.getChild("testDependenciesDir").getValue(), File.class); } execConfig.getIncludePath().add(depsDir.getAbsolutePath()); // TODO: Bad hack for broken pear libraries. execConfig.getIncludePath().add(new File(depsDir, "pear").getAbsolutePath()); addFromDepConfig(execConfig, project, Artifact.SCOPE_TEST, depConfig, depsDir); // add the project dependencies of multi-project-poms addProjectDependencies(execConfig, project, Artifact.SCOPE_TEST, depConfig); }
From source file:org.phpmaven.project.ProjectPhpExecution.java
License:Apache License
/** * Adds the default includes to the executable configuration. * @param execConfig executable configuration. * @param buildConfig the build configuration. * @param mojoConfig the mojo configuration. * @param project the project.//from w w w .j a va 2 s . co m * @param mavenSession the maven session. * @throws ExpressionEvaluationException thrown on maven property errors */ private void addIncludes(IPhpExecutableConfiguration execConfig, Xpp3Dom buildConfig, Xpp3Dom mojoConfig, MavenProject project, MavenSession mavenSession) throws ExpressionEvaluationException { execConfig.getIncludePath().add(project.getBuild().getOutputDirectory()); File depsDir; if (buildConfig == null || buildConfig.getChild("dependenciesDir") == null) { depsDir = this.componentFactory.filterString(mavenSession, "${project.basedir}/target/php-deps", File.class); } else { depsDir = this.componentFactory.filterString(mavenSession, buildConfig.getChild("dependenciesDir").getValue(), File.class); } if (mojoConfig != null && mojoConfig.getChild("dependenciesDir") != null) { depsDir = this.componentFactory.filterString(mavenSession, mojoConfig.getChild("dependenciesDir").getValue(), File.class); } execConfig.getIncludePath().add(depsDir.getAbsolutePath()); // TODO: Bad hack for broken pear libraries. execConfig.getIncludePath().add(new File(depsDir, "pear").getAbsolutePath()); }
From source file:org.phpmaven.project.ProjectPhpExecution.java
License:Apache License
/** * Adds the test includes to the executable configuration. * @param execConfig executable configuration. * @param buildConfig // ww w . j a v a 2 s .com * @param mojoConfig * @param project the project. * @param mavenSession the maven session. * @throws ExpressionEvaluationException thrown on maven property errors */ private void addTestIncludes(IPhpExecutableConfiguration execConfig, Xpp3Dom buildConfig, Xpp3Dom mojoConfig, MavenProject project, MavenSession mavenSession) throws ExpressionEvaluationException { execConfig.getIncludePath().add(project.getBuild().getOutputDirectory()); File depsDir; if (buildConfig == null || buildConfig.getChild("testDependenciesDir") == null) { depsDir = this.componentFactory.filterString(mavenSession, "${project.basedir}/target/php-test-deps", File.class); } else { depsDir = this.componentFactory.filterString(mavenSession, buildConfig.getChild("testDependenciesDir").getValue(), File.class); } if (mojoConfig != null && mojoConfig.getChild("testDependenciesDir") != null) { depsDir = this.componentFactory.filterString(mavenSession, mojoConfig.getChild("testDependenciesDir").getValue(), File.class); } execConfig.getIncludePath().add(depsDir.getAbsolutePath()); // TODO: Bad hack for broken pear libraries. execConfig.getIncludePath().add(new File(depsDir, "pear").getAbsolutePath()); }
From source file:org.phpmaven.sitemap.SitemapIndexMojo.java
License:Apache License
private void parseProject(final List<String> urls, final MavenProject project) throws ProjectBuildingException { for (final Plugin plugin : project.getBuild().getPlugins()) { if (plugin.getArtifactId().equals("sitemap-plugin") && plugin.getGroupId().equals("org.phpmaven.sites")) { urls.add(project.getUrl());/*from w w w. j a v a 2s .co m*/ } } for (final String module : project.getModules()) { final File moduleFolder = new File(project.getBasedir(), module); final File pomFile = new File(moduleFolder, "pom.xml"); if (pomFile.exists()) { this.parseProject(urls, this.getProjectFromPom(pomFile)); } } }
From source file:org.pustefixframework.maven.plugins.Reflection.java
License:Open Source License
public static Reflection create(MavenProject project) throws MojoExecutionException { URL[] cp;// w w w . ja v a 2 s . co m List<Artifact> artifacts; StringBuilder classpath; File file; classpath = new StringBuilder(); try { artifacts = extracted(project); cp = new URL[artifacts.size() + 1]; file = new File(project.getBuild().getOutputDirectory()); cp[0] = file.toURI().toURL(); classpath.append(file); for (int i = 1; i < cp.length; i++) { file = artifacts.get(i - 1).getFile(); cp[i] = file.toURI().toURL(); classpath.append(':').append(file.getAbsolutePath()); } } catch (MalformedURLException e) { throw new MojoExecutionException("invalid url", e); } return new Reflection(new URLClassLoader(cp, Reflection.class.getClassLoader()), classpath.toString()); }
From source file:org.rapidoid.plugin.app.AbstractRapidoidMojo.java
License:Apache License
protected String buildUberJar(MavenProject project, MavenSession session) throws MojoExecutionException { List<String> goals = U.list("package", "org.apache.maven.plugins:maven-assembly-plugin:2.6:single"); String assemblyFile = createTempFile("app-assembly-", ".xml"); IO.save(assemblyFile, IO.load("uber-jar.xml")); Map<String, String> properties = U.map(); properties.put("skipTests", "true"); properties.put("descriptor", assemblyFile); properties.put("assembly.appendAssemblyId", "true"); properties.put("assembly.attach", "false"); invoke(session, goals, false, properties); boolean deleted = new File(assemblyFile).delete(); if (!deleted) getLog().warn("Couldn't delete the temporary assembly descriptor file!"); List<String> appJars = IO.find("*-uber-jar.jar").in(project.getBuild().getDirectory()).getNames(); failIf(appJars.size() != 1, "Cannot find the deployment JAR (found %s candidates)! " + ABORT, appJars.size());//w ww. ja v a 2 s . c om String uberJar = U.first(appJars); try { Path uberJarPath = Paths.get(uberJar); Path appJar = uberJarPath.getParent().resolve("app.jar"); Files.move(uberJarPath, appJar, StandardCopyOption.REPLACE_EXISTING); uberJar = appJar.toFile().getAbsolutePath(); } catch (IOException e) { throw new MojoExecutionException("Couldn't rename the file! " + ABORT, e); } String mainClass = findMainClass(project); getLog().info(""); getLog().info("The main class is: " + mainClass); try { addJarManifest(uberJar, project, mainClass); } catch (IOException e) { throw new MojoExecutionException("Couldn't add the JAR manifest! " + ABORT, e); } String size = Msc.fileSizeReadable(uberJar); getLog().info(""); getLog().info("Successfully packaged the application with dependencies:"); getLog().info(U.frmt("%s (size: %s).", uberJar, size)); getLog().info(""); return uberJar; }
From source file:org.renjin.gcc.maven.GccBridgeHelper.java
License:Open Source License
public static void archiveHeaders(Log log, MavenProject project, File... includeDirectories) throws MojoExecutionException { File outputDir = new File(project.getBuild().getDirectory()); File archiveFile = new File(outputDir, project.getBuild().getFinalName() + "-headers.jar"); ensureDirExists(outputDir);//from ww w.j a v a2 s .c om try (JarOutputStream output = new JarOutputStream(new FileOutputStream(archiveFile))) { for (File includeDirectory : includeDirectories) { if (includeDirectory.exists()) { log.info("Archiving headers from " + includeDirectory.getAbsolutePath()); archiveFiles(output, includeDirectory, ""); } } } catch (IOException e) { throw new MojoExecutionException("Failed to create headers archive", e); } Artifact artifact = new AttachedArtifact(project.getArtifact(), "jar", "headers", new HeaderArtifactHandler()); artifact.setFile(archiveFile); artifact.setResolved(true); project.addAttachedArtifact(artifact); }
From source file:org.renjin.gcc.maven.GccBridgeHelper.java
License:Open Source License
public static ClassLoader getLinkClassLoader(MavenProject project, Log log) throws MojoExecutionException { try {//from w w w . j a v a 2s . co m log.debug("GCC-Bridge Link Classpath: "); List<URL> classpathURLs = Lists.newArrayList(); classpathURLs.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL()); for (Artifact artifact : (List<Artifact>) project.getCompileArtifacts()) { log.debug(" " + artifact.getFile()); classpathURLs.add(artifact.getFile().toURI().toURL()); } ClassLoader parent = GccBridgeHelper.class.getClassLoader(); return new URLClassLoader(classpathURLs.toArray(new URL[classpathURLs.size()]), parent); } catch (MalformedURLException e) { throw new MojoExecutionException("Exception resolving classpath", e); } }
From source file:org.renjin.maven.MavenBuildContext.java
License:Open Source License
public MavenBuildContext(MavenProject project, Collection<Artifact> pluginDependencies, Log log) throws MojoExecutionException { this.project = project; this.logger = new MavenBuildLogger(log); this.buildDir = new File(project.getBuild().getDirectory()); this.outputDir = new File(project.getBuild().getOutputDirectory()); this.packageOuputDir = new File(project.getBuild().getOutputDirectory() + File.separator + project.getGroupId().replace('.', File.separatorChar) + File.separator + project.getArtifactId()); this.pluginDependencies = pluginDependencies; this.homeDir = new File(buildDir, "gnur"); this.pluginFile = new File(buildDir, "bridge.so"); this.unpackedIncludeDir = new File(buildDir, "include"); this.classpath = buildClassPath(); ensureDirExists(outputDir);// ww w.jav a2 s . c o m ensureDirExists(packageOuputDir); ensureDirExists(getGnuRHomeDir()); ensureDirExists(unpackedIncludeDir); classloader = new URLClassLoader(classpath, getClass().getClassLoader()); packageLoader = new ClasspathPackageLoader(classloader); }