Package org.jboss.forge.projects

Examples of org.jboss.forge.projects.Project


public class MavenProjectLocator implements ProjectLocator
{
   @Override
   public Project createProject(final DirectoryResource dir)
   {
      Project project = new AbstractProject()
      {
         @Override
         public boolean supports(ProjectFacet type)
         {
            return true;
         }

         @Override
         public DirectoryResource getProjectRoot()
         {
            return dir;
         }

         @Override
         public String toString()
         {
            return dir.toString();
         }
      };

      List<Class<? extends ProjectFacet>> result = new ArrayList<Class<? extends ProjectFacet>>();
      result.add(MavenFacetImpl.class);
      result.add(MavenMetadataFacet.class);
      result.add(MavenPackagingFacet.class);
      result.add(MavenDependencyFacet.class);
      result.add(MavenResourceFacet.class);
     
      MavenFacetImpl mavenFacetImpl = new MavenFacetImpl();
      mavenFacetImpl.setOrigin(project);
      if (!project.install(mavenFacetImpl))
      {
         throw new IllegalStateException("Could not install Maven into Project located at ["
                  + dir.getFullyQualifiedName() + "]");
      }
View Full Code Here


   @Override
   public boolean install()
   {
      if (super.install())
      {
         Project project = getOrigin();
         String topLevelPackage = project.getFacet(MetadataFacet.class).getTopLevelPackage();
         JavaClass testClass = JavaParser.create(JavaClass.class).setPackage(topLevelPackage);
         testClass.setName("AbstractTestCase").setAbstract(true);
         JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
         try
         {
            facet.saveTestJavaSource(testClass.getEnclosingType());
         }
         catch (FileNotFoundException ffe)
View Full Code Here

      if (targetDir.mkdirs() || overwrite.getValue())
      {
         ProjectType value = type.getValue();

         Project project = null;
         if (value != null)
         {
            project = projectFactory.createProject(targetDir, value.getRequiredFacets());
         }
         else
         {
            project = projectFactory.createProject(targetDir);
         }

         if (project != null)
         {
            MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);
            metadataFacet.setProjectName(named.getValue());
            metadataFacet.setTopLevelPackage(topLevelPackage.getValue());

            context.setAttribute(Project.class, project);
         }
View Full Code Here

               return true;
            }
         };
      }

      Project result = null;
      for (ExportedInstance<ProjectLocator> instance : registry.getExportedInstances(ProjectLocator.class))
      {
         DirectoryResource r = target;
         while (r != null && result == null)
         {
View Full Code Here

   }

   @Override
   public Project createProject(DirectoryResource target, Iterable<Class<? extends ProjectFacet>> facetTypes)
   {
      Project result = null;
      for (ExportedInstance<ProjectLocator> instance : registry.getExportedInstances(ProjectLocator.class))
      {
         ProjectLocator locator = instance.get();
         result = locator.createProject(target);
         if (result != null)
            break;
      }

      if (result != null && facetTypes != null)
      {
         for (Class<? extends ProjectFacet> facetType : facetTypes)
         {
            ProjectFacet facet = factory.create(facetType, result);
            if (!result.install(facet))
            {
               throw new IllegalStateException("Could not install Facet [" + facet + "] of type [" + facetType
                        + "] into Project [" + result + "]");
            }
         }
      }

      if (result != null)
      {
         DirectoryResource parentDir = result.getProjectRoot().getParent().reify(DirectoryResource.class);
         if (parentDir != null)
         {
            for (ExportedInstance<ProjectAssociationProvider> providerInstance : registry
                     .getExportedInstances(ProjectAssociationProvider.class))
            {
View Full Code Here

      DirectoryResource directory = targetLocation.getValue();
      DirectoryResource targetDir = directory.getChildDirectory(named.getValue());

      if (targetDir.mkdirs() || overwrite.getValue())
      {
         Project project = projectFactory.createProject(targetDir, type.getValue());
         if (project != null)
         {
            MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);
            metadataFacet.setProjectName(named.getValue());
            metadataFacet.setTopLevelPackage(topLevelPackage.getValue());

            context.setAttribute(Project.class, project);
         }
View Full Code Here

   private FacetFactory factory;

   @Override
   public Project createProject(final DirectoryResource dir)
   {
      Project project = new MavenProject(dir);

      MavenFacet mavenFacet = factory.create(MavenFacet.class, project);
      MavenPluginFacet mavenPluginFacet = factory.create(MavenPluginFacet.class, project);
      MetadataFacet metadataFacet = factory.create(MavenMetadataFacet.class, project);
      PackagingFacet packagingFacet = factory.create(MavenPackagingFacet.class, project);
      DependencyFacet dependencyFacet = factory.create(MavenDependencyFacet.class, project);
      ResourceFacet resourceFacet = factory.create(MavenResourceFacet.class, project);

      if (!(project.install(mavenFacet)
               && project.install(metadataFacet)
               && project.install(packagingFacet)
               && project.install(dependencyFacet)
               && project.install(resourceFacet)
               && project.install(mavenPluginFacet)

      ))
      {
         throw new IllegalStateException("Could not install Maven into Project located at ["
                  + dir.getFullyQualifiedName() + "]");
View Full Code Here

   @Override
   public void associate(final Project project, final DirectoryResource parentDir)
   {
      if (canAssociate(project, parentDir))
      {
         Project parent = projectFactory.findProject(parentDir);
         MavenFacet parentMavenFacet = parent.getFacet(MavenFacet.class);
         Model parentPom = parentMavenFacet.getPOM();
         parentPom.setPackaging("pom");

         String moduleDir = project.getProjectRoot().getFullyQualifiedName()
                  .substring(parent.getProjectRoot().getFullyQualifiedName().length());
         if (moduleDir.startsWith("/"))
            moduleDir = moduleDir.substring(1);

         parentPom.addModule(moduleDir);
         parentMavenFacet.setPOM(parentPom);

         MavenFacet projectMavenFacet = project.getFacet(MavenFacet.class);
         Model pom = projectMavenFacet.getPOM();

         Parent projectParent = new Parent();
         projectParent.setGroupId(parentPom.getGroupId());
         projectParent.setArtifactId(parentPom.getArtifactId());
         projectParent.setVersion(parentPom.getVersion());

         DirectoryResource root = project.getProjectRoot();
         DirectoryResource parentRoot = parent.getProjectRoot();

         // Calculate parent relative path
         String delta = root.getFullyQualifiedName().substring(parentRoot.getFullyQualifiedName().length());
         String relativePath = delta.replaceAll("/(\\w+)", "../") + "pom.xml";
         projectParent.setRelativePath(relativePath);
View Full Code Here

   }

   @Override
   public boolean isInstalled()
   {
      Project project = getOrigin();
      MavenFacet mavenFacet = project.getFacet(MavenFacet.class);
      String packagingType = project.getFacet(PackagingFacet.class).getPackagingType();

      return mavenFacet.isInstalled()
               && packagingType.equals("war");
   }
View Full Code Here

TOP

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