use of org.jetbrains.jps.builders.java.JavaSourceRootDescriptor in project intellij-community by JetBrains.
the class FormsBindingManager method findBoundSourceCandidates.
@NotNull
private static Collection<File> findBoundSourceCandidates(CompileContext context, final ModuleBuildTarget target, File form) throws IOException {
final List<JavaSourceRootDescriptor> targetRoots = context.getProjectDescriptor().getBuildRootIndex().getTargetRoots(target, context);
if (targetRoots.isEmpty()) {
return Collections.emptyList();
}
final String className = FormsParsing.readBoundClassName(form);
if (className == null) {
return Collections.emptyList();
}
for (JavaSourceRootDescriptor rd : targetRoots) {
final File boundSource = findSourceForClass(rd, className);
if (boundSource != null) {
return Collections.singleton(boundSource);
}
}
final Set<File> candidates = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
for (JavaSourceRootDescriptor rd : targetRoots) {
candidates.addAll(findPossibleSourcesForClass(rd, className));
}
return candidates;
}
use of org.jetbrains.jps.builders.java.JavaSourceRootDescriptor in project android by JetBrains.
the class AndroidSourceGeneratingBuilder method doBuild.
private static ModuleLevelBuilder.ExitCode doBuild(CompileContext context, ModuleChunk chunk, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws IOException {
final Map<JpsModule, MyModuleData> moduleDataMap = computeModuleDatas(chunk.getModules(), context);
if (moduleDataMap == null || moduleDataMap.size() == 0) {
return ExitCode.ABORT;
}
if (!checkVersions(moduleDataMap, context)) {
return ExitCode.ABORT;
}
checkAndroidDependencies(moduleDataMap, context);
if (!checkArtifacts(context)) {
return ExitCode.ABORT;
}
if (JavaBuilderUtil.isForcedRecompilationAllJavaModules(context)) {
if (!clearAndroidStorages(context, chunk.getModules())) {
return ExitCode.ABORT;
}
}
final Map<File, ModuleBuildTarget> idlFilesToCompile = new HashMap<File, ModuleBuildTarget>();
final Map<File, ModuleBuildTarget> rsFilesToCompile = new HashMap<File, ModuleBuildTarget>();
dirtyFilesHolder.processDirtyFiles(new FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget>() {
@Override
public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor sourceRoot) throws IOException {
final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(target.getModule());
if (extension == null) {
return true;
}
String fileName = file.getName();
if (FileUtilRt.extensionEquals(fileName, AIDL_EXTENSION)) {
idlFilesToCompile.put(file, target);
} else if (FileUtilRt.extensionEquals(fileName, RENDERSCRIPT_EXTENSION)) {
rsFilesToCompile.put(file, target);
}
return true;
}
});
boolean success = true;
final BuildDataManager dataManager = context.getProjectDescriptor().dataManager;
if (JavaBuilderUtil.isForcedRecompilationAllJavaModules(context)) {
for (JpsModule module : moduleDataMap.keySet()) {
final File generatedSourcesStorage = AndroidJpsUtil.getGeneratedSourcesStorage(module, dataManager);
if (generatedSourcesStorage.exists() && !deleteAndMarkRecursively(generatedSourcesStorage, context, BUILDER_NAME)) {
success = false;
}
final File generatedResourcesStorage = AndroidJpsUtil.getGeneratedResourcesStorage(module, dataManager);
if (generatedResourcesStorage.exists() && !deleteAndMarkRecursively(generatedResourcesStorage, context, BUILDER_NAME)) {
success = false;
}
}
}
if (!success) {
return ExitCode.ABORT;
}
boolean didSomething = false;
if (idlFilesToCompile.size() > 0) {
if (!runAidlCompiler(context, idlFilesToCompile, moduleDataMap)) {
success = false;
}
didSomething = true;
}
if (rsFilesToCompile.size() > 0) {
if (!runRenderscriptCompiler(context, rsFilesToCompile, moduleDataMap)) {
success = false;
}
didSomething = true;
}
MyExitStatus status = runAaptCompiler(context, moduleDataMap);
if (status == MyExitStatus.FAIL) {
success = false;
} else if (status == MyExitStatus.OK) {
didSomething = true;
}
status = runBuildConfigGeneration(context, moduleDataMap);
if (status == MyExitStatus.FAIL) {
success = false;
} else if (status == MyExitStatus.OK) {
didSomething = true;
}
if (!success) {
return ExitCode.ABORT;
}
status = copyGeneratedSources(moduleDataMap, dataManager, context);
if (status == MyExitStatus.FAIL) {
return ExitCode.ABORT;
} else if (status == MyExitStatus.OK) {
didSomething = true;
}
if (didSomething) {
return ExitCode.OK;
}
return ExitCode.NOTHING_DONE;
}
use of org.jetbrains.jps.builders.java.JavaSourceRootDescriptor in project android by JetBrains.
the class AndroidSourceGeneratingBuilder method computePackageForFile.
@Nullable
private static String computePackageForFile(@NotNull CompileContext context, @NotNull File file) throws IOException {
final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, file);
if (descriptor == null) {
return null;
}
final String relPath = FileUtil.getRelativePath(descriptor.root, FileUtilRt.getParentFile(file));
if (relPath == null) {
return null;
}
return FileUtil.toSystemIndependentName(relPath).replace('/', '.');
}
use of org.jetbrains.jps.builders.java.JavaSourceRootDescriptor in project android by JetBrains.
the class AndroidSourceGeneratingBuilder method getDependencyFolder.
@Nullable
private static String getDependencyFolder(@NotNull CompileContext context, @NotNull File sourceFile, @NotNull File genFolder) {
final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, sourceFile);
if (descriptor == null) {
return null;
}
final File sourceRoot = descriptor.root;
final File parent = FileUtilRt.getParentFile(sourceFile);
if (parent == null) {
return null;
}
if (FileUtil.filesEqual(parent, sourceRoot)) {
return genFolder.getPath();
}
final String relativePath = FileUtil.getRelativePath(sourceRoot, parent);
assert relativePath != null;
return genFolder.getPath() + '/' + relativePath;
}
use of org.jetbrains.jps.builders.java.JavaSourceRootDescriptor 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