当前位置: 首页>>代码示例>>Java>>正文


Java MavenProject.getParentFile方法代码示例

本文整理汇总了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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:MavenEmbedder.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:NbMavenProjectImpl.java

示例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;
                }
            } );
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:39,代码来源:AbstractSetQualifierMojo.java

示例4: hasLocalParent

import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
private boolean hasLocalParent ( final MavenProject project )
{
    if ( project.getParentFile () != null )
    {
        return true;
    }
    return false;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:9,代码来源:DefaultPomHelper.java

示例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 );
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:16,代码来源:DefaultPomHelper.java


注:本文中的org.apache.maven.project.MavenProject.getParentFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。