List of usage examples for org.apache.maven.project MavenProject getBuild
public Build getBuild()
From source file:org.mule.tools.maven.plugin.module.analyze.DefaultModuleApiAnalyzer.java
License:Open Source License
protected Map<String, Set<String>> findPackageDependencies(MavenProject project, AnalyzerLogger analyzerLogger) throws IOException { String outputDirectory = project.getBuild().getOutputDirectory(); final Map<String, Set<String>> packageDeps = findPackageDependencies(outputDirectory, analyzerLogger); return packageDeps; }
From source file:org.mule.tools.maven.plugin.module.analyze.ModuleDiscoverer.java
License:Open Source License
private Properties getModuleProperties(MavenProject project) throws ModuleApiAnalyzerException { Properties properties = null; try {// w w w . j a v a 2s. co m final List<Resource> projectResources = project.getBuild().getResources(); File result = null; for (int i = 0; i < projectResources.size(); i++) { final Resource resource = projectResources.get(i); File moduleProperties = new File(resource.getDirectory(), MULE_MODULE_PROPERTIES_LOCATION); if (moduleProperties.exists()) { result = moduleProperties; break; } } final File moduleProperties = result; if (moduleProperties != null) { properties = loadProperties(moduleProperties.toURI().toURL()); } } catch (IOException e) { throw new ModuleApiAnalyzerException("Cannot access module properties", e); } return properties; }
From source file:org.nanoko.coffee.mill.utils.JasmineUtils.java
License:Apache License
public static void prepareJasmineMojo(AbstractCoffeeMillMojo mill, AbstractJasmineMojo mojo, List<String> aggregation) { MavenProject project = mill.project; mojo.setLog(mill.getLog());/*from ww w . ja v a2 s . co m*/ InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "jsSrcDir", new File(project.getBasedir(), "src/main/coffee")); //TODO This should be configurable. InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "jsTestSrcDir", new File(project.getBasedir(), "src/test/js")); //TODO This should be configurable. InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "webDriverClassName", "org.openqa.selenium.htmlunit.HtmlUnitDriver"); //TODO This should be configurable. InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "browserVersion", "FIREFOX_3"); //TODO This should be configurable. InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "format", "documentation"); //TODO This should be configurable. InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "jasmineTargetDir", new File(project.getBuild().getDirectory(), "jasmine")); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "specDirectoryName", "spec"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "srcDirectoryName", "src"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "manualSpecRunnerHtmlFileName", "ManualSpecRunner.html"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "specRunnerHtmlFileName", "SpecRunner.html"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "junitXmlReportFileName", TEST_JASMINE_XML); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "mavenProject", project); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "specRunnerTemplate", "DEFAULT"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "haltOnFailure", true); List<String> deps = new ArrayList<String>(); for (Dependency dep : (Collection<Dependency>) project.getDependencies()) { if ("js".equals(dep.getType())) { String filename = dep.getArtifactId() + ".js"; if (dep.getClassifier() != null && !dep.getClassifier().equals("min")) { filename = dep.getArtifactId() + "-" + dep.getClassifier() + ".js"; } File file = new File(mill.getLibDirectory(), filename); if (!file.exists()) { mill.getLog().error("Cannot preload " + dep.getArtifactId() + ":" + dep.getVersion() + " : " + file.getAbsolutePath() + " not found"); } else { try { FileUtils.copyFileToDirectory(file, getJasmineDirectory(project)); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } deps.add(filename); } } } InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "preloadSources", deps); // If javaScriptAggregation is set, use the right order. if (aggregation != null) { InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "sourceIncludes", aggregation); } // TODO Parameter. InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "timeout", 300); }
From source file:org.nanoko.coffee.mill.utils.JasmineUtils.java
License:Apache License
public static File getJasmineDirectory(MavenProject project) { return new File(project.getBuild().getDirectory(), "jasmine"); }
From source file:org.nanoko.coffee.mill.utils.JasmineUtils.java
License:Apache License
public static File getJasmineITDirectory(MavenProject project) { return new File(project.getBuild().getDirectory(), "it-jasmine"); }
From source file:org.nanoko.coffee.mill.utils.ReactorUtils.java
License:Apache License
public static Plugin getCoffeeMillPlugin(MavenProject project) { List<Plugin> plugins = project.getBuild().getPlugins(); for (Plugin plugin : plugins) { System.out.println(plugin.getArtifactId()); if ("coffee-mill-maven-plugin".equals(plugin.getArtifactId())) { return plugin; }/*from w ww . j a v a 2 s .co m*/ } return null; }
From source file:org.nanoko.coffeemill.utils.JasmineUtils.java
License:Apache License
public static void prepareJasmineMojo(AbstractCoffeeMillMojo mill, AbstractJasmineMojo mojo, List<String> aggregation) { MavenProject project = mill.project; mojo.setLog(mill.getLog());//from w w w . j a v a 2 s. c o m InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "jsSrcDir", new File(project.getBasedir(), "src/main/coffee")); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "jsTestSrcDir", new File(project.getBasedir(), "src/test/js")); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "webDriverClassName", "org.openqa.selenium.htmlunit.HtmlUnitDriver"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "browserVersion", "FIREFOX_3"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "format", "documentation"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "jasmineTargetDir", new File(project.getBuild().getDirectory(), "jasmine")); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "specDirectoryName", "spec"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "srcDirectoryName", "src"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "manualSpecRunnerHtmlFileName", "ManualSpecRunner.html"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "specRunnerHtmlFileName", "SpecRunner.html"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "junitXmlReportFileName", TEST_JASMINE_XML); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "mavenProject", project); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "specRunnerTemplate", "DEFAULT"); InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "haltOnFailure", true); Collection<File> files = FileUtils.listFiles(mill.getLibDirectory(), new String[] { "js" }, true); if (files.isEmpty()) { mill.getLog().warn( "JavaScript sources directory " + mill.getLibDirectory().getAbsolutePath() + " is empty !"); return; } List<String> deps = new ArrayList<String>(); for (File file : files) { try { FileUtils.copyFileToDirectory(file, getJasmineDirectory(project)); } catch (IOException e) { mill.getLog().error("Error during copy files to Jasmine directory " + getJasmineDirectory(project).getAbsolutePath(), e); } deps.add(file.getName()); } InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "preloadSources", deps); // If javaScriptAggregation is set, use the right order. if (aggregation != null) { InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "sourceIncludes", aggregation); } InjectionHelper.inject(mojo, AbstractJasmineMojo.class, "timeout", 300);// TODO Parameter. }
From source file:org.neo4j.build.plugins.ease.EaseHelper.java
License:Apache License
static void writeAndAttachArtifactList(StringBuilder builder, MavenProject project, MavenProjectHelper projectHelper, Log log) throws MojoExecutionException { String buildDir = project.getBuild().getDirectory(); String destFile = buildDir + File.separator + project.getArtifactId() + "-" + project.getVersion() + "-artifacts.txt"; try {/*from w ww . jav a2 s . c om*/ if (FileUtils.fileExists(destFile)) { FileUtils.fileDelete(destFile); } if (!FileUtils.fileExists(buildDir)) { FileUtils.mkdir(buildDir); } FileUtils.fileWrite(destFile, "UTF-8", builder.toString()); } catch (IOException ioe) { throw new MojoExecutionException("Could not write artifact list.", ioe); } projectHelper.attachArtifact(project, "txt", "artifacts", FileUtils.getFile(destFile)); log.info("Successfully attached artifact list to the project."); }
From source file:org.netbeans.modules.jackpot30.maven.Utils.java
License:Open Source License
public static Xpp3Dom getPluginConfiguration(MavenProject project, String groupId, String artifactId) { for (Object o : project.getBuild().getPlugins()) { if (!(o instanceof Plugin)) continue; Plugin p = (Plugin) o;/* w w w.j av a2 s . co m*/ if (groupId.equals(p.getGroupId()) && artifactId.equals(p.getArtifactId())) { if (p.getConfiguration() instanceof Xpp3Dom) { return (Xpp3Dom) p.getConfiguration(); } break; } } return null; }
From source file:org.nuxeo.extractor.ExtractorMojo.java
License:Apache License
protected static String getBuildOutputDirectory(MavenProject project) { // When project is standalone-pom; use the current directory instead of a build one return isStandaloneProject(project) ? Paths.get("").toAbsolutePath().toString() : project.getBuild().getOutputDirectory(); }