本文整理汇总了Java中org.apache.maven.project.MavenProject.getParentFile方法的典型用法代码示例。如果您正苦于以下问题:Java MavenProject.getParentFile方法的具体用法?Java MavenProject.getParentFile怎么用?Java MavenProject.getParentFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.project.MavenProject
的用法示例。
在下文中一共展示了MavenProject.getParentFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: normalizePaths
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
/**
* normalize all File references in the object tree.
* @param project
* @since 2.36
*/
public static void normalizePaths(MavenProject project) {
if (project == null) {
return;
}
File f = project.getFile();
if (f != null) {
project.setFile(FileUtil.normalizeFile(f));
}
normalizePath(project.getArtifact());
normalizePaths(project.getAttachedArtifacts());
f = project.getParentFile();
if (f != null) {
project.setParentFile(FileUtil.normalizeFile(f));
}
normalizePath(project.getParentArtifact());
normalizePaths(project.getArtifacts());
normalizePaths(project.getDependencyArtifacts());
normalizePaths(project.getExtensionArtifacts());
normalizePaths(project.getPluginArtifacts());
normalizePath(project.getModel());
normalizePath(project.getOriginalModel());
}
示例2: loadParentOf
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
/**
* replacement for MavenProject.getParent() which has bad long term memory behaviour. We offset it by recalculating/reparsing everything
* therefore should not be used lightly!
* pass a MavenProject instance and current configuration and other settings will be applied when loading the parent.
* @param project
* @return null or the parent mavenproject
*/
public MavenProject loadParentOf(MavenEmbedder embedder, MavenProject project) throws ProjectBuildingException {
MavenProject parent = null;
ProjectBuilder builder = embedder.lookupComponent(ProjectBuilder.class);
MavenExecutionRequest req = embedder.createMavenExecutionRequest();
M2Configuration active = configProvider.getActiveConfiguration();
req.addActiveProfiles(active.getActivatedProfiles());
req.setNoSnapshotUpdates(true);
req.setUpdateSnapshots(false);
req.setInteractiveMode(false);
req.setRecursive(false);
req.setOffline(true);
//#238800 important to merge, not replace
Properties uprops = req.getUserProperties();
uprops.putAll(MavenProjectCache.createUserPropsForProjectLoading(active.getProperties()));
req.setUserProperties(uprops);
ProjectBuildingRequest request = req.getProjectBuildingRequest();
request.setRemoteRepositories(project.getRemoteArtifactRepositories());
DefaultMaven maven = (DefaultMaven) embedder.lookupComponent(Maven.class);
request.setRepositorySession(maven.newRepositorySession(req));
if (project.getParentFile() != null) {
parent = builder.build(project.getParentFile(), request).getProject();
} else if (project.getModel().getParent() != null) {
parent = builder.build(project.getParentArtifact(), request).getProject();
}
//clear the project building request, it references multiple Maven Models via the RepositorySession cache
//is not used in maven itself, most likely used by m2e only..
if (parent != null) {
parent.setProjectBuildingRequest(null);
}
MavenEmbedder.normalizePaths(parent);
return parent;
}
示例3: checkNonRelativeParent
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
private void checkNonRelativeParent ( final MavenProject project )
{
if ( project.getModel ().getParent () == null )
{
// no parent
return;
}
if ( project.getParentFile () != null )
{
// is a local parent
return;
}
final Parent parent = project.getModel ().getParent ();
final String prefix = String.format ( "%s:%s:", parent.getGroupId (), parent.getArtifactId () );
for ( final String entry : this.forceUpdateParentQualifiers )
{
if ( entry.startsWith ( prefix ) )
{
final String qualifier = entry.substring ( prefix.length () );
final String newVersion = makeVersion ( parent.getVersion (), qualifier );
getLog ().info ( String.format ( "Force update parent of %s to %s -> %s", project.getId (), parent.getId (), newVersion ) );
addChange ( project.getFile (), new ModelModifier () {
@Override
public boolean apply ( final Model model )
{
model.getParent ().setVersion ( newVersion );
return true;
}
} );
}
}
}
示例4: hasLocalParent
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
private boolean hasLocalParent ( final MavenProject project )
{
if ( project.getParentFile () != null )
{
return true;
}
return false;
}
示例5: visitModulesWithParent
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
@Override
public void visitModulesWithParent ( final Collection<MavenProject> projects, final MavenProject parentProject, final ProjectVisitor visitor ) throws Exception
{
for ( final MavenProject project : projects )
{
if ( project.getParentFile () == null )
{
continue;
}
if ( project.getParentFile ().equals ( parentProject.getFile () ) )
{
visitor.visit ( project );
}
}
}