Package org.jboss.forge.project.facets

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


   private void installAdditionalDependencies(final PipeOut out, final PersistenceContainer container,
            final JPAProvider jpap, final PersistenceProvider provider,
            final String providerVersion)
   {
      DependencyFacet dependencyFacet = project.getFacet(DependencyFacet.class);

      List<Dependency> dependencies = new ArrayList<Dependency>();
      if (!provider.listDependencies().isEmpty()
               && prompt.promptBoolean("The JPA provider [" + jpap
                        + "], also supplies extended APIs. Install these as well?", false))
      {
         if (providerVersion != null)
         {
            for (Dependency dependency : provider.listDependencies())
            {
               if (container instanceof JavaEEDefaultContainer)
               {
                  dependency = DependencyBuilder.create(dependency).setScopeType(ScopeType.PROVIDED);
               }
               dependencies.add(DependencyBuilder.create(dependency).setVersion(providerVersion));
            }
         }
         else
         {
            DependencyFacet deps = project.getFacet(DependencyFacet.class);
            for (Dependency dependency : provider.listDependencies())
            {
               List<Dependency> versions = deps.resolveAvailableVersions(dependency);
               if (!versions.isEmpty())
               {
                  Dependency choice = prompt.promptChoiceTyped("Install which version of [" + dependency + "]?",
                           versions, versions.get(versions.size() - 1));
View Full Code Here


   public boolean install()
   {
      for (Dependency requirement : getRequiredDependencies()) {
         if (!installer.isInstalled(project, requirement))
         {
            DependencyFacet deps = project.getFacet(DependencyFacet.class);
            if (!deps.hasEffectiveManagedDependency(requirement) && !deps.hasDirectManagedDependency(JAVAEE6))
            {
               deps.addDirectManagedDependency(JAVAEE6);
            }
            installer.install(project, requirement, ScopeType.PROVIDED);
         }
      }
      return true;
View Full Code Here

   }

   @Override
   public boolean isInstalled()
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);
      for (Dependency requirement : getRequiredDependencies()) {
         if (!deps.hasEffectiveDependency(requirement))
         {
            return false;
         }
      }
      return true;
View Full Code Here

         {
            throw new IllegalStateException("Unable to recognise plugin project in ["
                     + buildDir.getFullyQualifiedName() + "]");
         }

         DependencyFacet deps = project.getFacet(DependencyFacet.class);
         DependencyBuilder shellApi = DependencyBuilder.create("org.jboss.forge:forge-shell-api");

         String apiVersion = null;
         if (!deps.hasEffectiveDependency(shellApi)
                  && !prompt.promptBoolean(
                           "The project does not appear to be a Forge Plugin Project, install anyway?",
                           false))
         {
            throw new Abort("Installation aborted");
         }
         else
         {
            if (apiVersion == null)
            {
               Dependency directDependency = deps.getDirectDependency(shellApi);
               if ((directDependency != null) && !Strings.isNullOrEmpty(directDependency.getVersion()))
                  apiVersion = directDependency.getVersion();
            }

            if (apiVersion == null)
            {
               // Fall back to checking managed dependencies for a version
               Dependency managedDependency = deps.getManagedDependency(shellApi);
               if ((managedDependency != null) && !Strings.isNullOrEmpty(managedDependency.getVersion()))
                  apiVersion = managedDependency.getVersion();
            }

            if (apiVersion == null)
            {
               // Now completely give up and just use the result from the build
               Dependency effectiveDependency = deps.getEffectiveDependency(shellApi);
               if (effectiveDependency != null)
                  apiVersion = effectiveDependency.getVersion();
               else
                  apiVersion = environment.getRuntimeVersion();
            }
         }

         /**
          * Make sure that our PROVIDED modules are not included in the module dependencies
          */
         // TODO Weld bug requires us to correct /add module for Seam Render dependency
         List<String> groupIds = Arrays.asList("org.jboss.seam.render", "org.jboss.forge");
         List<String> providedDeps = Arrays.asList("forge-javaee-api", "forge-maven-api", "forge-scaffold-api",
                  "forge-shell-api");
         List<Dependency> dependencies = deps.getDependencies();
         for (Dependency dependency : dependencies)
         {
            if (groupIds.contains(dependency.getGroupId())
                     && !(ScopeType.PROVIDED.equals(dependency.getScopeTypeEnum())
                     || ScopeType.TEST.equals(dependency.getScopeTypeEnum())))
            {
               ShellMessages.warn(out, "Dependency [" + dependency.toCoordinates()
                        + "] was not correctly marked as PROVIDED scope; this has been corrected.");
               deps.addDirectDependency(DependencyBuilder.create(dependency).setScopeType(ScopeType.PROVIDED));
            }
            else if (dependency.getGroupId().equals("org.jboss.forge")
                     && !providedDeps.contains(dependency.getArtifactId())
                     && !ScopeType.TEST.equals(deps.getEffectiveDependency(dependency).getScopeTypeEnum()))
            {
               ShellMessages.warn(writer,
                        "Plugin has a dependency on internal Forge API [" + dependency
                                 + "] - this is not allowed and may cause failures.");
            }
View Full Code Here

      return moduleDir;
   }

   private List<DependencyResource> getPluginDependencies(final Project project, Node module)
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);
      List<DependencyResource> pluginDependencies = new ArrayList<DependencyResource>();
      List<Dependency> effectiveDependenciesInScopes = deps.getEffectiveDependenciesInScopes(ScopeType.COMPILE,
               ScopeType.RUNTIME);
      for (Dependency d : effectiveDependenciesInScopes)
      {
         if (d.getPackagingTypeEnum().equals(PackagingType.JAR)
                  && !d.getGroupId().equals("org.jboss.forge"))
View Full Code Here

   private List<DependencyResource> resolveArtifacts(final Project project, final Dependency dep)
   {
      Dependency d = dep;

      List<DependencyResource> artifacts = new ArrayList<DependencyResource>();
      DependencyFacet deps = project.getFacet(DependencyFacet.class);

      for (Dependency d2 : deps.getDependencies())
      {
         if (DependencyBuilder.areEquivalent(d, d2) && (d2.getVersion() != null))
         {
            d = d2;
            break;
         }
      }

      if (artifacts.size() != 1)
      {
         artifacts = resolver.resolveArtifacts(d, deps.getRepositories());
      }
      if (artifacts.size() != 1)
      {
         ShellMessages.warn(writer, "Could not resolve dependency [" + d.toCoordinates() + "]");
      }
View Full Code Here

         {
            throw new IllegalStateException("Unable to recognise plugin project in ["
                     + buildDir.getFullyQualifiedName() + "]");
         }

         DependencyFacet deps = project.getFacet(DependencyFacet.class);
         DependencyBuilder shellApi = DependencyBuilder.create("org.jboss.forge:forge-shell-api");

         String apiVersion = null;
         if (!deps.hasEffectiveDependency(shellApi)
                  && !prompt.promptBoolean(
                           "The project does not appear to be a Forge Plugin Project, install anyway?",
                           false))
         {
            throw new Abort("Installation aborted");
         }
         else
         {
            Dependency directDependency = deps.getDirectDependency(shellApi);
            if ((directDependency != null) && !Strings.isNullOrEmpty(directDependency.getVersion()))
               apiVersion = directDependency.getVersion();

            if (apiVersion == null)
            {
               // Fall back to checking managed dependencies for a version
               Dependency managedDependency = deps.getManagedDependency(shellApi);
               if ((managedDependency != null) && !Strings.isNullOrEmpty(managedDependency.getVersion()))
                  apiVersion = managedDependency.getVersion();
            }

            if (apiVersion == null)
            {
               // Now completely give up and just use the result from the build
               Dependency effectiveDependency = deps.getEffectiveDependency(shellApi);
               if (effectiveDependency != null)
                  apiVersion = effectiveDependency.getVersion();
               else
                  apiVersion = environment.getRuntimeVersion();
            }
         }

         /**
          * Make sure that our PROVIDED modules are not included in the module dependencies
          */
         // TODO Weld bug requires us to correct /add module for Seam Render dependency
         List<String> groupIds = Arrays.asList("org.jboss.seam.render", "org.jboss.forge");
         List<String> providedDeps = Arrays.asList("forge-javaee-api", "forge-maven-api", "forge-scaffold-api",
                  "forge-shell-api");
         List<Dependency> dependencies = deps.getDependencies();
         for (Dependency dependency : dependencies)
         {
            if (groupIds.contains(dependency.getGroupId())
                     && !(ScopeType.PROVIDED.equals(dependency.getScopeTypeEnum())
                     || ScopeType.TEST.equals(dependency.getScopeTypeEnum())))
            {
               ShellMessages.warn(out, "Dependency [" + dependency.toCoordinates()
                        + "] was not correctly marked as PROVIDED scope; this has been corrected.");
               deps.addDirectDependency(DependencyBuilder.create(dependency).setScopeType(ScopeType.PROVIDED));
            }
            else if (dependency.getGroupId().equals("org.jboss.forge")
                     && !providedDeps.contains(dependency.getArtifactId())
                     && !ScopeType.TEST.equals(deps.getEffectiveDependency(dependency).getScopeTypeEnum()))
            {
               ShellMessages.warn(writer,
                        "Plugin has a dependency on internal Forge API [" + dependency
                                 + "] - this is not allowed and may cause failures.");
            }
View Full Code Here

      return moduleDir;
   }

   private List<DependencyResource> getPluginDependencies(final Project project, Node module)
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);
      List<DependencyResource> pluginDependencies = new ArrayList<DependencyResource>();
      List<Dependency> effectiveDependenciesInScopes = deps.getEffectiveDependenciesInScopes(ScopeType.COMPILE,
               ScopeType.RUNTIME);
      for (Dependency d : effectiveDependenciesInScopes)
      {
         if (d.getPackagingTypeEnum().equals(PackagingType.JAR)
                  && !d.getGroupId().equals("org.jboss.forge"))
View Full Code Here

   private List<DependencyResource> resolveArtifacts(final Project project, final Dependency dep)
   {
      Dependency d = dep;

      List<DependencyResource> artifacts = new ArrayList<DependencyResource>();
      DependencyFacet deps = project.getFacet(DependencyFacet.class);

      for (Dependency d2 : deps.getDependencies())
      {
         if (DependencyBuilder.areEquivalent(d, d2) && (d2.getVersion() != null))
         {
            d = d2;
            break;
         }
      }

      if (artifacts.size() != 1)
      {
         artifacts = resolver.resolveArtifacts(d, deps.getRepositories());
      }
      if (artifacts.size() != 1)
      {
         ShellMessages.warn(writer, "Could not resolve dependency [" + d.toCoordinates() + "]");
      }
View Full Code Here

   private DependencyInstaller installer;

   @Override
   public boolean install()
   {
      DependencyFacet deps = project.getFacet(DependencyFacet.class);

      List<Dependency> versions = deps.resolveAvailableVersions("org.jboss.forge:forge-shell-api:[,]");
      Dependency version = shell.promptChoiceTyped("Install which version of the Forge API?", versions);
      deps.setProperty("forge.api.version", version.getVersion());
      DependencyBuilder apiDep = DependencyBuilder.create("org.jboss.forge:forge-shell-api:${forge.api.version}")
               .setScopeType(ScopeType.PROVIDED);
      DependencyBuilder testDep = DependencyBuilder.create("org.jboss.forge:forge-test-harness:${forge.api.version}")
               .setScopeType(ScopeType.TEST);
      DependencyBuilder testShellDep = DependencyBuilder.create("org.jboss.forge:forge-shell:${forge.api.version}")
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.