Package org.jboss.forge.addon.dependencies

Examples of org.jboss.forge.addon.dependencies.Dependency


      String repository = archetypeRepository.getValue();
      if (repository != null)
      {
         depQuery.setRepositories(new DependencyRepository("archetype", repository));
      }
      Dependency resolvedArtifact = resolver.resolveArtifact(depQuery);
      FileResource<?> artifact = resolvedArtifact.getArtifact();
      MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);
      File fileRoot = project.getRoot().reify(DirectoryResource.class).getUnderlyingResourceObject();
      ArchetypeHelper archetypeHelper = new ArchetypeHelper(artifact.getResourceInputStream(), fileRoot,
               metadataFacet.getProjectGroupName(), metadataFacet.getProjectName(), metadataFacet.getProjectVersion());
      JavaSourceFacet facet = (JavaSourceFacet) project.getFacet(JavaSourceFacet.class);
View Full Code Here


         if (!repository.isEmpty())
         {
            depQuery.setRepositories(new DependencyRepository("archetype", repository));
         }
      }
      Dependency resolvedArtifact = resolver.resolveArtifact(depQuery);
      FileResource<?> artifact = resolvedArtifact.getArtifact();
      MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);
      File fileRoot = project.getRoot().reify(DirectoryResource.class).getUnderlyingResourceObject();
      ArchetypeHelper archetypeHelper = new ArchetypeHelper(artifact.getResourceInputStream(), fileRoot,
               metadataFacet.getProjectGroupName(), metadataFacet.getProjectName(), metadataFacet.getProjectVersion());
      JavaSourceFacet facet = (JavaSourceFacet) project.getFacet(JavaSourceFacet.class);
View Full Code Here

      if (arguments.hasValue())
      {
         int count = 0;
         for (Dependency gav : arguments.getValue())
         {
            Dependency existingDep = deps.getEffectiveManagedDependency(DependencyBuilder.create(gav).setVersion(null));
            if (existingDep != null)
            {
               if (context.getPrompt().promptBoolean(String.format(
                        "Dependency [%s:%s] is currently managed. "
                                 + "Reference the existing managed dependency [%s:%s:%s]?",
                        gav.getCoordinate().getArtifactId(),
                        gav.getCoordinate().getGroupId(),
                        existingDep.getCoordinate().getGroupId(),
                        existingDep.getCoordinate().getArtifactId(),
                        existingDep.getCoordinate().getVersion())))
               {
                  gav = DependencyBuilder.create(existingDep).setScopeType(gav.getScopeType());
               }
            }
View Full Code Here

      {
         int count = 0;
         for (Dependency dependency : arguments.getValue())
         {

            Dependency existingDep = deps.getEffectiveManagedDependency(DependencyBuilder.create(dependency)
                     .setVersion(
                              null));
            if (existingDep != null)
            {
               if (context.getPrompt().promptBoolean(
                        String.format("Dependency is already managed [%s:%s:%s], reference the managed dependency?",
                                 existingDep.getCoordinate().getGroupId(), existingDep.getCoordinate().getArtifactId(),
                                 existingDep.getCoordinate().getVersion())))
               {
                  return Results.success("Project not updated: No changes required.");
               }
            }
View Full Code Here

{
   @Override
   public Dependency install(final Project project, final Dependency request)
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);
      final Dependency dependency = deps.resolveProperties(request);

      // Exists in deps, no version change requested
      Dependency unversioned = getUnversioned(dependency);
      Dependency existing = deps.getEffectiveDependency(unversioned);
      Dependency existingManaged = deps.getEffectiveManagedDependency(unversioned);

      if (existing != null) // we already have the dep
      {
         if (!Strings.isNullOrEmpty(existing.getCoordinate().getVersion())
                  && (existing.getCoordinate().getVersion().equals(dependency.getCoordinate().getVersion())
                  || Strings.isNullOrEmpty(dependency.getCoordinate().getVersion())))
         {
            /*
             * The version is the same as requested, or no specific version was requested. No action required.
             */
            return existing;
         }
         else
         {
            /*
             * Version is different. Update it.
             */
            return updateAll(deps, dependency, unversioned);
         }
      }
      else if (existingManaged != null)
      {
         /*
          * we don't have a dependency, or the existing dependency did not have a version, but we do have a managed
          * dependency
          */
         if (!Strings.isNullOrEmpty(existingManaged.getCoordinate().getVersion())
                  && (existingManaged.getCoordinate().getVersion().equals(dependency.getCoordinate().getVersion())
                  || Strings.isNullOrEmpty(dependency.getCoordinate().getVersion())))
         {
            /*
             * We have a version already, or the version is the same as requested, or no specific version was requested.
             * No need to touch dep management because we already have the right version.
             */
            deps.removeDependency(dependency);
            updateDependency(deps, unversioned);
            return existingManaged;
         }
         else
         {
            /*
             * Version is different or unspecified, and we had no existing managed dependency.
             */
            return updateAll(deps, dependency, unversioned);
         }
      }
      else
      {
         Dependency toInstall = dependency;
         if (Strings.isNullOrEmpty(dependency.getCoordinate().getVersion()))
         {
            List<Coordinate> versions = deps.resolveAvailableVersions(DependencyQueryBuilder.create(
                     dependency.getCoordinate()).setFilter(new NonSnapshotDependencyFilter()));

View Full Code Here

    return Results.success();
  }

  private Collection<String> getValidErraiVersions() {
    final DependencyFacet depFacet = holder.getProject().getFacet(DependencyFacet.class);
    final Dependency erraiDep = DependencyBuilder.create(DependencyArtifact.ErraiParent.toString());

    final List<String> versions = new ArrayList<String>();
    for (final Coordinate coord : depFacet.resolveAvailableVersions(erraiDep)) {
      if (isValidVersion(coord.getVersion()))
        versions.add(coord.getVersion());
View Full Code Here

    else
      return getHighestStableVersion(groupId, artifactId);
  }

  private String getHighestStableVersion(String groupId, String artifactId) {
    final Dependency dep = DependencyBuilder.create(groupId + ":" + artifactId);
    final List<Coordinate> availVersions = depFacet.resolveAvailableVersions(dep);
   
    String maxVersion = null;
    for (final Coordinate versionCoord : availVersions) {
      // FIXME needs a more reliable way of comparing versions
View Full Code Here

  @Override
  public boolean install() {
    final MavenPluginFacet pluginFacet = getProject().getFacet(MavenPluginFacet.class);
    final DependencyFacet depFacet = getProject().getFacet(DependencyFacet.class);
    final VersionOracle oracle = new VersionOracle(depFacet);
    final Dependency pluginDep = DependencyBuilder.create(getPluginArtifact().toString()).setVersion(
            oracle.resolveVersion(getPluginArtifact()));
    final MavenPluginBuilder plugin;

    if (pluginFacet.hasPlugin(pluginDep.getCoordinate())) {
      plugin = MavenPluginBuilder.create(pluginFacet.getPlugin(pluginDep.getCoordinate()));
      // So that it is not duplicated when added later on
      pluginFacet.removePlugin(pluginDep.getCoordinate());
    }
    else {
      plugin = MavenPluginBuilder.create();
      plugin.setCoordinate(pluginDep.getCoordinate());
    }

    Configuration config = plugin.getConfig();
    for (final ConfigurationElement configElem : getConfigurations()) {
      mergeConfigurationElement(config, configElem);
View Full Code Here

    else
      return getHighestStableVersion(groupId, artifactId);
  }

  private String getHighestStableVersion(String groupId, String artifactId) {
    final Dependency dep = DependencyBuilder.create(groupId + ":" + artifactId);
    final DependencyFacet depFacet = getFaceted().getFacet(DependencyFacet.class);
    final List<Coordinate> availVersions = depFacet.resolveAvailableVersions(dep);

    String maxVersion = null;
    for (final Coordinate versionCoord : availVersions) {
View Full Code Here

  @Override
  public boolean install() {
    maybeInit();
    final MavenPluginFacet pluginFacet = getProject().getFacet(MavenPluginFacet.class);
    final VersionFacet versionFacet = getProject().getFacet(VersionFacet.class);
    final Dependency pluginDep = DependencyBuilder.create(getPluginArtifact().toString()).setVersion(
            versionFacet.resolveVersion(getPluginArtifact()));
    final MavenPluginBuilder plugin;

    if (pluginFacet.hasPlugin(pluginDep.getCoordinate())) {
      plugin = MavenPluginBuilder.create(pluginFacet.getPlugin(pluginDep.getCoordinate()));
      // So that it is not duplicated when added later on
      pluginFacet.removePlugin(pluginDep.getCoordinate());
    }
    else {
      plugin = MavenPluginBuilder.create();
      plugin.setCoordinate(pluginDep.getCoordinate());
    }

    Configuration config = plugin.getConfig();
    for (final ConfigurationElement configElem : getConfigurations()) {
      mergeConfigurationElement(config, configElem);
View Full Code Here

TOP

Related Classes of org.jboss.forge.addon.dependencies.Dependency

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.