Examples of MavenPluginAdapter


Examples of org.jboss.forge.addon.maven.plugins.MavenPluginAdapter

            versionToInstall = promptVersion(deps, pluginCoordinates, null).getVersion();
         }
      }

      // Install the plugin
      MavenPluginAdapter pluginToInstall = new MavenPluginAdapter(mergedPlugin);
      pluginToInstall.setVersion(versionToInstall);
      if (!managed)
      {
         // In case of a direct plugin install
         // We want it's version being managed in the plugin management section
         MavenPluginAdapter mavenManagedPlugin = null;
         if (managedPlugin != null)
         {
            // A plugin managemement section already exists, update version
            mavenManagedPlugin = new MavenPluginAdapter(managedPlugin);
            mavenManagedPlugin.setVersion(pluginToInstall.getVersion());
         }
         else
         {
            // Create a new plugin management, that will handle the minimal configuration: groupId, artifactId and
            // version
            Plugin newManagedPlugin = new Plugin();
            newManagedPlugin.setGroupId(pluginToInstall.getGroupId());
            newManagedPlugin.setArtifactId(pluginToInstall.getArtifactId());
            newManagedPlugin.setVersion(pluginToInstall.getVersion());
            mavenManagedPlugin = new MavenPluginAdapter(newManagedPlugin);
         }

         // Install the plugin management, if needed
         addOrUpdatePlugin(deps, plugins, mavenManagedPlugin, true);
         pluginToInstall.setVersion(null); // handled by the plugin management section
View Full Code Here

Examples of org.jboss.forge.addon.maven.plugins.MavenPluginAdapter

    * in the recessive plugin but not in dominant, it will be ignored <b>Important: the artifactId and groupId
    * properties are not affected</b>
    */
   private MavenPluginAdapter diff(final MavenPlugin dominant, final MavenPlugin recessive)
   {
      MavenPluginAdapter merged = new MavenPluginAdapter(dominant);
      if (Dependencies.areEquivalent(dominant.getCoordinate(), recessive.getCoordinate()))
      {
         // Version
         if (Strings.compare(dominant.getCoordinate().getVersion(), recessive.getCoordinate().getVersion()))
         {
            // Remove version as dominant and recessive have the same one
            merged.setVersion(null);
         }

         // Extension
         if (dominant.isExtensionsEnabled() == recessive.isExtensionsEnabled())
         {
            // Remove extension as dominant and recessive have the same one
            merged.setExtensions(null);
         }
         // Config
         Map<String, String> cfgElmtsRefMap = new HashMap<>();
         Configuration mergedConfiguration = merged.getConfig();
         if (dominant.getConfig() != null && recessive.getConfig() != null)
         {
            for (ConfigurationElement e : dominant.getConfig().listConfigurationElements())
            {
               // FIXME: recursively do a diff of childrens, if any
               cfgElmtsRefMap.put(e.getName(), e.toString());
            }
            for (ConfigurationElement e : recessive.getConfig().listConfigurationElements())
            {
               if (cfgElmtsRefMap.containsKey(e.getName()))
               {
                  if (Strings.compare(cfgElmtsRefMap.get(e.getName()), e.toString()))
                  {
                     // Remove the configuration element as dominant and recessive have the same element
                     mergedConfiguration.removeConfigurationElement(e.getName());
                  }
               }
            }
         }
         merged.setConfig(mergedConfiguration);
         // Executions
         Map<String, PluginExecution> dominantExec = new MavenPluginAdapter(dominant).getExecutionsAsMap();
         Map<String, PluginExecution> recessiveExec = new MavenPluginAdapter(recessive).getExecutionsAsMap();
         Map<String, PluginExecution> mergedExec = merged.getExecutionsAsMap();
         if (dominantExec != null && recessiveExec != null)
         {
            for (Map.Entry<String, PluginExecution> entry : recessiveExec.entrySet())
            {
               PluginExecution pluginExecutionRecessive = entry.getValue();
View Full Code Here

Examples of org.jboss.forge.addon.maven.plugins.MavenPluginAdapter

   {
      Coordinate compilerDependency = CoordinateBuilder.create()
               .setGroupId("org.apache.maven.plugins")
               .setArtifactId("maven-compiler-plugin");
      MavenPluginFacet pluginFacet = getFaceted().getFacet(MavenPluginFacet.class);
      final MavenPluginAdapter compiler;
      if (pluginFacet.hasPlugin(compilerDependency))
      {
         compiler = new MavenPluginAdapter(pluginFacet.getPlugin(compilerDependency));
      }
      else
      {
         compiler = new MavenPluginAdapter(MavenPluginBuilder.create().setCoordinate(compilerDependency));
      }
      Configuration config = compiler.getConfig();
      if (!config.hasConfigurationElement("proc"))
      {
         ConfigurationElement proc = ConfigurationBuilder.create().createConfigurationElement("proc").setText("none");
         config.addConfigurationElement(proc);
         compiler.setConfig(config);
      }
      pluginFacet.updatePlugin(compiler);
   }
View Full Code Here

Examples of org.jboss.forge.addon.maven.plugins.MavenPluginAdapter

   }

   @Override
   public MavenPlugin merge(final MavenPlugin dominant, final MavenPlugin recessive)
   {
      MavenPluginAdapter merged = new MavenPluginAdapter(dominant);
      if (Dependencies.areEquivalent(dominant.getCoordinate(), recessive.getCoordinate()))
      {
         MavenPluginAdapter recessiveAdaptater = new MavenPluginAdapter(recessive);
         // Merge the configurations
         Xpp3Dom mergedDomConfig = Xpp3Dom.mergeXpp3Dom((Xpp3Dom) merged.getConfiguration(),
                  (Xpp3Dom) recessiveAdaptater.getConfiguration());
         merged.setConfiguration(mergedDomConfig);
         // Merge the executions
         List<PluginExecution> mergedExecutions = mergePluginsExecutions(merged.getExecutionsAsMap(),
                  recessiveAdaptater.getExecutionsAsMap());
         merged.setExecutions(mergedExecutions);
         // Merge dependencies; only version required, we already know that groupId and artifactId are equals
         if (Strings.isNullOrEmpty(merged.getVersion()))
         {
            merged.setVersion(recessiveAdaptater.getVersion());
         }
         // Extension flag
         if (Strings.isNullOrEmpty(merged.getExtensions()))
         {
            merged.setExtensions(recessiveAdaptater.getExtensions());
         }
         // Inherited flag
         if (Strings.isNullOrEmpty(merged.getInherited()))
         {
            merged.setExtensions(recessiveAdaptater.getInherited());
         }
      }
      return merged;
   }
View Full Code Here

Examples of org.jboss.forge.addon.maven.plugins.MavenPluginAdapter

            org.jboss.forge.addon.maven.profiles.Profile profileParam)
   {
      List<MavenPlugin> plugins = new ArrayList<>();
      for (org.apache.maven.model.Plugin plugin : getPluginsPOM(managedPlugin, effectivePlugin, profileParam))
      {
         plugins.add(new MavenPluginAdapter(plugin));
      }
      return plugins;
   }
View Full Code Here

Examples of org.jboss.forge.addon.maven.plugins.MavenPluginAdapter

         if (pluginManagement == null)
         {
            pluginManagement = new PluginManagement();
            build.setPluginManagement(pluginManagement);
         }
         pluginManagement.addPlugin(new MavenPluginAdapter(plugin));
      }
      else
      {
         build.addPlugin(new MavenPluginAdapter(plugin));
      }
      mavenCoreFacet.setModel(pom);
   }
View Full Code Here

Examples of org.jboss.forge.addon.maven.plugins.MavenPluginAdapter

         BuildBase build = getBuild(pom, profileParam); // We know for sure it isnt null because the plugin exists
         if (managedPlugin)
         {
            PluginManagement pluginManagement = build.getPluginManagement(); // We know for sure it isnt null because
                                                                             // the plugin exists
            pluginManagement.removePlugin(new MavenPluginAdapter(pluginToRemove));
         }
         else
         {
            build.removePlugin(new MavenPluginAdapter(pluginToRemove));
         }
         mavenCoreFacet.setModel(pom);
      }
   }
View Full Code Here

Examples of org.jboss.forge.addon.maven.plugins.MavenPluginAdapter

      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()) {
      mergeConfigurationElement(config, elem);
    }
    adapter.setConfig(config);

    for (final DependencyBuilder depBuilder : getDependencies()) {
      if (depBuilder.getCoordinate().getVersion() == null || depBuilder.getCoordinate().getVersion().equals("")) {
        if (ArtifactVault.ERRAI_GROUP_ID.equals(depBuilder.getGroupId())) {
          depBuilder.setVersion(Property.ErraiVersion.invoke());
        }
        else {
          depBuilder.setVersion(new VersionOracle(getProject().getFacet(DependencyFacet.class)).resolveVersion(
                  depBuilder.getGroupId(), depBuilder.getCoordinate().getArtifactId()));
        }
      }
      adapter.addDependency(MavenConverter.convert(depBuilder));
    }

    for (final PluginExecution exec : getPluginExecutions()) {
      adapter.addExecution(exec);
    }
    adapter.setExtensions(isExtensions());

    // Changes are not committed from adapter to original plugin
    plugin.setConfiguration(adapter.getConfiguration());
    plugin.setExecutions(adapter.getExecutions());
    plugin.setDependencies(adapter.getDependencies());

    coreFacet.setModel(pom);

    return true;
  }
View Full Code Here

Examples of org.jboss.forge.addon.maven.plugins.MavenPluginAdapter

          continue outer;
      }
      return false;
    }

    final MavenPluginAdapter adapter = new MavenPluginAdapter(plugin);

    if (!isMatchingConfiguration(adapter.getConfig(), getConfigurations()))
      return false;

    return true;
  }
View Full Code Here

Examples of org.jboss.forge.addon.maven.plugins.MavenPluginAdapter

      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()) {
      mergeConfigurationElement(config, elem);
    }
    adapter.setConfig(config);

    for (final DependencyBuilder depBuilder : getDependencies()) {
      if (depBuilder.getCoordinate().getVersion() == null || depBuilder.getCoordinate().getVersion().equals("")) {
        if (ArtifactVault.ERRAI_GROUP_ID.equals(depBuilder.getGroupId())) {
          depBuilder.setVersion(Property.ErraiVersion.invoke());
        }
        else {
          depBuilder.setVersion(getProject().getFacet(VersionFacet.class).resolveVersion(
                  depBuilder.getGroupId(), depBuilder.getCoordinate().getArtifactId()));
        }
      }
      adapter.addDependency(MavenConverter.convert(depBuilder));
    }

    for (final PluginExecution exec : getPluginExecutions()) {
      adapter.addExecution(exec);
    }
    adapter.setExtensions(isExtensions());

    // Changes are not committed from adapter to original plugin
    plugin.setConfiguration(adapter.getConfiguration());
    plugin.setExecutions(adapter.getExecutions());
    plugin.setDependencies(adapter.getDependencies());

    coreFacet.setModel(pom);

    return true;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.