Пример #1
0
  @org.junit.Test
  public void testAddsDefaultIncludeAndExcludePatternsWhenTestScanningIsOff() {
    configureTask();
    test.setScanForTestClasses(false);

    ConfigurableFileTree files = (ConfigurableFileTree) test.getCandidateClassFiles();
    assertThat(files.getDir(), equalTo(classesDir));
    assertThat(files.getIncludes(), equalTo(toSet("**/*Tests.class", "**/*Test.class")));
    assertThat(files.getExcludes(), equalTo(toSet("**/Abstract*.class")));
  }
Пример #2
0
  @org.junit.Test
  public void testScansForTestClassesInTheTestClassesDir() {
    configureTask();
    test.include("include");
    test.exclude("exclude");

    FileTree classFiles = test.getCandidateClassFiles();
    assertThat(classFiles, instanceOf(ConfigurableFileTree.class));
    ConfigurableFileTree files = (ConfigurableFileTree) classFiles;
    assertThat(files.getDir(), equalTo(classesDir));
    assertThat(files.getIncludes(), equalTo(toSet("include")));
    assertThat(files.getExcludes(), equalTo(toSet("exclude")));
  }
Пример #3
0
  @InputFiles
  @SkipWhenEmpty
  public FileCollection getSourceFiles() {
    Project project = getProject();

    File sourceDir = getSourceDir();

    if (sourceDir == null) {
      return project.files();
    }

    ConfigurableFileTree configurableFileTree = project.fileTree(sourceDir);

    configurableFileTree.include(getSoySrcIncludes());
    configurableFileTree.include(getSrcIncludes());

    return configurableFileTree;
  }
Пример #4
0
  public void validateConfiguration() {
    // check the location of the static content/jsps etc
    try {
      if ((getWebAppSourceDirectory() == null) || !getWebAppSourceDirectory().exists()) {
        throw new InvalidUserDataException(
            "Webapp source directory "
                + (getWebAppSourceDirectory() == null
                    ? "null"
                    : getWebAppSourceDirectory().getCanonicalPath())
                + " does not exist");
      } else {
        logger.info("Webapp source directory = " + getWebAppSourceDirectory().getCanonicalPath());
      }
    } catch (IOException e) {
      throw new InvalidUserDataException("Webapp source directory does not exist", e);
    }

    // check reload mechanic
    if (!"automatic".equalsIgnoreCase(reload) && !"manual".equalsIgnoreCase(reload)) {
      throw new InvalidUserDataException(
          "invalid reload mechanic specified, must be 'automatic' or 'manual'");
    } else {
      logger.info("Reload Mechanic: " + reload);
    }

    // get the web.xml file if one has been provided, otherwise assume it is in the webapp src
    // directory
    if (getWebXml() == null) {
      setWebXml(new File(new File(getWebAppSourceDirectory(), "WEB-INF"), "web.xml"));
    }
    logger.info("web.xml file = " + getWebXml());

    // check if a jetty-env.xml location has been provided, if so, it must exist
    if (getJettyEnvXml() != null) {
      setJettyEnvXmlFile(jettyEnvXml);

      try {
        if (!getJettyEnvXmlFile().exists()) {
          throw new InvalidUserDataException(
              "jetty-env.xml file does not exist at location " + jettyEnvXml);
        } else {
          logger.info(" jetty-env.xml = " + getJettyEnvXmlFile().getCanonicalPath());
        }
      } catch (IOException e) {
        throw new InvalidUserDataException("jetty-env.xml does not exist");
      }
    }

    setExtraScanTargets(new ArrayList<File>());
    if (scanTargets != null) {
      for (File scanTarget : scanTargets) {
        logger.info("Added extra scan target:" + scanTarget);
        getExtraScanTargets().add(scanTarget);
      }
    }

    if (scanTargetPatterns != null) {
      for (ScanTargetPattern scanTargetPattern : scanTargetPatterns) {
        ConfigurableFileTree files = getProject().fileTree(scanTargetPattern.getDirectory());
        files.include(scanTargetPattern.getIncludes());
        files.exclude(scanTargetPattern.getExcludes());
        List<File> currentTargets = getExtraScanTargets();
        if (currentTargets != null && !currentTargets.isEmpty()) {
          currentTargets.addAll(files.getFiles());
        } else {
          setExtraScanTargets((List) files.asType(List.class));
        }
      }
    }
  }