public CompileModuleChunkTarget()

in generate-ant/src/main/java/com/intellij/compiler/ant/CompileModuleChunkTarget.java [24:112]


  public CompileModuleChunkTarget(final Project project,
                                  ModuleChunk moduleChunk,
                                  VirtualFile[] sourceRoots,
                                  VirtualFile[] testSourceRoots,
                                  File baseDir,
                                  GenerationOptions genOptions) {
    final String moduleChunkName = moduleChunk.getName();
    //noinspection HardCodedStringLiteral
    final Tag compilerArgs = new Tag("compilerarg", Couple.of("line", BuildProperties.propertyRef(
      BuildProperties.getModuleChunkCompilerArgsProperty(moduleChunkName))));
    //noinspection HardCodedStringLiteral
    final Couple<String> classpathRef = Couple.of("refid", BuildProperties.getClasspathProperty(moduleChunkName));
    final Tag classpathTag = new Tag("classpath", classpathRef);
    //noinspection HardCodedStringLiteral
    final Tag bootclasspathTag =
      new Tag("bootclasspath", Couple.of("refid", BuildProperties.getBootClasspathProperty(moduleChunkName)));
    final PatternSetRef compilerExcludes = new PatternSetRef(BuildProperties.getExcludedFromCompilationProperty(moduleChunkName));

    final String mainTargetName = BuildProperties.getCompileTargetName(moduleChunkName);
    final @NonNls String productionTargetName = mainTargetName + ".production";
    final @NonNls String testsTargetName = mainTargetName + ".tests";

    final ChunkCustomCompilerExtension[] customCompilers = moduleChunk.getCustomCompilers();
    final String customCompilersDependency = customCompilers.length != 0 || genOptions.enableFormCompiler ?
                                             BuildProperties.TARGET_REGISTER_CUSTOM_COMPILERS : "";
    final int modulesCount = moduleChunk.getModules().length;
    Target mainTarget = new Target(mainTargetName, productionTargetName + "," + testsTargetName,
                                   GenerateAntBundle.message("generated.ant.build.compile.modules.main.target.comment", modulesCount,
                                                          moduleChunkName), null);
    String dependenciesProduction = getChunkDependenciesString(moduleChunk);
    if (customCompilersDependency.length() > 0) {
      if (dependenciesProduction != null && dependenciesProduction.length() > 0) {
        dependenciesProduction = customCompilersDependency + "," + dependenciesProduction;
      }
      else {
        dependenciesProduction = customCompilersDependency;
      }
    }
    Target productionTarget = new Target(productionTargetName, dependenciesProduction,
                                         GenerateAntBundle.message("generated.ant.build.compile.modules.production.classes.target.comment",
                                                                modulesCount, moduleChunkName), null);
    String dependenciesTests = (customCompilersDependency.length() != 0 ? customCompilersDependency + "," : "") + productionTargetName;
    Target testsTarget = new Target(testsTargetName, dependenciesTests,
                                    GenerateAntBundle.message("generated.ant.build.compile.modules.tests.target.comment", modulesCount,
                                                           moduleChunkName), BuildProperties.PROPERTY_SKIP_TESTS);

    if (sourceRoots.length > 0) {
      final String outputPathRef = BuildProperties.propertyRef(BuildProperties.getOutputPathProperty(moduleChunkName));
      final Tag srcTag = new Tag("src", Couple.of("refid", BuildProperties.getSourcepathProperty(moduleChunkName)));
      productionTarget.add(new Mkdir(outputPathRef));
      createCustomCompilerTasks(project, moduleChunk, genOptions, false, customCompilers, compilerArgs, bootclasspathTag,
                                classpathTag, compilerExcludes, srcTag, outputPathRef, productionTarget);
      if (customCompilers.length == 0 || genOptions.enableFormCompiler) {
        final Javac javac = new Javac(genOptions, moduleChunk, outputPathRef);
        javac.add(compilerArgs);
        javac.add(bootclasspathTag);
        javac.add(classpathTag);
        javac.add(srcTag);
        javac.add(compilerExcludes);
        productionTarget.add(javac);
      }
      productionTarget.add(createCopyTask(project, moduleChunk, sourceRoots, outputPathRef, baseDir, genOptions));
    }

    if (testSourceRoots.length > 0) {

      final String testOutputPathRef = BuildProperties.propertyRef(BuildProperties.getOutputPathForTestsProperty(moduleChunkName));
      final Tag srcTag = new Tag("src", Couple.of("refid", BuildProperties.getTestSourcepathProperty(moduleChunkName)));
      final Couple<String> testClasspathRef = Couple.of("refid", BuildProperties.getTestClasspathProperty(moduleChunkName));
      final Tag testClassPath = new Tag("classpath", testClasspathRef);
      testsTarget.add(new Mkdir(testOutputPathRef));
      createCustomCompilerTasks(project, moduleChunk, genOptions, true, customCompilers, compilerArgs, bootclasspathTag,
                                testClassPath, compilerExcludes, srcTag, testOutputPathRef, testsTarget);
      if (customCompilers.length == 0 || genOptions.enableFormCompiler) {
        final Javac javac = new Javac(genOptions, moduleChunk, testOutputPathRef);
        javac.add(compilerArgs);
        javac.add(bootclasspathTag);
        javac.add(testClassPath);
        javac.add(srcTag);
        javac.add(compilerExcludes);
        testsTarget.add(javac);
      }
      testsTarget.add(createCopyTask(project, moduleChunk, testSourceRoots, testOutputPathRef, baseDir, genOptions));
    }

    add(mainTarget);
    add(productionTarget, 1);
    add(testsTarget, 1);
  }