Package org.jboss.forge.project

Examples of org.jboss.forge.project.Project


   }

   private void completeJavaPaths(final PluginCommandCompleterState state, final OptionMetadata option,
            final Map<OptionMetadata, Object> valueMap, final ResourceFilter filter)
   {
      Project project = shell.getCurrentProject();
      if ((project != null) && project.hasFacet(JavaSourceFacet.class))
      {
         ArrayList<String> results = new ArrayList<String>();
         String[] values;

         if (valueMap.isEmpty())
         {
            values = new String[] { "" };
         }
         else if (valueMap.get(option) instanceof String[])
         {
            values = (String[]) valueMap.get(option);
         }
         else if (valueMap.get(option) == null)
         {
            values = new String[] { "" };
         }
         else
         {
            values = new String[] { String.valueOf(valueMap.get(option)) };
         }

         String val = values[values.length - 1];
         for (Resource<?> r : new JavaPathspecParser(project.getFacet(JavaSourceFacet.class), val + "*")
                  .resolve(filter))
         {
            // Add result to the results list, and append a '.' if the
            // resource has children.
            String name = ("~".equals(val) ? "~." : "") + r.getName()
View Full Code Here


   @Override
   public List<Object> getCompletionTokens()
   {
      List<Object> result = new ArrayList<Object>();

      Project project = shell.getCurrentProject();
      List<Facet> allFacets = factory.getFacets();
      for (Facet facet : allFacets)
      {
         if (!project.hasFacet(facet.getClass()))
         {
            result.add(ConstraintInspector.getName(facet.getClass()));
         }
      }
View Full Code Here

      out.println();
      out.println("Type " + out.renderColor(ShellColor.BOLD, "'list-commands'") + " for a list of available " +
               "commands in the current Resource context.");

      out.println();
      Project currentProject = shell.getCurrentProject();
      if (currentProject != null)
      {
         out.println("Currently operating on the Project located at ["
                  + currentProject.getProjectRoot().getFullyQualifiedName() + "]");
      }
      else
      {
         out.println("You are not working on a project. Type " + out.renderColor(ShellColor.BOLD, "'help new-project'")
                  + " to get started.");
View Full Code Here

   {
      DirectoryResource savedLocation = shell.getCurrentDirectory();
      try
      {
         shell.setCurrentResource(buildDir);
         Project project = shell.getCurrentProject();
         if (project == null)
         {
            throw new IllegalStateException("Unable to recognise plugin project in ["
                     + buildDir.getFullyQualifiedName() + "]");
         }

         DependencyFacet deps = project.getFacet(DependencyFacet.class);
         if (!deps.hasEffectiveDependency(DependencyBuilder.create("org.jboss.forge:forge-shell-api"))
                  && !prompt.promptBoolean("The project does not appear to be a Forge Plugin Project, install anyway?",
                           false))
         {
            throw new Abort("Installation aborted");
         }

         List<Dependency> dependencies = deps.getDependencies();
         for (Dependency dependency : dependencies) {
            if ("org.jboss.forge".equals(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));
            }
         }

         ShellMessages.info(out, "Invoking build with underlying build system.");
         Resource<?> artifact = project.getFacet(PackagingFacet.class).executeBuild();
         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
View Full Code Here

      if (!dir.exists())
      {
         dir.mkdirs();
      }

      Project project = null;

      if (type.equals(PackagingType.JAR) || type.equals(PackagingType.BUNDLE))
      {
         project = projectFactory.createProject(dir,
                  DependencyFacet.class,
                  MetadataFacet.class,
                  JavaSourceFacet.class,
                  ResourceFacet.class);
      }
      else if (type.equals(PackagingType.WAR))
      {
         project = projectFactory.createProject(dir,
                  DependencyFacet.class,
                  MetadataFacet.class,
                  WebResourceFacet.class,
                  JavaSourceFacet.class,
                  ResourceFacet.class);
      }
      else
      {
         project = projectFactory.createProject(dir,
                  DependencyFacet.class,
                  MetadataFacet.class);
      }

      DirectoryResource parentDir = project.getProjectRoot().getParent().reify(DirectoryResource.class);
      if (parentDir != null) {
         for (ProjectAssociationProvider provider : providers) {
            if (provider.canAssociate(project, parentDir)
                     && shell.promptBoolean("Add new project as a sub-project of [" + parentDir.getFullyQualifiedName()
                              + "]?"))
            {
               provider.associate(project, parentDir);
            }
         }
      }

      MetadataFacet meta = project.getFacet(MetadataFacet.class);
      meta.setProjectName(name);
      meta.setTopLevelPackage(javaPackage);

      PackagingFacet packaging = project.getFacet(PackagingFacet.class);
      packaging.setPackagingType(type);

      DependencyFacet deps = project.getFacet(DependencyFacet.class);
      deps.addRepository(KnownRepository.JBOSS_NEXUS);

      if (packaging.getPackagingType().equals(PackagingType.JAR) && createMain)
      {
         project.getFacet(JavaSourceFacet.class).saveJavaSource(JavaParser
                  .create(JavaClass.class)
                  .setPackage(javaPackage)
                  .setName("Main")
                  .addMethod("public static void main(String[] args) {}")
                  .setBody("System.out.println(\"Hi there! I was forged as part of the project you call " + name
                           + ".\");")
                  .getOrigin());
      }

      if (finalName != null)
      {
         packaging.setFinalName(finalName);
      }
      else
      {
         packaging.setFinalName(name);
      }

      if (project.hasFacet(ResourceFacet.class))
      {
         project.getFacet(ResourceFacet.class).createResource("<forge/>".toCharArray(), "META-INF/forge.xml");
      }
      /*
       * Only change the environment after success!
       */
      shell.setCurrentResource(project.getProjectRoot());
      ShellMessages.success(out,
               "Created project [" + name + "] in new working directory [" + dir.getFullyQualifiedName() + "]");
   }
View Full Code Here

   @Override
   public List<Object> getCompletionTokens()
   {
      List<Object> result = new ArrayList<Object>();

      Project project = shell.getCurrentProject();
      List<Facet> allFacets = factory.getFacets();
      for (Facet facet : allFacets)
      {
         if (project.hasFacet(facet.getClass()))
         {
            result.add(ConstraintInspector.getName(facet.getClass()));
         }
      }
View Full Code Here

      out.println();
      out.println("Type " + out.renderColor(ShellColor.BOLD, "'list-commands'") + " for a list of available " +
               "commands in the current Resource context.");

      out.println();
      Project currentProject = shell.getCurrentProject();
      if (currentProject != null)
      {
         out.println("Currently operating on the Project located at ["
                  + currentProject.getProjectRoot().getFullyQualifiedName() + "]");
      }
      else
      {
         out.println("You are not working on a project. Type " + out.renderColor(ShellColor.BOLD, "'help new-project'")
                  + " to get started.");
View Full Code Here

   }

   @Unwraps
   public Configuration getConfiguration() throws ConfigurationException
   {
      Project project = shell.getCurrentProject();
      if ((project != null) && !project.equals(this.currentProject))
      {
         currentProject = project;
         projectConfig = new ScopedConfigurationAdapter();
         XMLConfiguration forgeXml;
         try {
View Full Code Here

   {
      DirectoryResource savedLocation = shell.getCurrentDirectory();
      try
      {
         shell.setCurrentResource(buildDir);
         Project project = shell.getCurrentProject();
         if (project == null)
         {
            throw new IllegalStateException("Unable to recognise plugin project in ["
                     + buildDir.getFullyQualifiedName() + "]");
         }

         DependencyFacet deps = project.getFacet(DependencyFacet.class);
         if (!deps.hasDependency(DependencyBuilder.create("org.jboss.forge:forge-shell-api"))
                  && !prompt.promptBoolean("The project does not appear to be a Forge Plugin Project, install anyway?",
                           false))
         {
            throw new Abort("Installation aborted");
         }

         List<Dependency> dependencies = deps.getDependencies();
         for (Dependency dependency : dependencies) {
            if ("org.jboss.forge".equals(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.removeDependency(dependency);
               deps.addDependency(DependencyBuilder.create(dependency).setScopeType(ScopeType.PROVIDED));
            }
         }

         ShellMessages.info(out, "Invoking build with underlying build system.");
         Resource<?> artifact = project.getFacet(PackagingFacet.class).executeBuild();
         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
View Full Code Here

      this.projectInstance = projectInstance;
   }

   public String convert(final PromptType promptType, String value)
   {
      Project project = projectInstance.get();

      if (value != null)
      {
         if (PromptType.JAVA_CLASS.equals(promptType))
         {
            if (value.startsWith("~.") && (project != null))
            {
               if (project.hasFacet(JavaSourceFacet.class))
               {
                  value = value.replaceFirst("~", project.getFacet(JavaSourceFacet.class).getBasePackage());
               }
            }
         }
         else if (PromptType.JAVA_PACKAGE.equals(promptType))
         {
            if (value.startsWith("~.") && (project != null))
            {
               if (project.hasFacet(JavaSourceFacet.class))
               {
                  value = value.replaceFirst("~", project.getFacet(JavaSourceFacet.class).getBasePackage());
               }
            }
         }
      }
      return value;
View Full Code Here

TOP

Related Classes of org.jboss.forge.project.Project

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.