Package org.jboss.forge.project

Examples of org.jboss.forge.project.Project


   }

   @Test
   public void shouldGenerateTestNGBasedTest() throws Exception
   {
      final Project project = initializeJavaProject();
      final MavenCoreFacet mavenCoreFacet = project.getFacet(MavenCoreFacet.class);

      queueInputLines("", "", "", "", "", "");
      getShell().execute("java new-class --named Bean --package com.test");
      getShell().execute("arquillian setup --containerName GLASSFISH_EMBEDDED_3.1 --testFramework testng");
      getShell().execute("arquillian create-test --class com.test.Bean");

      assertThat(mavenCoreFacet.getPOM().getDependencies(), hasItem(new DependencyMatcher("testng")));
      assertThat(mavenCoreFacet.getPOM().getDependencies(), hasItem(new DependencyMatcher("arquillian-testng-container")));

      final JavaSource<?> testClass = project.getFacet(JavaSourceFacet.class)
                                             .getTestJavaResource("com.test.BeanTest")
                                             .getJavaSource();
      assertTrue("@Test TestNG should be imported", testClass.hasImport("org.testng.annotations.Test"));

      getShell().execute("build --profile arquillian-glassfish-embedded-3.1");
View Full Code Here


      return Deployments.basicPluginInfrastructure();
   }

   private Project installContainer(final String container, final List<DependencyMatcher> dependencies) throws Exception
   {
      Project project = initializeJavaProject();

      MavenCoreFacet mavenCoreFacet = project.getFacet(MavenCoreFacet.class);

      List<Profile> profiles = mavenCoreFacet.getPOM().getProfiles();

      assertThat(profiles.size(), is(0));

      queueInputLines(container, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
      getShell().execute("arquillian setup");

      assertThat(mavenCoreFacet.getPOM().getProfiles().size(), is(1));
      Profile profile = mavenCoreFacet.getPOM().getProfiles().get(0);

      for (DependencyMatcher dependency : dependencies)
      {
         assertThat(profile.getDependencies(), hasItem(dependency));
      }

      Model pom = mavenCoreFacet.getPOM();
      DependencyMatcher arqBom = new DependencyMatcher("arquillian-bom");

      assertThat("Verify arquillian:bom was added to DependencyManagement ",
            pom.getDependencyManagement().getDependencies(), hasItem(arqBom));

      assertNotNull("Verify that the plugin use a version property for arquillian core",
            pom.getProperties().get(ArquillianPlugin.ARQ_CORE_VERSION_PROP_NAME));

      assertNotNull("Verify that the plugin use a version property for junit",
            pom.getProperties().get(new JUnitFacet().getVersionPropertyName()));

      ResourceFacet facet = project.getFacet(ResourceFacet.class);
      FileResource<?> arquillianXml = facet.getTestResource("arquillian.xml");

      assertThat(arquillianXml, is(notNullValue()));
      assertThat(arquillianXml.exists(), is(true));
View Full Code Here

   }

   @Test
   public void installMultipleTimesShouldOverwriteProfile() throws Exception
   {
      Project project = initializeJavaProject();

      MavenCoreFacet coreFacet = project.getFacet(MavenCoreFacet.class);

      List<Profile> profiles = coreFacet.getPOM().getProfiles();
      assertThat(profiles.size(), is(0));

      queueInputLines("JBOSS_AS_REMOTE_7", "19", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
View Full Code Here

   }

   @Test
   public void installContainerWithDownload() throws Exception
   {
      Project project = initializeJavaProject();

      MavenCoreFacet coreFacet = project.getFacet(MavenCoreFacet.class);

      List<Profile> profiles = coreFacet.getPOM().getProfiles();
      assertThat(profiles.size(), is(0));

      // answer y to download server
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);
         DependencyBuilder shellApi = DependencyBuilder.create("org.jboss.forge:forge-shell-api");

         String apiVersion = null;
         if (!deps.hasEffectiveDependency(shellApi)
                  && !prompt.promptBoolean(
                           "The project does not appear to be a Forge Plugin Project, install anyway?",
                           false))
         {
            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
View Full Code Here

    }

    @Override
    public Project createProject(final DirectoryResource dir)
    {
        Project result = new ProjectImpl(factory, dir);
        MavenCoreFacet maven = coreFacetInstance.get();
        maven.setProject(result);
        if (!maven.isInstalled())
        {
            result.installFacet(maven);
        }
        else
            result.registerFacet(maven);
       
        if(!result.hasFacet(MavenCoreFacet.class))
        {
            throw new IllegalStateException("Could not create Maven project [MavenCoreFacet could not be installed.]");
        }

        return result;
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

   @Inject
   private Shell shell;

   public void updateConfigLocation(@Observes final PackagingChanged event)
   {
      Project project = event.getProject();
      if (project.hasFacet(CDIFacetImpl.class))
      {
         PackagingType oldType = event.getOldPackagingType();
         PackagingType newType = event.getNewPackagingType();
         shell.printlnVerbose("Packaging type change detected; moving beans.xml " +
                  "from [" + oldType + "] to [" + newType + "]");
View Full Code Here

   public void doInit(@Observes final InitProject event)
   {
      DirectoryResource currentDirectory = shell.getCurrentDirectory();

      Project newProject = null;

      try
      {
         final DirectoryResource newRoot = projectFactory.findProjectRootRecusively(currentDirectory);
         if (newRoot != null)
         {
            Project oldProject = cp.getCurrent();

            Project temp = new BaseProject()
            {
               public DirectoryResource getProjectRoot()
               {
                  return newRoot;
               }
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);
         DependencyBuilder shellApi = DependencyBuilder.create("org.jboss.forge:forge-shell-api");

         String apiVersion = null;
         if (!deps.hasEffectiveDependency(shellApi)
                  && !prompt.promptBoolean(
                           "The project does not appear to be a Forge Plugin Project, install anyway?",
                           false))
         {
            throw new Abort("Installation aborted");
         }
         else
         {
            if (apiVersion == null)
            {
               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-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
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.