use of org.jetbrains.jps.model.JpsProject in project intellij-community by JetBrains.
the class FormsInstrumenter method build.
@Override
public ExitCode build(CompileContext context, ModuleChunk chunk, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, OutputConsumer outputConsumer) throws ProjectBuildException, IOException {
final JpsProject project = context.getProjectDescriptor().getProject();
final JpsUiDesignerConfiguration config = JpsUiDesignerExtensionService.getInstance().getOrCreateUiDesignerConfiguration(project);
if (!config.isInstrumentClasses()) {
return ExitCode.NOTHING_DONE;
}
final Map<File, Collection<File>> srcToForms = FORMS_TO_COMPILE.get(context);
FORMS_TO_COMPILE.set(context, null);
if (srcToForms == null || srcToForms.isEmpty()) {
return ExitCode.NOTHING_DONE;
}
final Set<File> formsToCompile = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
for (Collection<File> files : srcToForms.values()) {
formsToCompile.addAll(files);
}
if (JavaBuilderUtil.isCompileJavaIncrementally(context)) {
final ProjectBuilderLogger logger = context.getLoggingManager().getProjectBuilderLogger();
if (logger.isEnabled()) {
logger.logCompiledFiles(formsToCompile, getPresentableName(), "Compiling forms:");
}
}
try {
final Collection<File> platformCp = ProjectPaths.getPlatformCompilationClasspath(chunk, false);
final List<File> classpath = new ArrayList<>();
classpath.addAll(ProjectPaths.getCompilationClasspath(chunk, false));
// forms_rt.jar
classpath.add(getResourcePath(GridConstraints.class));
final Map<File, String> chunkSourcePath = ProjectPaths.getSourceRootsWithDependents(chunk);
// sourcepath for loading forms resources
classpath.addAll(chunkSourcePath.keySet());
final JpsSdk<JpsDummyElement> sdk = chunk.representativeTarget().getModule().getSdk(JpsJavaSdkType.INSTANCE);
final InstrumentationClassFinder finder = ClassProcessingBuilder.createInstrumentationClassFinder(sdk, platformCp, classpath, outputConsumer);
try {
final Map<File, Collection<File>> processed = instrumentForms(context, chunk, chunkSourcePath, finder, formsToCompile, outputConsumer);
final OneToManyPathsMapping sourceToFormMap = context.getProjectDescriptor().dataManager.getSourceToFormMap();
for (Map.Entry<File, Collection<File>> entry : processed.entrySet()) {
final File src = entry.getKey();
final Collection<File> forms = entry.getValue();
final Collection<String> formPaths = new ArrayList<>(forms.size());
for (File form : forms) {
formPaths.add(form.getPath());
}
sourceToFormMap.update(src.getPath(), formPaths);
srcToForms.remove(src);
}
// clean mapping
for (File srcFile : srcToForms.keySet()) {
sourceToFormMap.remove(srcFile.getPath());
}
} finally {
finder.releaseResources();
}
} finally {
context.processMessage(new ProgressMessage("Finished instrumenting forms [" + chunk.getPresentableShortName() + "]"));
}
return ExitCode.OK;
}
use of org.jetbrains.jps.model.JpsProject in project intellij-community by JetBrains.
the class JpsLibraryOrderEntry method getLibraryLevel.
@Override
public String getLibraryLevel() {
final JpsElementReference<? extends JpsCompositeElement> reference = myDependencyElement.getLibraryReference().getParentReference();
final JpsCompositeElement parent = reference.resolve();
if (parent instanceof JpsGlobal)
return LibraryTablesRegistrar.APPLICATION_LEVEL;
if (parent instanceof JpsProject)
return LibraryTablesRegistrar.PROJECT_LEVEL;
if (parent instanceof JpsModule)
return LibraryTableImplUtil.MODULE_LEVEL;
return LibraryTablesRegistrar.PROJECT_LEVEL;
}
use of org.jetbrains.jps.model.JpsProject in project intellij-community by JetBrains.
the class FilteredResourceRootDescriptor method createFileFilter.
@NotNull
@Override
public FileFilter createFileFilter() {
final JpsProject project = getTarget().getModule().getProject();
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
final JpsCompilerExcludes excludes = configuration.getCompilerExcludes();
return file -> !excludes.isExcluded(file) && configuration.isResourceFile(file, getRootFile());
}
use of org.jetbrains.jps.model.JpsProject in project intellij-plugins by JetBrains.
the class FlexBuildTargetType method computeAllTargets.
@NotNull
public List<FlexBuildTarget> computeAllTargets(@NotNull final JpsModel model) {
final List<FlexBuildTarget> result = new ArrayList<>();
final JpsProject project = model.getProject();
for (JpsTypedRunConfiguration<JpsFlashRunnerParameters> runConfig : project.getRunConfigurations(JpsFlashRunConfigurationType.INSTANCE)) {
ContainerUtilRt.addIfNotNull(result, FlexBuildTarget.create(project, runConfig.getType(), runConfig.getName()));
}
for (JpsTypedRunConfiguration<JpsFlexUnitRunnerParameters> runConfig : project.getRunConfigurations(JpsFlexUnitRunConfigurationType.INSTANCE)) {
ContainerUtilRt.addIfNotNull(result, FlexBuildTarget.create(project, runConfig.getType(), runConfig.getName()));
}
for (JpsTypedModule<JpsFlexBuildConfigurationManager> module : project.getModules(JpsFlexModuleType.INSTANCE)) {
for (JpsFlexBuildConfiguration bc : module.getProperties().getBuildConfigurations()) {
result.add(FlexBuildTarget.create(bc, null));
final BuildConfigurationNature nature = bc.getNature();
if (nature.isApp() && (nature.isDesktopPlatform() || nature.isMobilePlatform())) {
result.add(FlexBuildTarget.create(bc, Boolean.TRUE));
result.add(FlexBuildTarget.create(bc, Boolean.FALSE));
}
}
}
return result;
}
use of org.jetbrains.jps.model.JpsProject in project android by JetBrains.
the class AndroidPreDexBuilder method doBuild.
private static boolean doBuild(@NotNull AndroidPreDexBuildTarget target, @NotNull DirtyFilesHolder<AndroidPreDexBuildTarget.MyRootDescriptor, AndroidPreDexBuildTarget> holder, @NotNull BuildOutputConsumer outputConsumer, @NotNull CompileContext context) throws IOException, ProjectBuildException {
final List<Pair<File, String>> filesToPreDex = new ArrayList<Pair<File, String>>();
holder.processDirtyFiles(new FileProcessor<AndroidPreDexBuildTarget.MyRootDescriptor, AndroidPreDexBuildTarget>() {
@Override
public boolean apply(AndroidPreDexBuildTarget target, File file, AndroidPreDexBuildTarget.MyRootDescriptor root) throws IOException {
if (canBePreDexed(file) && file.isFile()) {
filesToPreDex.add(Pair.create(file, root.getModuleName()));
}
return true;
}
});
final JpsProject project = target.getProject();
AndroidPlatform platform = null;
for (JpsModule module : project.getModules()) {
if (AndroidJpsUtil.getExtension(module) != null) {
platform = AndroidJpsUtil.getAndroidPlatform(module, context, BUILDER_NAME);
break;
}
}
if (platform == null) {
return false;
}
if (!filesToPreDex.isEmpty()) {
final File outputDir = target.getOutputFile(context);
for (Pair<File, String> pair : filesToPreDex) {
context.checkCanceled();
final File srcFile = pair.getFirst();
final String moduleName = pair.getSecond();
final String srcFilePath = srcFile.getAbsolutePath();
final File outputFile;
if (moduleName != null) {
context.processMessage(new ProgressMessage("Pre-dex [" + moduleName + "]"));
outputFile = new File(new File(outputDir, moduleName), srcFile.getName());
} else {
context.processMessage(new ProgressMessage("Pre-dex: " + srcFile.getName()));
final String outputFileName = getOutputFileNameForExternalJar(srcFile);
if (outputFileName == null) {
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, "Cannot pre-dex file " + srcFilePath + ": incorrect path", srcFilePath));
return false;
}
outputFile = new File(outputDir, outputFileName);
}
if (AndroidJpsUtil.createDirIfNotExist(outputFile.getParentFile(), context, BUILDER_NAME) == null) {
return false;
}
if (!AndroidDexBuilder.runDex(platform, outputFile.getPath(), new String[] { srcFilePath }, context, project, outputConsumer, BUILDER_NAME, srcFile.getName(), null)) {
return false;
}
}
}
return true;
}
Aggregations