List of usage examples for org.apache.maven.project MavenProject getBasedir
public File getBasedir()
From source file:org.asciidoctor.maven.site.AsciidoctorDoxiaParser.java
License:Apache License
protected File resolveSiteDirectory(MavenProject project, Xpp3Dom siteConfig) { File siteDirectory = new File(project.getBasedir(), "src/site"); if (siteConfig != null) { Xpp3Dom siteDirectoryNode = siteConfig.getChild("siteDirectory"); if (siteDirectoryNode != null) { siteDirectory = new File(siteDirectoryNode.getValue()); }//from w ww . j a v a2s .c o m } return siteDirectory; }
From source file:org.asciidoctor.maven.site.AsciidoctorDoxiaParser.java
License:Apache License
protected File resolveProjectDir(MavenProject project, String path) { File filePath = new File(path); if (!filePath.isAbsolute()) { filePath = new File(project.getBasedir(), filePath.toString()); }//w w w. j av a 2 s . c o m return filePath; }
From source file:org.carewebframework.maven.plugin.theme.CSSThemeProcessor.java
License:Mozilla Public License
@Override public void transform() throws Exception { Theme theme = getTheme();//from w ww . ja v a 2 s .co m MavenProject mavenProject = mojo.getMavenProject(); String mapper = theme.getCSSMapper(); File file = new File(mavenProject.getBasedir(), theme.getThemeUri()); File map = mapper == null ? null : new File(mavenProject.getBasedir(), mapper); IResource resource = new CSSResource(file, map); addConfigEntry("css", resource.getRelativePath()); transform(resource); }
From source file:org.cloudsmith.geppetto.forge.maven.plugin.AbstractForgeMojo.java
License:Open Source License
/** * Returns the basedir as an absolute path string without any '..' constructs. * // w ww . j a v a 2 s .com * @return The absolute path of basedir */ public File getBasedir() { if (baseDir == null) { MavenProject project = session.getCurrentProject(); URI basedirURI; File basedir = project.getBasedir(); if (basedir != null) basedirURI = basedir.toURI(); else basedirURI = URI.create(session.getExecutionRootDirectory()); baseDir = new File(basedirURI.normalize()); } return baseDir; }
From source file:org.codehaus.gmaven.plugin.CompileState.java
License:Apache License
private String projectKey(final MavenProject project) { assert project != null; if (project.getBasedir() == null || !project.getBasedir().isDirectory()) { throw new IllegalStateException( "Project " + project.getId() + " does not define a base directory: " + project.getBasedir()); }//from www. j a va2s .c o m try { return project.getBasedir().getCanonicalPath(); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:org.codehaus.mojo.cobertura.CoberturaReportMojo.java
License:Apache License
/** * Generates an aggregate cobertura report for the given project. *//* www. j av a 2 s .c o m*/ private void executeAggregateReport(Locale locale, MavenProject curProject) throws MavenReportException { List<MavenProject> children = getAllChildren(curProject); if (children.isEmpty()) { return; } List<File> serFiles = getOutputFiles(children); if (serFiles.isEmpty()) { getLog().info("Not executing aggregate cobertura:report for " + curProject.getName() + " as no child cobertura data files could not be found"); return; } getLog().info("Executing aggregate cobertura:report for " + curProject.getName()); ProjectData aggProjectData = new ProjectData(); for (File serFile : serFiles) { ProjectData data = CoverageDataFileHandler.loadCoverageData(serFile); aggProjectData.merge(data); } File aggSerFile = new File(curProject.getBasedir(), relDataFileName); aggSerFile.getAbsoluteFile().getParentFile().mkdirs(); getLog().info("Saving aggregate cobertura information in " + aggSerFile.getAbsolutePath()); CoverageDataFileHandler.saveCoverageData(aggProjectData, aggSerFile); // get all compile source roots List<String> aggCompileSourceRoots = new ArrayList<String>(); for (MavenProject child : children) { aggCompileSourceRoots.addAll(child.getCompileSourceRoots()); } File reportDir = new File(curProject.getBasedir(), relAggregateOutputDir); reportDir.mkdirs(); executeReport(aggSerFile, reportDir, aggCompileSourceRoots); }
From source file:org.codehaus.mojo.cobertura.CoberturaReportMojo.java
License:Apache License
/** * Returns any existing cobertura data files from the given list of projects. *//*w ww .j ava 2 s . co m*/ private List<File> getOutputFiles(List<MavenProject> projects) { List<File> files = new ArrayList<File>(); for (MavenProject proj : projects) { if (isMultiModule(proj)) { continue; } File outputFile = new File(proj.getBasedir(), relDataFileName); if (outputFile.exists()) { files.add(outputFile); } } return files; }
From source file:org.codehaus.mojo.dashboard.report.plugin.DashBoardUtils.java
License:Apache License
/** * @param project/*from ww w. j av a 2 s .com*/ * @param module * @return */ private MavenProject getModuleMavenProject(MavenProject project, String module) { MavenProject projectModule = null; File f = new File(project.getBasedir(), module + "/pom.xml"); if (f.exists()) { try { projectModule = this.projectBuilder.build(f, this.localRepo, null); } catch (ProjectBuildingException e) { this.log.error("Unable to read local module-POM \"" + module + "\".", e); } } return projectModule; }
From source file:org.codehaus.mojo.dashboard.report.plugin.DashBoardUtils.java
License:Apache License
/** * get the Cobertura datafile. MOJO-644 : pb with different versions of Cobertura plugin. for cobertura 2.1 * default-value="${project.build.directory}/cobertura/cobertura.ser" for cobertura 2.0 * default-value="${basedir}/cobertura.ser" MOJO-674 : NumberFormatException fixed by using DefaultArtifactVersion * class MOJO-749 : NPE if dashboard called on parent project (when no cobertura version in pom.xml) * //from w w w. j a va 2 s . c om * @param project * MavenProject to be processed * @return cobertura.ser File object */ private File getCoberturaDataFile(MavenProject project) { /* * HACK to address the broken datafile location code in Cobertura See * https://sourceforge.net/tracker/index.php?func=detail&aid=1543280&group_id=130558&atid=720017 Until patch is * commited, this hack will be in place. */ File coberturaFile = null; File brokenDatafile = new File(project.getBasedir(), this.coberturaDataFile); File dataFile = new File(project.getBuild().getDirectory(), "cobertura/" + this.coberturaDataFile); if (brokenDatafile != null && brokenDatafile.exists()) { try { FileUtils.copyFile(brokenDatafile, dataFile); brokenDatafile.delete(); coberturaFile = dataFile; } catch (IOException e) { coberturaFile = null; } } if (dataFile != null && dataFile.exists()) { coberturaFile = dataFile; } else { coberturaFile = null; } return coberturaFile; }
From source file:org.codehaus.mojo.dashboard.report.plugin.DashBoardUtils.java
License:Apache License
/** * @param project// w ww . j a v a 2 s . com * @param pluginArtifact * @param optionName * @param defaultValue * @return */ private String getConfiguration(MavenProject project, String pluginArtifact, String pluginGroupId, String optionName, String defaultValue) { String result = null; String value = ""; try { value = getMavenPluginConfiguration(project, pluginArtifact, pluginGroupId, optionName, ""); if (value != null && value.length() > 0) { if (value.indexOf("$") > -1) { result = this.getInterpolatorValue(project, value); } else { File dir = new File(value); boolean isExists = dir.exists(); if (!isExists) { File resultFile = FileUtils.resolveFile(project.getBasedir(), value); result = resultFile.getAbsolutePath(); } else { result = value; } } } else { result = this.getInterpolatorValue(project, defaultValue); } } catch (IOException e) { result = null; this.log.error("DashBoardUtils getConfiguration() : ", e); } return result; }