Package org.jboss.forge.resources

Examples of org.jboss.forge.resources.DirectoryResource


    * @param coordinates The maven coordinates information of the required plugin
    * @throws Abort
    */
   public void installFromProject(final DirectoryResource buildDir, final Dependency coordinates) throws Abort
   {
      DirectoryResource root = projectFactory.findProjectRootRecusively(buildDir);
      Project rootProject = projectFactory.findProject(root);
      if (rootProject == null)
      {
         throw new IllegalArgumentException("Unable to recognise plugin project in ["
                  + buildDir.getFullyQualifiedName() + "]");
View Full Code Here


      // 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())
         {
            DirectoryResource moduleDir = projectDir.getChildDirectory(module);
            // 1.1) If yes, traverse the projects
            Project moduleProject = projectFactory.findProject(moduleDir);
            // If module is empty, avoid infinite recursion
            if (moduleProject.equals(rootProject))
            {
View Full Code Here

            final String apiVersion) throws Abort
   {

      boolean dependenciesAsResourceRoot = needDependenciesAsResourceRoot(project);

      DirectoryResource moduleDir = getOrCreatePluginModuleDirectory(dep);
      String pluginName = dep.getGroupId() + "." + dep.getArtifactId();
      String pluginSlot = dep.getVersion();

      FileResource<?> moduleXml = (FileResource<?>) moduleDir.getChild("module.xml");
      if (moduleXml.exists()
               && !shell.promptBoolean(
                        "An existing installation for version [" + pluginSlot
                                 + "] of this plugin was found. Replace it?", true))
      {
         throw new Abort("Aborted.");
      }

      moduleXml.delete();
      moduleXml.createNewFile();

      // <resource-root path="maven-dependency.jar" />
      Node module = XMLParser.parse(getClass().getResourceAsStream(MODULE_TEMPLATE_XML));
      module.attribute("name", pluginName);
      module.attribute("slot", pluginSlot);
      Node resources = module.getSingle("resources");

      resources.createChild("resource-root").attribute("path", dep.getArtifactId() + ".jar");

      if (dependenciesAsResourceRoot)
      {
         writeResourceRoots(project, module, moduleDir, resources);
      }

      // Copy the compiled JAR into the module directory
      FileResource<?> jar = moduleDir.getChild(dep.getArtifactId() + ".jar").reify(FileResource.class);
      jar.createNewFile();
      jar.setContents(artifact.getResourceInputStream());

      // <module name="org.jboss.forge:main" />
      Node dependencies = module.getSingle("dependencies");
View Full Code Here

      }
   }

   private void createDependenciesModule(final Project project, final Dependency dep)
   {
      DirectoryResource dependencyDir = getOrCreatePluginDependenciesModuleDirectory(dep);
      String pluginName = dep.getGroupId() + "." + dep.getArtifactId();
      String pluginSlot = dep.getVersion();

      FileResource<?> moduleXml = (FileResource<?>) dependencyDir.getChild("module.xml");
      moduleXml.delete();
      moduleXml.createNewFile();

      // <resource-root path="maven-dependency.jar" />
      Node module = XMLParser.parse(getClass().getResourceAsStream(MODULE_TEMPLATE_XML));
View Full Code Here

      }
   }

   private DirectoryResource getOrCreatePluginModuleDirectory(final Dependency dep)
   {
      DirectoryResource pluginDir = environment.getPluginDirectory();

      List<String> groupId = Arrays.asList(dep.getGroupId().split("\\."));
      List<String> artifactId = Arrays.asList(dep.getArtifactId().split("\\."));
      DirectoryResource dir = pluginDir;
      for (String segment : groupId)
      {
         dir = dir.getOrCreateChildDirectory(segment);
      }

      for (String segment : artifactId)
      {
         dir = dir.getOrCreateChildDirectory(segment);
      }

      dir = dir.getOrCreateChildDirectory(dep.getVersion());
      return dir;
   }
View Full Code Here

      return dir;
   }

   private DirectoryResource getOrCreatePluginDependenciesModuleDirectory(final Dependency dep)
   {
      DirectoryResource pluginDir = environment.getPluginDirectory();

      List<String> groupId = Arrays.asList(dep.getGroupId().split("\\."));
      List<String> artifactId = Arrays.asList(dep.getArtifactId().split("\\."));
      DirectoryResource dir = pluginDir;
      for (String segment : groupId)
      {
         dir = dir.getOrCreateChildDirectory(segment);
      }

      for (String segment : artifactId)
      {
         dir = dir.getOrCreateChildDirectory(segment);
      }

      dir = dir.getOrCreateChildDirectory("dependencies");
      dir = dir.getOrCreateChildDirectory(dep.getVersion());
      return dir;
   }
View Full Code Here

      String p = path;

      if (path.startsWith("~"))
      {
         DirectoryResource base = java.getBasePackageResource();

         if (path.length() == 1)
         {
            if (filter.accept(base))
            {
View Full Code Here

       * Special case for directories required.
       */
      file = file.getAbsoluteFile();
      if (file.isDirectory())
      {
         return new DirectoryResource(this, file);
      }

      final String name = file.getName();

      synchronized (this)
View Full Code Here

      }
   }

   public DirectoryResource findProjectRootRecusively(final DirectoryResource currentDirectory)
   {
      DirectoryResource root = null;
      List<ProjectLocator> locators = getLocators();
      for (ProjectLocator locator : locators)
      {
         root = locateRecursively(currentDirectory, locator);
         if (root != null)
View Full Code Here

      return root;
   }

   public DirectoryResource locateRecursively(final DirectoryResource startingDirectory, final ProjectLocator locator)
   {
      DirectoryResource root = startingDirectory;

      while (!locator.containsProject(root) && (root.getParent() instanceof DirectoryResource))
      {
         root = (DirectoryResource) root.getParent();
      }

      if (!locator.containsProject(root))
      {
         root = null;
View Full Code Here

TOP

Related Classes of org.jboss.forge.resources.DirectoryResource

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.