Package org.apache.maven.model

Examples of org.apache.maven.model.Profile


    }

    final MavenFacet coreFacet = getProject().getFacet(MavenFacet.class);
    Model pom = coreFacet.getModel();
    for (final String profName : profileDependencies.keySet()) {
      final Profile profile = MavenModelUtil.getProfileById(profName, pom.getProfiles());
      if (profile == null) {
        return false;
      }
      outer: for (final DependencyBuilder dep : profileDependencies.get(profName)) {
        for (final Dependency profDep : profile.getDependencies()) {
          if (MavenConverter.areSameArtifact(profDep, dep)) {
            continue outer;
          }
        }
        return false;
      }
    }

    /*
     * Check that all blacklisted dependencies that are transitively in the
     * project have been provided scoped. Note that we are not checking if these
     * blacklisted dependencies were pulled in transitively through a dependency
     * in this instance. This should not be an issue, since we don't really care
     * what sets the blacklisted dependencies to provided, as long as something
     * does it.
     */
    pom = coreFacet.getModel();
    for (final String profileId : ArtifactVault.getBlacklistProfiles()) {
      final Profile profile = MavenModelUtil.getProfileById(profileId, pom.getProfiles());
      for (final DependencyArtifact artifact : ArtifactVault.getBlacklistedArtifacts(profileId)) {
        final DependencyBuilder dep = getDependency(artifact);
        if (depFacet.hasEffectiveDependency(dep) && !hasProvidedDependency(profile, dep))
          return false;
      }
View Full Code Here


  @Override
  public boolean install() {
    final MavenFacet coreFacet = getProject().getFacet(MavenFacet.class);
    Model pom = coreFacet.getModel();
    Profile profile = MavenModelUtil.getProfileById(profileId, pom.getProfiles());
    final VersionOracle oracle = new VersionOracle(getProject().getFacet(DependencyFacet.class));

    if (profile == null) {
      addDependenciesToProfile(profileId, Collections.<DependencyBuilder> emptyList(), oracle);
      pom = coreFacet.getModel();
      profile = MavenModelUtil.getProfileById(profileId, pom.getProfiles());
    }

    if (profile.getBuild() == null) {
      profile.setBuild(new BuildBase());
    }

    Plugin plugin = getPlugin(getPluginArtifact(), profile.getBuild().getPlugins());

    if (plugin == null) {
      plugin = new Plugin();
      plugin.setArtifactId(getPluginArtifact().getArtifactId());
      plugin.setGroupId(getPluginArtifact().getGroupId());
      if (ArtifactVault.ERRAI_GROUP_ID.equals(plugin.getGroupId()))
        plugin.setVersion(Property.ErraiVersion.invoke());
      else
        plugin.setVersion(oracle.resolveVersion(plugin.getGroupId(), plugin.getArtifactId()));
      profile.getBuild().addPlugin(plugin);
    }

    final MavenPluginAdapter adapter = new MavenPluginAdapter(plugin);
    final Configuration config = adapter.getConfig();
    for (final ConfigurationElement elem : getConfigurations()) {
View Full Code Here

  @Override
  public boolean isInstalled() {
    final MavenFacet coreFacet = getProject().getFacet(MavenFacet.class);
    final Model pom = coreFacet.getModel();

    final Profile profile = MavenModelUtil.getProfileById(profileId, pom.getProfiles());
    if (profile == null || profile.getBuild() == null)
      return false;

    Plugin plugin = profile.getBuild().getPluginsAsMap().get(getPluginArtifact().toString());
    if (plugin == null) {
      plugin = new Plugin();
      plugin.setGroupId(pluginArtifact.getGroupId());
      plugin.setArtifactId(pluginArtifact.getArtifactId());
     
      final VersionOracle oracle = new VersionOracle(getFaceted().getFacet(DependencyFacet.class));
      plugin.setVersion(oracle.resolveVersion(pluginArtifact));
     
      profile.getBuild().addPlugin(plugin);
    }

    outer: for (final DependencyBuilder dep : getDependencies()) {
      for (final Dependency pluginDep : plugin.getDependencies()) {
        if (pluginDep.getArtifactId().equals(dep.getCoordinate().getArtifactId())
View Full Code Here

  @Override
  public boolean uninstall() {
    final MavenFacet coreFacet = getProject().getFacet(MavenFacet.class);
    final Model pom = coreFacet.getModel();

    final Profile profile = MavenModelUtil.getProfileById(profileId, pom.getProfiles());
    if (profile == null)
      return false;

    final BuildBase build = profile.getBuild();
    if (build == null)
      return false;

    final Plugin plugin = build.getPluginsAsMap().get(getPluginArtifact().toString());
    if (plugin == null)
      return false;

    build.removePlugin(plugin);
    profile.setBuild(build);
    coreFacet.setModel(pom);

    return true;
  }
View Full Code Here

            throw new ProjectBuildingException( projectId, "Failed to calculate active external profiles.", e );
        }

        for ( Iterator i = activeExternalProfiles.iterator(); i.hasNext(); )
        {
            Profile externalProfile = (Profile) i.next();

            for ( Iterator repoIterator = externalProfile.getRepositories().iterator(); repoIterator.hasNext(); )
            {
                Repository mavenRepo = (Repository) repoIterator.next();

                ArtifactRepository artifactRepo = null;
                try
View Full Code Here

                throw new ProjectBuildingException( projectId, e.getMessage(), e );
            }

            for ( Iterator it = activeProfiles.iterator(); it.hasNext(); )
            {
                Profile profile = (Profile) it.next();

                profileInjector.inject( profile, model );
            }
        }
        else
View Full Code Here

                    for ( Iterator it = root.getProfiles().iterator(); it.hasNext(); )
                    {
                        org.apache.maven.profiles.Profile rawProfile = (org.apache.maven.profiles.Profile) it.next();

                        Profile converted = ProfilesConversionUtils.convertFromProfileXmlProfile( rawProfile );

                        profileManager.addProfile( converted );
                    }
                }
            }
View Full Code Here

    }

    final Model pom = coreFacet.getModel();
    final Map<String, Collection<DependencyBuilder>> blacklistProfileDependencies = new HashMap<String, Collection<DependencyBuilder>>();
    for (String profileId : ArtifactVault.getBlacklistProfiles()) {
      final Profile profile = MavenModelUtil.getProfileById(profileId, pom.getProfiles());
      for (final DependencyArtifact artifact : ArtifactVault.getBlacklistedArtifacts(profileId)) {
        final DependencyBuilder dep = getDependency(artifact);
        if (depFacet.hasEffectiveDependency(dep)
                && !hasProvidedDependency(profile, dep)) {
          final org.jboss.forge.addon.dependencies.Dependency existing = depFacet.getEffectiveDependency(dep);
View Full Code Here

    }

    final MavenFacet coreFacet = getProject().getFacet(MavenFacet.class);
    Model pom = coreFacet.getModel();
    for (final String profName : profileDependencies.keySet()) {
      final Profile profile = MavenModelUtil.getProfileById(profName, pom.getProfiles());
      if (profile == null) {
        return false;
      }
      outer: for (final DependencyBuilder dep : profileDependencies.get(profName)) {
        for (final Dependency profDep : profile.getDependencies()) {
          if (MavenConverter.areSameArtifact(profDep, dep)) {
            continue outer;
          }
        }
        return false;
      }
    }

    /*
     * Check that all blacklisted dependencies that are transitively in the
     * project have been provided scoped. Note that we are not checking if these
     * blacklisted dependencies were pulled in transitively through a dependency
     * in this instance. This should not be an issue, since we don't really care
     * what sets the blacklisted dependencies to provided, as long as something
     * does it.
     */
    pom = coreFacet.getModel();
    for (final String profileId : ArtifactVault.getBlacklistProfiles()) {
      final Profile profile = MavenModelUtil.getProfileById(profileId, pom.getProfiles());
      for (final DependencyArtifact artifact : ArtifactVault.getBlacklistedArtifacts(profileId)) {
        final DependencyBuilder dep = getDependency(artifact);
        if (depFacet.hasEffectiveDependency(dep) && !hasProvidedDependency(profile, dep))
          return false;
      }
View Full Code Here

  @Override
  public boolean install() {
    maybeInit();
    final MavenFacet coreFacet = getProject().getFacet(MavenFacet.class);
    Model pom = coreFacet.getModel();
    Profile profile = MavenModelUtil.getProfileById(profileId, pom.getProfiles());
    final VersionFacet versionFacet = getProject().getFacet(VersionFacet.class);

    if (profile == null) {
      addDependenciesToProfile(profileId, Collections.<DependencyBuilder> emptyList(), versionFacet);
      pom = coreFacet.getModel();
      profile = MavenModelUtil.getProfileById(profileId, pom.getProfiles());
    }

    if (profile.getBuild() == null) {
      profile.setBuild(new BuildBase());
    }

    Plugin plugin = getPlugin(getPluginArtifact(), profile.getBuild().getPlugins());

    if (plugin == null) {
      plugin = new Plugin();
      plugin.setArtifactId(getPluginArtifact().getArtifactId());
      plugin.setGroupId(getPluginArtifact().getGroupId());
      if (ArtifactVault.ERRAI_GROUP_ID.equals(plugin.getGroupId()))
        plugin.setVersion(Property.ErraiVersion.invoke());
      else
        plugin.setVersion(versionFacet.resolveVersion(plugin.getGroupId(), plugin.getArtifactId()));
      profile.getBuild().addPlugin(plugin);
    }

    final MavenPluginAdapter adapter = new MavenPluginAdapter(plugin);
    final Configuration config = adapter.getConfig();
    for (final ConfigurationElement elem : getConfigurations()) {
View Full Code Here

TOP

Related Classes of org.apache.maven.model.Profile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.