org.apache.maven.model.ModelBase Java Examples

The following examples show how to use org.apache.maven.model.ModelBase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DistributionEnforcingManipulator.java    From pom-manipulation-ext with Apache License 2.0 6 votes vote down vote up
/**
 * Go through the plugin / plugin-execution configurations and find references to the <code>skip</code> parameter for the given Maven plugin
 * (specified by artifactId), both in managed and concrete plugin declarations (where available).
 */
private List<SkipReference> findSkipRefs( final ModelBase base, final String pluginArtifactId, final Project project )
    throws ManipulationException
{
    final String key = ga( MAVEN_PLUGIN_GROUPID, pluginArtifactId );

    Map<String, Plugin> pluginMap = getManagedPluginMap( base );
    Plugin plugin = pluginMap.get( key );
    final List<SkipReference> result = new ArrayList<>( findSkipRefs( plugin, project ) );

    pluginMap = getPluginMap( base );
    plugin = pluginMap.get( key );
    result.addAll( findSkipRefs( plugin, project ) );

    return result;
}
 
Example #2
Source File: DistributionEnforcingManipulator.java    From pom-manipulation-ext with Apache License 2.0 6 votes vote down vote up
private Map<String, Plugin> getPluginMap( final ModelBase base )
{
    final BuildBase build;
    if ( base instanceof Model )
    {
        build = ( (Model) base ).getBuild();
    }
    else
    {
        build = ( (Profile) base ).getBuild();
    }

    if ( build == null )
    {
        return Collections.emptyMap();
    }

    final Map<String, Plugin> result = build.getPluginsAsMap();
    if ( result == null )
    {
        return Collections.emptyMap();
    }

    return result;
}
 
Example #3
Source File: ProjectOpenedHookImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void scanForSubmodulesIn(ModelBase projectOrProfile, File basedir, Set<File> registered) throws IllegalArgumentException {
    for (String module : projectOrProfile.getModules()) {
        if (module == null) {
            //#205690 apparently in some rare scenarios module can be null, I was not able to reproduce myself
            //maven itself checks for null value during validation, but at later stages doesn't always check.
            //additional aspect for consideration is that in this case the value is taken from Model class not MavenProject
            continue;
        }
        registerWithSubmodules(FileUtilities.resolveFilePath(basedir, module), registered);
    }
}
 
Example #4
Source File: DetectExtension.java    From os-maven-plugin with Apache License 2.0 5 votes vote down vote up
private static void interpolate(Map<String, String> dict, MavenProject p) {
    if (p == null) {
        return;
    }

    interpolate(dict, p.getParent());
    interpolate(dict, p.getModel());
    for (ModelBase model: p.getActiveProfiles()) {
        interpolate(dict, model);
    }
}
 
Example #5
Source File: DistributionEnforcingManipulator.java    From pom-manipulation-ext with Apache License 2.0 5 votes vote down vote up
private Map<String, Plugin> getManagedPluginMap( final ModelBase base )
{
    if ( base instanceof Model )
    {
        final Build build = ( (Model) base ).getBuild();
        if ( build == null )
        {
            return Collections.emptyMap();
        }

        final PluginManagement pm = build.getPluginManagement();
        if ( pm == null )
        {
            return Collections.emptyMap();
        }

        final Map<String, Plugin> result = pm.getPluginsAsMap();
        if ( result == null )
        {
            return Collections.emptyMap();
        }

        return result;
    }

    return Collections.emptyMap();
}