Package org.jboss.forge.project.facets

Examples of org.jboss.forge.project.facets.DependencyFacet


                     completer = DependencyPropertyCompleter.class) final String name,
            @Option(required = true,
                     name = "value") final String value,
            final PipeOut out)
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);

      if (deps.getProperties().containsKey(name) &&
               shell.promptBoolean("Update property [" + name + "=" + deps.getProperty(name) + "] to new value ["
                        + value + "]", true))
      {
         deps.setProperty(name, value);
         out.println("Updated...");
      }
      else
      {
         deps.setProperty(name, value);
         out.println("Set property [" + name + "=" + value + "]");
      }
   }
View Full Code Here


   public void removeProp(
            @Option(required = true, description = "propname",
                     completer = DependencyPropertyCompleter.class) final String name,
            final PipeOut out)
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);
      if (deps.getProperties().containsKey(name))
      {
         String value = deps.removeProperty(name);
         out.println("Removed property [" + name + "=" + value + "]");
      }
      else
      {
         out.println("No such property [" + name + "]");
View Full Code Here

   }

   @Command("list-properties")
   public void listProps(final PipeOut out)
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);
      Map<String, String> properties = deps.getProperties();

      for (Entry<String, String> entry : properties.entrySet())
      {
         out.print(entry.getKey() + "=");
         out.println(ShellColor.BLUE, entry.getValue());
View Full Code Here

   @Command("add-known-repository")
   public void repoAdd(
            @Option(description = "type...", required = true) final KnownRepository repo,
            final PipeOut out)
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);

      if (deps.hasRepository(repo))
      {
         out.println("Repository exists [" + repo.name() + "->" + repo.getUrl() + "]");
      }
      else
      {
         deps.addRepository(repo);
         out.println("Added repository [" + repo.name() + "->" + repo.getUrl() + "]");
      }
   }
View Full Code Here

   public void repoAdd(
            @Option(description = "repository name...", required = true) final String name,
            @Option(description = "repository URL...", required = true) final String url,
            final PipeOut out)
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);

      if (deps.hasRepository(url))
      {
         out.println("Repository exists [" + url + "]");
      }
      else
      {
         deps.addRepository(name, url);
         out.println("Added repository [" + name + "->" + url + "]");
      }
   }
View Full Code Here

   public void repoRemove(
            @Option(required = true, description = "repo url...",
                     completer = RepositoryCompleter.class) final String url,
            final PipeOut out)
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);

      DependencyRepository rep;
      if ((rep = deps.removeRepository(url)) != null)
      {
         out.println("Removed repository [" + rep.getId() + "->" + rep.getUrl() + "]");
      }
      else
      {
View Full Code Here

   }

   @Command("list-repositories")
   public void repoList(final PipeOut out)
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);
      List<DependencyRepository> repos = deps.getRepositories();

      for (DependencyRepository repo : repos)
      {
         out.print(repo.getId() + "->");
         out.println(ShellColor.BLUE, repo.getUrl());
View Full Code Here

   }

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

      // Exists in deps, no version change requested
      Dependency existing = deps.getEffectiveDependency(dependency);
      Dependency existingManaged = deps.getEffectiveManagedDependency(dependency);
      DependencyBuilder unversioned = DependencyBuilder.create(dependency).setVersion(null)
               .setScopeType(type == null ? dependency.getScopeType() : type.toString())
               .setPackagingType(dependency.getPackagingType());

      if (existing != null) // we already have the dep
      {
         if (!Strings.isNullOrEmpty(existing.getVersion())
                  && (existing.getVersion().equals(dependency.getVersion()) // the version is the same as requested
                  || Strings.isNullOrEmpty(dependency.getVersion()))) // or no specific version was requested
         {
            // take no action
            return existing;
         }
         else if (Strings.isNullOrEmpty(existing.getVersion()) // we have no existing version
                  && !Strings.isNullOrEmpty(dependency.getVersion())) // but we did request one
         {
            return update(dependency, deps, unversioned);
         }
         else // version is different
         {
            return promptAndUpdate(dependency, deps, 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.getVersion()) // we have a version already
                  && (!existingManaged.getVersion().equals(dependency.getVersion()) // the version is the same as
                                                                                    // requested
                  || Strings.isNullOrEmpty(dependency.getVersion()))) // or no specific version was requested
         {
            // don't need to touch dep management because we already have the right version
            deps.removeDependency(dependency);
            deps.addDirectDependency(unversioned);
            return existingManaged;
         }
         else if (Strings.isNullOrEmpty(existingManaged.getVersion()) // we have no existing version
                  && !Strings.isNullOrEmpty(dependency.getVersion())) // but we did request one
         {
View Full Code Here

   }

   @Override
   public boolean isInstalled(final Project project, final Dependency dependency)
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);
      return deps.hasEffectiveDependency(dependency);
   }
View Full Code Here

                     description = "[ groupId:artifactId ]",
                     help = "exclusion identifier, ex: \"org.jboss.forge:forge-api\"") final Dependency exclusion,
            final PipeOut out
            )
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);

      if (!deps.hasEffectiveDependency(gav)
               || shell.promptBoolean("Dependency already exists [" + gav.getGroupId() + ":" + gav.getArtifactId()
                        + "], continue?", true))
      {
         boolean requestProcessed = false;
         if (deps.hasEffectiveManagedDependency(gav))
         {
            Dependency existingDep = deps.getEffectiveManagedDependency(gav);
            if (shell.promptBoolean("Dependency is managed [" +
                     existingDep.getGroupId() + ":" +
                     existingDep.getArtifactId() + ":" + existingDep.getVersion()
                     + "], reference the managed dependency?", true))
            {
               DependencyBuilder depToAdd = DependencyBuilder.create();
               depToAdd.setGroupId(gav.getGroupId());
               depToAdd.setArtifactId(gav.getArtifactId());
               deps.addDirectDependency(depToAdd);
               out.println("Added dependency [" + depToAdd + "]");
               requestProcessed = true;
            }
         }
         if (!requestProcessed)
         {
            DependencyBuilder search = DependencyBuilder.create(gav).setVersion("[0,)");
            List<Dependency> availableVersions = deps.resolveAvailableVersions(search);

            if (availableVersions.isEmpty())
            {
               if (Strings.isNullOrEmpty(gav.getVersion())
                        || !shell.promptBoolean("No artifacts resolved from available repositories, install anyway?"))
               {
                  throw new RuntimeException("No available versions resolved for dependency [" + gav + "]");
               }
            }
            else if (!availableVersions.contains(gav))
            {
               ShellMessages.info(out, "No artifact found for dependency [" + gav + "]");
               if (availableVersions.size() > 1)
               {
                  gav = shell.promptChoiceTyped("Add which version?", availableVersions);
               }
               else if (shell.promptBoolean("Use [" + availableVersions.get(0) + "] instead?", true))
               {
                  gav = availableVersions.get(0);
               }
               else
               {
                  throw new RuntimeException("Could not add dependency [" + gav + "]");
               }
            }

            if (deps.hasEffectiveDependency(gav))
            {
               Dependency dependency = deps.getEffectiveDependency(gav);
               deps.removeDependency(dependency);
            }
            if (exclusion != null)
            {
               gav.getExcludedDependencies().add(exclusion);
            }
            deps.addDirectDependency(gav);
            out.println("Added dependency [" + gav + "]" + (exclusion != null ? " excluding [" + exclusion + "]" : ""));
         }
      }
      else
      {
View Full Code Here

TOP

Related Classes of org.jboss.forge.project.facets.DependencyFacet

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.