本文整理汇总了Java中org.apache.maven.project.MavenProject.getBasedir方法的典型用法代码示例。如果您正苦于以下问题:Java MavenProject.getBasedir方法的具体用法?Java MavenProject.getBasedir怎么用?Java MavenProject.getBasedir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.project.MavenProject
的用法示例。
在下文中一共展示了MavenProject.getBasedir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performHandleRepository
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
private void performHandleRepository ( final MavenProject project ) throws Exception, XPathExpressionException
{
final File file = new File ( project.getBasedir (), "category.xml" );
if ( !file.exists () )
{
return;
}
final Document doc = XmlHelper.parse ( file );
for ( final Node node : XmlHelper.findNodes ( doc, "/site/feature" ) )
{
final Element ele = (Element)node;
final String featureId = ele.getAttribute ( "id" );
final String featureVersion = getVersion ( "feature", featureId );
ele.setAttribute ( "version", featureVersion );
ele.setAttribute ( "url", String.format ( "features/%s_%s.jar", featureId, featureVersion ) );
}
XmlHelper.write ( doc, file );
}
示例2: getBndrunPath
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
private String getBndrunPath(MavenProject project) throws MavenExecutionException {
String bndrunName = project.getProperties().getProperty(Constants.PROP_CONFIG_BNDRUN, "");
if (bndrunName.trim().isEmpty()) {
bndrunName = project.getName() + ".bndrun";
}
File existingBndrunFile = new File(project.getBasedir(), bndrunName);
File targetBndrunFile = emProjectHome.resolve(bndrunName).toFile();
if (existingBndrunFile.exists()) {
if (existingBndrunFile.isFile()) {
logger.info("Found `" + existingBndrunFile.getName() + "` in project's folder and will use it as is! POM config is ignored!");
try {
Files.copy(existingBndrunFile.toPath(), targetBndrunFile.toPath());
} catch (IOException e) {
throw new MavenExecutionException("Failed to copy file!", e);
}
} else {
throw new MavenExecutionException("'" + existingBndrunFile + "' is not a file!", project.getFile());
}
} else {
String distro = project.getProperties().getProperty(INTERNAL_DISTRO_FILE, "");
generateBndrun(project, distro, targetBndrunFile);
}
return targetBndrunFile.getAbsolutePath();
}
示例3: createEvaluator
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
/**
* Evaluator usable for interpolating variables in non resolved (interpolated) models.
* Should not be necessary when dealing with the project's <code>MavenProject</code> instance accessed via<code>NbMavenProject.getMavenProject()</code>
* Please NOTE that if you have access to <code>Project</code> instance, then
* the variant with <code>Project</code> as parameter is preferable. Faster and less prone to deadlock.
* @since 2.32
*/
public static @NonNull ExpressionEvaluator createEvaluator(@NonNull MavenProject prj) {
ExpressionEvaluator eval = (ExpressionEvaluator) prj.getContextValue(CONTEXT_EXPRESSION_EVALUATOR);
if (eval != null) {
return eval;
}
Map<? extends String,? extends String> sysprops = Collections.emptyMap();
Map<? extends String,? extends String> userprops = Collections.emptyMap();
File basedir = prj.getBasedir();
if (basedir != null) {
FileObject bsd = FileUtil.toFileObject(basedir);
if (bsd != null) {
Project p = FileOwnerQuery.getOwner(bsd);
if (p != null) {
NbMavenProjectImpl project = p.getLookup().lookup(NbMavenProjectImpl.class);
if (project != null) {
sysprops = project.createSystemPropsForPropertyExpressions();
userprops = project.createUserPropsForPropertyExpressions();
}
}
}
}
//ugly
Settings ss = EmbedderFactory.getProjectEmbedder().getSettings();
ss.setLocalRepository(EmbedderFactory.getProjectEmbedder().getLocalRepository().getBasedir());
eval = new NBPluginParameterExpressionEvaluator(
prj,
ss,
sysprops,
userprops);
prj.setContextValue(CONTEXT_EXPRESSION_EVALUATOR, eval);
return eval;
}
示例4: findReactor
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
/**
* Tries to find the reactor root starting from what may be just a submodule.
* The intent is that running {@code mvn -f $reactor/pom.xml --projects $module} would work.
* @param module a project to start the search at
* @return its apparent reactor root; maybe just the same project
*/
public static @NonNull NbMavenProject findReactor(@NonNull NbMavenProject module) { // #197232
MavenProject prj = module.getMavenProject();
List<ModelDescription> models = MavenEmbedder.getModelDescriptors(prj);
File moduleDir = prj.getBasedir();
File current = moduleDir;
if (current != null && models != null) { //models are null for totally broken projects..
boolean first = true;
for (ModelDescription model : models) {
if (first) { //ignore the first value, it's the current project
first = false;
continue;
}
File loc = model.getLocation();
if (loc == null || loc.getName().endsWith(".pom")) {
break;
}
File modelDir = loc.getParentFile();
if (listsModule(modelDir, current, model.getModules())) {
current = modelDir;
} else {
break;
}
}
if (!moduleDir.equals(current)) {
NbMavenProject loaded = load(current);
if (loaded != null) {
return findReactor(loaded);
}
}
}
NbMavenProject p = load(prj.getBasedir().getParentFile());
if (p != null && listsModule(moduleDir.getParentFile(), moduleDir, p.getMavenProject().getModules())) {
return findReactor(p);
}
return module;
}
示例5: NBPluginParameterExpressionEvaluator
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
public NBPluginParameterExpressionEvaluator(
MavenProject project,
Settings settings,
Map<? extends String,? extends String> systemProperties,
Map<? extends String,? extends String> userProperties)
{
this.pathTranslator = new DefaultPathTranslator();
this.systemProperties = systemProperties;
this.userProperties = userProperties;
this.project = project;
this.settings = settings;
String bsdir = null;
if ( project != null )
{
File projectFile = project.getBasedir();
// this should always be the case for non-super POM instances...
if ( projectFile != null )
{
bsdir = projectFile.getAbsolutePath();
}
}
if ( bsdir == null )
{
bsdir = System.getProperty( "user.dir" );
}
this.basedir = bsdir;
}
示例6: setMavenProject
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
@Override
public void setMavenProject(final MavenProject project) {
this.projectBaseDir = project.getBasedir();
LOG.debug("{}: project base dir: {}", getClass().getCanonicalName(), this.projectBaseDir);
}