Package org.jboss.forge.project.dependencies

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


         ShellMessages
                  .warn(shell,
                           "There is an update pending. Restart Forge for the update to take effect. To abort this update, type 'forge update-abort'");
         return;
      }
      Dependency forgeDistribution = getLatestAvailableDistribution();
      if (forgeDistribution == null)
      {
         ShellMessages.info(shell, "Forge is up to date! Enjoy!");
      }
      else
      {
         shell.print(ShellColor.YELLOW, "***INFO*** ");
         shell.print("This Forge installation will be updated to ");
         shell.println(ShellColor.BOLD, forgeDistribution.getVersion());
         if (prompt.promptBoolean("Is that ok ?", true))
         {
            updateForge(forgeDistribution);
         }
      }
View Full Code Here


         {
            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-scaffoldx-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.");
            }
         }

         ShellMessages.info(out, "Invoking build with underlying build system.");
         Resource<?> artifact = project.getFacet(PackagingFacet.class).createBuilder().runTests(false).build();
         if ((artifact != null) && artifact.exists())
         {
            MetadataFacet meta = project.getFacet(MetadataFacet.class);
            Dependency dep = meta.getOutputDependency();

            ShellMessages.info(out, "Installing plugin artifact.");

            // TODO Figure out a better plugin versioning strategy than random numbers, also see if unloading is
            // possible to avoid this entirely.
            createModule(
                     project,
                     DependencyBuilder.create(dep).setVersion(
                              dep.getVersion() + "-" + UUID.randomUUID().toString()),
                     artifact, apiVersion);
         }
         else
         {
            throw new IllegalStateException("Build artifact [" + artifact
View Full Code Here

      moduleXml.setContents(XMLParser.toXMLString(module));
   }

   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() + "]");
      }

      return artifacts;
   }
View Full Code Here

      String groupId = dependency.getGroupId();
      groupId = (groupId == null) || groupId.equals("") ? DEFAULT_GROUPID : groupId;

      for (MavenPlugin mavenPlugin : listConfiguredPlugins(managedPlugin, effectivePlugin))
      {
         Dependency temp = mavenPlugin.getDependency();
         if (DependencyBuilder.areEquivalent(temp, DependencyBuilder.create(dependency).setGroupId(groupId)))
         {
            return mavenPlugin;
         }
      }
View Full Code Here

         ShellMessages
                  .warn(shell,
                           "There is an update pending. Restart Forge for the update to take effect. To abort this update, type 'forge update-abort'");
         return;
      }
      Dependency forgeDistribution = getLatestAvailableDistribution();
      if (forgeDistribution == null)
      {
         ShellMessages.info(shell, "Forge is up to date! Enjoy!");
      }
      else
      {
         shell.print(ShellColor.YELLOW, "***INFO*** ");
         shell.print("This Forge installation will be updated to ");
         shell.println(ShellColor.BOLD, forgeDistribution.getVersion());
         if (prompt.promptBoolean("Is that ok ?", true))
         {
            updateForge(forgeDistribution);
         }
      }
View Full Code Here

         {
            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-scaffoldx-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.");
            }
         }

         ShellMessages.info(out, "Invoking build with underlying build system.");
         Resource<?> artifact = project.getFacet(PackagingFacet.class).createBuilder().runTests(false).build();
         if ((artifact != null) && artifact.exists())
         {
            MetadataFacet meta = project.getFacet(MetadataFacet.class);
            Dependency dep = meta.getOutputDependency();

            ShellMessages.info(out, "Installing plugin artifact.");

            // TODO Figure out a better plugin versioning strategy than random numbers, also see if unloading is
            // possible to avoid this entirely.
            createModule(
                     project,
                     DependencyBuilder.create(dep).setVersion(
                              dep.getVersion() + "-" + UUID.randomUUID().toString()),
                     artifact, apiVersion);
         }
         else
         {
            throw new IllegalStateException("Build artifact [" + artifact
View Full Code Here

      moduleXml.setContents(XMLParser.toXMLString(module));
   }

   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() + "]");
      }

      return artifacts;
   }
View Full Code Here

      }

      DependencyFacet deps = pluginProject.getFacet(DependencyFacet.class);

      String apiVersion = null;
      Dependency directDependency = deps.getDirectDependency(SHELL_API);
      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(SHELL_API);
         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(SHELL_API);
         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-scaffoldx-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(shell, "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(shell,
                     "Plugin has a dependency on internal Forge API [" + dependency
                              + "] - this is not allowed and may cause failures.");
         }
      }

      ShellMessages.info(shell, "Invoking build with underlying build system.");
      // Build the whole project
      // Inter-module dependencies are not resolved when mvn package is just run. Perhaps it should install ?
      Resource<?> artifact;
      if (rootProject.equals(pluginProject))
      {
         artifact = rootProject.getFacet(PackagingFacet.class).createBuilder().runTests(false).build();
      }
      else
      {
         rootProject.getFacet(PackagingFacet.class).createBuilder().addArguments("clean", "install").runTests(false).build();
         artifact = pluginProject.getFacet(PackagingFacet.class).getFinalArtifact();
      }
      // However, get only the necessary plugin artifact
      if ((artifact != null) && artifact.exists())
      {
         MetadataFacet meta = rootProject.getFacet(MetadataFacet.class);
         Dependency dep = meta.getOutputDependency();

         ShellMessages.info(shell, "Installing plugin artifact.");

         // TODO Figure out a better plugin versioning strategy than random numbers, also see if unloading is
         // possible to avoid this entirely.
         createModule(
                  pluginProject,
                  DependencyBuilder.create(dep).setVersion(
                           dep.getVersion() + "-" + UUID.randomUUID().toString()),
                  artifact, apiVersion);
      }
      else
      {
         throw new IllegalStateException("Build artifact [" + artifact
View Full Code Here

    */
   Project findPluginProject(final Project rootProject, final Dependency coordinates)
   {
      final Project pluginProject;
      Model rootPom = rootProject.getFacet(MavenCoreFacet.class).getPOM();
      Dependency projectDependency = DependencyBuilder.create()
               .setGroupId(rootPom.getGroupId() == null ? rootPom.getParent().getGroupId() : rootPom.getGroupId())
               .setArtifactId(rootPom.getArtifactId()).setPackagingType(rootPom.getPackaging());

      // 1) Check if the root project is a multimodule project
      if (projectDependency.getPackagingTypeEnum() == PackagingType.BASIC)
      {
         Project tempPluginProject = null;
         DirectoryResource projectDir = rootProject.getProjectRoot();
         for (String module : rootPom.getModules())
         {
View Full Code Here

      moduleXml.setContents(XMLParser.toXMLString(module));
   }

   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(shell, "Could not resolve dependency [" + d.toCoordinates() + "]");
      }

      return artifacts;
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.project.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.