use of org.jetbrains.jps.incremental.ModuleBuildTarget in project intellij-community by JetBrains.
the class JavaModuleBuildTargetType method computeAllTargets.
@NotNull
@Override
public List<ModuleBuildTarget> computeAllTargets(@NotNull JpsModel model) {
List<JpsModule> modules = model.getProject().getModules();
List<ModuleBuildTarget> targets = new ArrayList<>(modules.size());
for (JpsModule module : modules) {
targets.add(new ModuleBuildTarget(module, this));
}
return targets;
}
use of org.jetbrains.jps.incremental.ModuleBuildTarget in project intellij-community by JetBrains.
the class CompileScopeTestBuilder method module.
public CompileScopeTestBuilder module(JpsModule module) {
myTargets.add(new ModuleBuildTarget(module, JavaModuleBuildTargetType.PRODUCTION));
myTargets.add(new ModuleBuildTarget(module, JavaModuleBuildTargetType.TEST));
return this;
}
use of org.jetbrains.jps.incremental.ModuleBuildTarget in project intellij-community by JetBrains.
the class CompilingGroovycRunner method getGenerationOutputs.
@Override
protected Map<ModuleBuildTarget, String> getGenerationOutputs(CompileContext context, ModuleChunk chunk, Map<ModuleBuildTarget, String> finalOutputs) throws IOException {
if (!myForStubs)
return super.getGenerationOutputs(context, chunk, finalOutputs);
Map<ModuleBuildTarget, String> generationOutputs = new HashMap<>();
File commonRoot = GroovyBuilder.getStubRoot(context);
for (ModuleBuildTarget target : chunk.getTargets()) {
File targetRoot = new File(commonRoot, target.getModule().getName() + File.separator + target.getTargetType().getTypeId());
if (targetRoot.exists() && !FileUtil.deleteWithRenaming(targetRoot)) {
throw new IOException("External build cannot clean " + targetRoot.getPath());
}
if (!targetRoot.mkdirs()) {
throw new IOException("External build cannot create " + targetRoot.getPath());
}
generationOutputs.put(target, targetRoot.getPath());
}
return generationOutputs;
}
use of org.jetbrains.jps.incremental.ModuleBuildTarget in project android by JetBrains.
the class AndroidDexBuildTarget method doComputeRootDescriptors.
@NotNull
@Override
protected List<BuildRootDescriptor> doComputeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(myModule);
assert extension != null;
if (extension.isLibrary()) {
return Collections.emptyList();
}
final Map<String, String> libPackage2ModuleName = new THashMap<String, String>(FileUtil.PATH_HASHING_STRATEGY);
final Set<String> appClassesDirs = new THashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
final Set<String> javaClassesDirs = new THashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
final Set<String> libClassesDirs = new THashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
final File moduleClassesDir = new ModuleBuildTarget(myModule, JavaModuleBuildTargetType.PRODUCTION).getOutputDir();
if (moduleClassesDir != null) {
appClassesDirs.add(moduleClassesDir.getPath());
}
AndroidJpsUtil.processClasspath(dataPaths, myModule, new AndroidDependencyProcessor() {
@Override
public void processAndroidLibraryPackage(@NotNull File file, @NotNull JpsModule depModule) {
libPackage2ModuleName.put(file.getPath(), depModule.getName());
}
@Override
public void processAndroidLibraryOutputDirectory(@NotNull File dir) {
libClassesDirs.add(dir.getPath());
}
@Override
public void processJavaModuleOutputDirectory(@NotNull File dir) {
javaClassesDirs.add(dir.getPath());
}
@Override
public boolean isToProcess(@NotNull AndroidDependencyType type) {
return type == AndroidDependencyType.ANDROID_LIBRARY_PACKAGE || type == AndroidDependencyType.ANDROID_LIBRARY_OUTPUT_DIRECTORY || type == AndroidDependencyType.JAVA_MODULE_OUTPUT_DIR;
}
}, false, false);
if (extension.isPackTestCode()) {
final File testModuleClassesDir = new ModuleBuildTarget(myModule, JavaModuleBuildTargetType.TEST).getOutputDir();
if (testModuleClassesDir != null) {
appClassesDirs.add(testModuleClassesDir.getPath());
}
}
final List<BuildRootDescriptor> result = new ArrayList<BuildRootDescriptor>();
for (String classesDir : appClassesDirs) {
result.add(new MyClassesDirBuildRootDescriptor(this, new File(classesDir), ClassesDirType.ANDROID_APP));
}
for (String classesDir : libClassesDirs) {
result.add(new MyClassesDirBuildRootDescriptor(this, new File(classesDir), ClassesDirType.ANDROID_LIB));
}
for (String classesDir : javaClassesDirs) {
result.add(new MyClassesDirBuildRootDescriptor(this, new File(classesDir), ClassesDirType.JAVA));
}
final File preDexOutputDir = AndroidPreDexBuildTarget.getOutputDir(dataPaths);
for (Map.Entry<String, String> entry : libPackage2ModuleName.entrySet()) {
final String libPackage = entry.getKey();
final String moduleName = entry.getValue();
final File libPackageJarFile = new File(libPackage);
assert AndroidPreDexBuilder.canBePreDexed(libPackageJarFile);
result.add(new MyJarBuildRootDescriptor(this, libPackageJarFile, true, false));
result.add(new MyJarBuildRootDescriptor(this, new File(new File(preDexOutputDir, moduleName), libPackageJarFile.getName()), true, true));
}
final AndroidPlatform platform = AndroidJpsUtil.getAndroidPlatform(myModule, null, null);
if (platform != null) {
for (String jarOrLibDir : AndroidJpsUtil.getExternalLibraries(dataPaths, myModule, platform, false, false, true)) {
File file = new File(jarOrLibDir);
File preDexedFile = file;
if (AndroidPreDexBuilder.canBePreDexed(file)) {
final String preDexedFileName = AndroidPreDexBuilder.getOutputFileNameForExternalJar(file);
if (preDexedFileName != null) {
preDexedFile = new File(preDexOutputDir, preDexedFileName);
}
}
result.add(new MyJarBuildRootDescriptor(this, file, false, false));
result.add(new MyJarBuildRootDescriptor(this, preDexedFile, false, true));
}
}
for (String path : AndroidJpsUtil.getProvidedLibraries(dataPaths, myModule)) {
result.add(new MyProvidedJarBuildRootDescriptor(this, new File(path)));
}
return result;
}
use of org.jetbrains.jps.incremental.ModuleBuildTarget in project android by JetBrains.
the class AndroidAdditionalRootProviderService method getAdditionalRoots.
@NotNull
@Override
public List<JavaSourceRootDescriptor> getAdditionalRoots(@NotNull BuildTarget<JavaSourceRootDescriptor> target, BuildDataPaths dataPaths) {
ModuleBuildTarget buildTarget = (ModuleBuildTarget) target;
final File generatedSourcesRoot = AndroidJpsUtil.getGeneratedSourcesStorage(buildTarget.getModule(), dataPaths);
final List<JavaSourceRootDescriptor> result = new ArrayList<JavaSourceRootDescriptor>();
addRoot(result, buildTarget, new File(generatedSourcesRoot, AndroidJpsUtil.AAPT_GENERATED_SOURCE_ROOT_NAME));
addRoot(result, buildTarget, new File(generatedSourcesRoot, AndroidJpsUtil.AIDL_GENERATED_SOURCE_ROOT_NAME));
addRoot(result, buildTarget, new File(generatedSourcesRoot, AndroidJpsUtil.RENDERSCRIPT_GENERATED_SOURCE_ROOT_NAME));
addRoot(result, buildTarget, new File(generatedSourcesRoot, AndroidJpsUtil.BUILD_CONFIG_GENERATED_SOURCE_ROOT_NAME));
addRoot(result, buildTarget, AndroidJpsUtil.getCopiedSourcesStorage(buildTarget.getModule(), dataPaths));
return result;
}
Aggregations