Package org.jboss.forge.project

Examples of org.jboss.forge.project.Project


    /**
     * An exception-safe method of determining whether a directory contains a project.
     */
    public boolean containsProject(final DirectoryResource dir)
    {
        Project project = findProject(dir);
        return project != null;
    }
View Full Code Here


        return project != null;
    }

    public Project findProject(final DirectoryResource dir)
    {
        Project project = null;
        if (dir != null)
        {
            List<ProjectLocator> locators = getLocators();
            for (ProjectLocator locator : locators)
            {
View Full Code Here

   {
      getShell().setCurrentResource(createTempFolder());
      queueInputLines("");
      getShell().execute("new-project --named test --topLevelPackage com.test");

      Project project = getProject();
      tempFolder = project.getProjectRoot();
      tempFolders.add(tempFolder);
      return project;
   }
View Full Code Here

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

      Project project = locator.createProject(root);
      while ((project == null) && (root.getParent() instanceof DirectoryResource))
      {
         root = (DirectoryResource) root.getParent();
         project = locator.createProject(root);
      }
View Full Code Here

      return root;
   }

   public Project findProjectRecursively(final DirectoryResource startingPath)
   {
      Project project = null;
      List<ProjectLocator> locators = getLocators();
      for (ProjectLocator locator : locators)
      {
         DirectoryResource root = locateRecursively(startingPath, locator);
View Full Code Here

      return project;
   }

   public Project createProject(final DirectoryResource root, final Class<? extends Facet>... facetTypes)
   {
      Project project = null;
      List<ProjectLocator> locators = getLocators();
      for (ProjectLocator locator : locators)
      {
         if (root != null)
         {
View Full Code Here

   /**
    * An exception-safe method of determining whether a directory contains a project.
    */
   public boolean containsProject(final DirectoryResource dir)
   {
      Project project = findProject(dir);
      return project != null;
   }
View Full Code Here

      return project != null;
   }

   public Project findProject(final DirectoryResource dir)
   {
      Project project = null;
      if (dir != null)
      {
         List<ProjectLocator> locators = getLocators();
         for (ProjectLocator locator : locators)
         {
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 (project.hasFacet(JavaSourceFacet.class))
      {
         DirectoryResource sourceFolder = project.getFacet(JavaSourceFacet.class).getSourceFolder();
         createTopLevelPackage(sourceFolder, javaPackage);
      }

      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

   public void associate(final Project project, final DirectoryResource parentDir)
   {
      if (canAssociate(project, parentDir))
      {

         Project parent = projectFactory.findProject(parentDir);
         MavenCoreFacet parentMCF = parent.getFacet(MavenCoreFacet.class);
         Model parentPom = parentMCF.getPOM();
         parentPom.setPackaging("pom");
         parentPom.addModule(project.getProjectRoot().toString());
         parentMCF.setPOM(parentPom);
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.