[r=nik] automatically exclude from compilation annotation processors output

This commit is contained in:
Eugene Zhuravlev
2012-12-14 19:27:16 +01:00
parent 5aa6fe3572
commit 2c5e21bc40
21 changed files with 134 additions and 128 deletions
@@ -0,0 +1 @@
org.jetbrains.jps.incremental.java.AnnotationsExcludedJavaSourceRootProvider
@@ -21,7 +21,6 @@ import com.intellij.util.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsDummyElement;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.JpsSimpleElement;
import org.jetbrains.jps.model.java.*;
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;
@@ -41,30 +40,25 @@ import java.util.*;
* Date: 9/30/11
*/
public class ProjectPaths {
@NotNull
private final JpsProject myProject;
//private final Map<JpsJavaClasspathKind, Map<ModuleChunk, List<String>>> myCachedClasspath = new HashMap<JpsJavaClasspathKind, Map<ModuleChunk, List<String>>>();
public ProjectPaths(@NotNull JpsProject project) {
myProject = project;
private ProjectPaths() {
}
public Collection<File> getCompilationClasspathFiles(ModuleChunk chunk,
public static Collection<File> getCompilationClasspathFiles(ModuleChunk chunk,
boolean includeTests,
final boolean excludeMainModuleOutput,
final boolean exportedOnly) {
return getClasspathFiles(chunk, JpsJavaClasspathKind.compile(includeTests), excludeMainModuleOutput, ClasspathPart.WHOLE, exportedOnly);
}
public Collection<File> getPlatformCompilationClasspath(ModuleChunk chunk, boolean excludeMainModuleOutput) {
public static Collection<File> getPlatformCompilationClasspath(ModuleChunk chunk, boolean excludeMainModuleOutput) {
return getClasspathFiles(chunk, JpsJavaClasspathKind.compile(chunk.containsTests()), excludeMainModuleOutput, ClasspathPart.BEFORE_JDK, true);
}
public Collection<File> getCompilationClasspath(ModuleChunk chunk, boolean excludeMainModuleOutput) {
public static Collection<File> getCompilationClasspath(ModuleChunk chunk, boolean excludeMainModuleOutput) {
return getClasspathFiles(chunk, JpsJavaClasspathKind.compile(chunk.containsTests()), excludeMainModuleOutput, ClasspathPart.AFTER_JDK, true);
}
private Collection<File> getClasspathFiles(ModuleChunk chunk,
private static Collection<File> getClasspathFiles(ModuleChunk chunk,
JpsJavaClasspathKind kind,
final boolean excludeMainModuleOutput,
ClasspathPart classpathPart, final boolean exportedOnly) {
@@ -159,12 +153,12 @@ public class ProjectPaths {
}
@Nullable
public File getModuleOutputDir(JpsModule module, boolean forTests) {
public static File getModuleOutputDir(JpsModule module, boolean forTests) {
return JpsJavaExtensionService.getInstance().getOutputDirectory(module, forTests);
}
@Nullable
public File getAnnotationProcessorGeneratedSourcesOutputDir(JpsModule module, final boolean forTests, ProcessorConfigProfile profile) {
public static File getAnnotationProcessorGeneratedSourcesOutputDir(JpsModule module, final boolean forTests, ProcessorConfigProfile profile) {
final String sourceDirName = profile.getGeneratedSourcesDirectoryName(forTests);
if (profile.isOutputRelativeToContentRoot()) {
List<String> roots = module.getContentRootsList().getUrls();
@@ -20,6 +20,7 @@ import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsModuleSourceRoot;
/**
*
* @author nik
*/
public abstract class ExcludedJavaSourceRootProvider {
@@ -16,15 +16,11 @@
package org.jetbrains.jps.incremental;
import com.intellij.openapi.util.UserDataHolder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.ModuleChunk;
import org.jetbrains.jps.ProjectPaths;
import org.jetbrains.jps.api.CanceledStatus;
import org.jetbrains.jps.builders.logging.BuildLoggingManager;
import org.jetbrains.jps.cmdline.ProjectDescriptor;
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;
import org.jetbrains.jps.model.module.JpsModule;
/**
* @author Eugene Zhuravlev
@@ -33,8 +29,6 @@ import org.jetbrains.jps.model.module.JpsModule;
public interface CompileContext extends UserDataHolder, MessageHandler {
ProjectDescriptor getProjectDescriptor();
ProjectPaths getProjectPaths();
CompileScope getScope();
boolean isMake();
@@ -48,10 +42,6 @@ public interface CompileContext extends UserDataHolder, MessageHandler {
void removeBuildListener(BuildListener listener);
@NotNull
ProcessorConfigProfile getAnnotationProcessingProfile(JpsModule module);
boolean shouldDifferentiate(ModuleChunk chunk);
CanceledStatus getCancelStatus();
@@ -18,10 +18,8 @@ package org.jetbrains.jps.incremental;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.util.EventDispatcher;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.ModuleChunk;
import org.jetbrains.jps.ProjectPaths;
import org.jetbrains.jps.api.CanceledStatus;
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
import org.jetbrains.jps.builders.logging.BuildLoggingManager;
@@ -30,10 +28,6 @@ import org.jetbrains.jps.incremental.messages.BuildMessage;
import org.jetbrains.jps.incremental.messages.FileDeletedEvent;
import org.jetbrains.jps.incremental.messages.FileGeneratedEvent;
import org.jetbrains.jps.incremental.messages.ProgressMessage;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration;
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;
import org.jetbrains.jps.model.module.JpsModule;
import java.util.*;
@@ -49,14 +43,12 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
private final MessageHandler myDelegateMessageHandler;
private final Set<ModuleBuildTarget> myNonIncrementalModules = new HashSet<ModuleBuildTarget>();
private final ProjectPaths myProjectPaths;
private volatile long myCompilationStartStamp;
private final ProjectDescriptor myProjectDescriptor;
private final Map<String, String> myBuilderParams;
private final CanceledStatus myCancelStatus;
private volatile float myDone = -1.0f;
private EventDispatcher<BuildListener> myListeners = EventDispatcher.create(BuildListener.class);
private Map<JpsModule, ProcessorConfigProfile> myAnnotationProcessingProfileMap;
public CompileContextImpl(CompileScope scope,
ProjectDescriptor pd, boolean isMake,
@@ -72,7 +64,6 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
myIsProjectRebuild = isProjectRebuild;
myIsMake = !isProjectRebuild && isMake;
myDelegateMessageHandler = delegateMessageHandler;
myProjectPaths = new ProjectPaths(pd.getProject());
}
@Override
@@ -85,11 +76,6 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
myCompilationStartStamp = System.currentTimeMillis();
}
@Override
public ProjectPaths getProjectPaths() {
return myProjectPaths;
}
@Override
public boolean isMake() {
return myIsMake;
@@ -121,34 +107,6 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
myListeners.removeListener(listener);
}
@Override
@NotNull
public ProcessorConfigProfile getAnnotationProcessingProfile(JpsModule module) {
final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(
getProjectDescriptor().getProject());
Map<JpsModule, ProcessorConfigProfile> map = myAnnotationProcessingProfileMap;
if (map == null) {
map = new HashMap<JpsModule, ProcessorConfigProfile>();
final Map<String, JpsModule> namesMap = new HashMap<String, JpsModule>();
for (JpsModule m : getProjectDescriptor().getProject().getModules()) {
namesMap.put(m.getName(), m);
}
if (!namesMap.isEmpty()) {
for (ProcessorConfigProfile profile : compilerConfig.getAnnotationProcessingConfigurations()) {
for (String name : profile.getModuleNames()) {
final JpsModule mod = namesMap.get(name);
if (mod != null) {
map.put(mod, profile);
}
}
}
}
myAnnotationProcessingProfileMap = map;
}
final ProcessorConfigProfile profile = map.get(module);
return profile != null? profile : compilerConfig.getDefaultAnnotationProcessingConfiguration();
}
@Override
public void markNonIncremental(ModuleBuildTarget target) {
if (!target.isTests()) {
@@ -21,6 +21,7 @@ import com.intellij.util.SmartList;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.ProjectPaths;
import org.jetbrains.jps.builders.*;
import org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider;
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
@@ -69,9 +70,11 @@ public final class ModuleBuildTarget extends JVMModuleBuildTarget<JavaSourceRoot
if (outputDir != null) {
result.add(outputDir);
}
final ProcessorConfigProfile profile = context.getAnnotationProcessingProfile(getModule());
final JpsModule module = getModule();
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(module.getProject());
final ProcessorConfigProfile profile = configuration.getAnnotationProcessingProfile(module);
if (profile.isEnabled()) {
final File annotationOut = context.getProjectPaths().getAnnotationProcessorGeneratedSourcesOutputDir(getModule(), isTests(), profile);
final File annotationOut = ProjectPaths.getAnnotationProcessorGeneratedSourcesOutputDir(module, isTests(), profile);
if (annotationOut != null) {
result.add(annotationOut);
}
@@ -20,7 +20,6 @@ import com.intellij.util.SmartList;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.ProjectPaths;
import org.jetbrains.jps.builders.BuildRootIndex;
import org.jetbrains.jps.builders.BuildTarget;
import org.jetbrains.jps.builders.BuildTargetRegistry;
@@ -37,7 +36,6 @@ import org.jetbrains.jps.model.java.JavaSourceRootProperties;
import org.jetbrains.jps.model.java.JavaSourceRootType;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration;
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsTypedModuleSourceRoot;
import org.jetbrains.jps.service.JpsServiceManager;
@@ -113,34 +111,9 @@ public final class ResourcesTarget extends JVMModuleBuildTarget<ResourceRootDesc
addedRoots.add(rootFile);
}
final ProcessorConfigProfile profile = findAnnotationProcessingProfile(model);
if (profile != null) {
final File annotationOut = new ProjectPaths(model.getProject()).getAnnotationProcessorGeneratedSourcesOutputDir(getModule(), isTests(), profile);
if (annotationOut != null && !addedRoots.contains(annotationOut) && !FileUtil.filesEqual(annotationOut, getOutputDir())) {
roots.add(new ResourceRootDescriptor(annotationOut, this, true, "", computeRootExcludes(annotationOut, index)));
}
}
return roots;
}
@Nullable
private ProcessorConfigProfile findAnnotationProcessingProfile(JpsModel model) {
final Collection<ProcessorConfigProfile> allProfiles =
JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(model.getProject()).getAnnotationProcessingConfigurations();
ProcessorConfigProfile profile = null;
final String moduleName = getModule().getName();
for (ProcessorConfigProfile p : allProfiles) {
if (p.getModuleNames().contains(moduleName)) {
if (p.isEnabled()) {
profile = p;
}
break;
}
}
return profile;
}
@NotNull
@Override
public String getPresentableName() {
@@ -79,11 +79,9 @@ public abstract class ClassProcessingBuilder extends ModuleLevelBuilder {
try {
InstrumentationClassFinder finder = CLASS_FINDER.get(context); // try using shared finder
if (finder == null) {
final ProjectPaths paths = context.getProjectPaths();
final Collection<File> platformCp = paths.getPlatformCompilationClasspath(chunk, false);
final Collection<File> platformCp = ProjectPaths.getPlatformCompilationClasspath(chunk, false);
final Collection<File> classpath = new ArrayList<File>();
classpath.addAll(paths.getCompilationClasspath(chunk, false));
classpath.addAll(ProjectPaths.getCompilationClasspath(chunk, false));
classpath.addAll(ProjectPaths.getSourceRootsWithDependents(chunk).keySet());
finder = createInstrumentationClassFinder(platformCp, classpath, outputConsumer);
@@ -30,6 +30,7 @@ import gnu.trove.THashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.ModuleChunk;
import org.jetbrains.jps.ProjectPaths;
import org.jetbrains.jps.incremental.*;
import org.jetbrains.jps.incremental.messages.BuildMessage;
import org.jetbrains.jps.incremental.messages.CompilerMessage;
@@ -118,7 +119,7 @@ public class RmiStubsGenerator extends ClassProcessingBuilder {
OutputConsumer outputConsumer) {
ExitCode exitCode = ExitCode.NOTHING_DONE;
final Collection<File> classpath = context.getProjectPaths().getCompilationClasspath(chunk, false);
final Collection<File> classpath = ProjectPaths.getCompilationClasspath(chunk, false);
final StringBuilder buf = new StringBuilder();
for (File file : classpath) {
if (buf.length() > 0) {
@@ -0,0 +1,49 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jps.incremental.java;
import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.ProjectPaths;
import org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider;
import org.jetbrains.jps.model.java.JavaSourceRootType;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration;
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsModuleSourceRoot;
import java.io.File;
/**
* @author Eugene Zhuravlev
* Date: 12/14/12
*/
public class AnnotationsExcludedJavaSourceRootProvider extends ExcludedJavaSourceRootProvider{
@Override
public boolean isExcludedFromCompilation(@NotNull JpsModule module, @NotNull JpsModuleSourceRoot root) {
final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(module.getProject());
final ProcessorConfigProfile profile = compilerConfig.getAnnotationProcessingProfile(module);
if (!profile.isEnabled()) {
return false;
}
final File outputDir =
ProjectPaths.getAnnotationProcessorGeneratedSourcesOutputDir(module, JavaSourceRootType.TEST_SOURCE == root.getRootType(), profile);
return outputDir != null && FileUtil.filesEqual(outputDir, root.getFile());
}
}
@@ -207,12 +207,11 @@ public class JavaBuilder extends ModuleLevelBuilder {
return exitCode;
}
final ProjectPaths paths = context.getProjectPaths();
final ProjectDescriptor pd = context.getProjectDescriptor();
JavaBuilderUtil.ensureModuleHasJdk(chunk.representativeTarget().getModule(), context, BUILDER_NAME);
final Collection<File> classpath = paths.getCompilationClasspath(chunk, false/*context.isProjectRebuild()*/);
final Collection<File> platformCp = paths.getPlatformCompilationClasspath(chunk, false/*context.isProjectRebuild()*/);
final Collection<File> classpath = ProjectPaths.getCompilationClasspath(chunk, false/*context.isProjectRebuild()*/);
final Collection<File> platformCp = ProjectPaths.getPlatformCompilationClasspath(chunk, false/*context.isProjectRebuild()*/);
// begin compilation round
final DiagnosticSink diagnosticSink = new DiagnosticSink(context);
@@ -297,14 +296,18 @@ public class JavaBuilder extends ModuleLevelBuilder {
final TasksCounter counter = new TasksCounter();
COUNTER_KEY.set(context, counter);
final JpsJavaExtensionService javaExt = JpsJavaExtensionService.getInstance();
final JpsJavaCompilerConfiguration compilerConfig = javaExt.getCompilerConfiguration(context.getProjectDescriptor().getProject());
assert compilerConfig != null;
final Set<JpsModule> modules = chunk.getModules();
ProcessorConfigProfile profile = null;
if (modules.size() == 1) {
profile = context.getAnnotationProcessingProfile(modules.iterator().next());
final JpsModule module = modules.iterator().next();
profile = compilerConfig.getAnnotationProcessingProfile(module);
}
else {
// perform cycle-related validations
final JpsJavaExtensionService javaExt = JpsJavaExtensionService.getInstance();
Pair<String, LanguageLevel> pair = null;
for (JpsModule module : modules) {
final LanguageLevel moduleLevel = javaExt.getLanguageLevel(module);
@@ -322,7 +325,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
// check that all chunk modules are excluded from annotation processing
for (JpsModule module : modules) {
final ProcessorConfigProfile prof = context.getAnnotationProcessingProfile(module);
final ProcessorConfigProfile prof = compilerConfig.getAnnotationProcessingProfile(module);
if (prof.isEnabled()) {
final String message = "Annotation processing is not supported for module cycles. Please ensure that all modules from cycle [" + chunk.getName() + "] are excluded from annotation processing";
diagnosticSink.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, message));
@@ -596,7 +599,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
options.add("-A" + optionEntry.getKey() + "=" + optionEntry.getValue());
}
final File srcOutput = context.getProjectPaths().getAnnotationProcessorGeneratedSourcesOutputDir(
final File srcOutput = ProjectPaths.getAnnotationProcessorGeneratedSourcesOutputDir(
chunk.getModules().iterator().next(), chunk.containsTests(), profile
);
if (srcOutput != null) {
@@ -59,18 +59,14 @@ public class ModuleClasspathTest extends JpsRebuildTestCase {
public void testCompilationClasspath() {
ModuleChunk chunk = createChunk('main')
assertClasspath(["util/lib/exported.jar", "out/production/util", "/jdk.jar"],
getPathsList(getProjectPaths().getPlatformCompilationClasspath(chunk, true)))
getPathsList(ProjectPaths.getPlatformCompilationClasspath(chunk, true)))
assertClasspath(["main/lib/service.jar"],
getPathsList(getProjectPaths().getCompilationClasspath(chunk, true)))
}
private ProjectPaths getProjectPaths() {
return new ProjectPaths(myProject)
getPathsList(ProjectPaths.getCompilationClasspath(chunk, true)))
}
private def assertClasspath(String moduleName, boolean includeTests, List<String> expected) {
ModuleChunk chunk = createChunk(moduleName)
final List<String> classpath = getPathsList(new ProjectPaths(myProject).getCompilationClasspathFiles(chunk, includeTests, true, true))
final List<String> classpath = getPathsList(new ProjectPaths().getCompilationClasspathFiles(chunk, includeTests, true, true))
assertClasspath(expected, toSystemIndependentPaths(classpath))
}
@@ -18,6 +18,7 @@ package org.jetbrains.jps.model.java.compiler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsElement;
import org.jetbrains.jps.model.module.JpsModule;
import java.util.Collection;
import java.util.List;
@@ -36,10 +37,21 @@ public interface JpsJavaCompilerConfiguration extends JpsElement {
JpsCompilerExcludes getCompilerExcludes();
@NotNull
ProcessorConfigProfile getDefaultAnnotationProcessingConfiguration();
ProcessorConfigProfile getDefaultAnnotationProcessingProfile();
ProcessorConfigProfile addAnnotationProcessingProfile();
/**
* @return a list of currently configured profiles excluding default one
*/
@NotNull
Collection<ProcessorConfigProfile> getAnnotationProcessingConfigurations();
Collection<ProcessorConfigProfile> getAnnotationProcessingProfiles();
/**
* @param module
* @return annotation profile with which the given module is associated
*/
@NotNull
ProcessorConfigProfile getAnnotationProcessingProfile(JpsModule module);
void addResourcePattern(String pattern);
List<String> getResourcePatterns();
@@ -24,6 +24,7 @@ import org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes;
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration;
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerOptions;
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;
import org.jetbrains.jps.model.module.JpsModule;
import java.util.*;
@@ -42,6 +43,7 @@ public class JpsJavaCompilerConfigurationImpl extends JpsCompositeElementBase<Jp
private Map<String, String> myModulesByteCodeTargetLevels = new HashMap<String, String>();
private Map<String, JpsJavaCompilerOptions> myCompilerOptions = new HashMap<String, JpsJavaCompilerOptions>();
private String myJavaCompilerId = "Javac";
private Map<JpsModule, ProcessorConfigProfile> myAnnotationProcessingProfileMap;
public JpsJavaCompilerConfigurationImpl() {
}
@@ -84,13 +86,13 @@ public class JpsJavaCompilerConfigurationImpl extends JpsCompositeElementBase<Jp
@NotNull
@Override
public ProcessorConfigProfile getDefaultAnnotationProcessingConfiguration() {
public ProcessorConfigProfile getDefaultAnnotationProcessingProfile() {
return myDefaultAnnotationProcessingProfile;
}
@NotNull
@Override
public Collection<ProcessorConfigProfile> getAnnotationProcessingConfigurations() {
public Collection<ProcessorConfigProfile> getAnnotationProcessingProfiles() {
return myAnnotationProcessingProfiles;
}
@@ -163,4 +165,30 @@ public class JpsJavaCompilerConfigurationImpl extends JpsCompositeElementBase<Jp
myAnnotationProcessingProfiles.add(profile);
return profile;
}
@Override
@NotNull
public ProcessorConfigProfile getAnnotationProcessingProfile(JpsModule module) {
Map<JpsModule, ProcessorConfigProfile> map = myAnnotationProcessingProfileMap;
if (map == null) {
map = new HashMap<JpsModule, ProcessorConfigProfile>();
final Map<String, JpsModule> namesMap = new HashMap<String, JpsModule>();
for (JpsModule m : module.getProject().getModules()) {
namesMap.put(m.getName(), m);
}
if (!namesMap.isEmpty()) {
for (ProcessorConfigProfile profile : getAnnotationProcessingProfiles()) {
for (String name : profile.getModuleNames()) {
final JpsModule mod = namesMap.get(name);
if (mod != null) {
map.put(mod, profile);
}
}
}
}
myAnnotationProcessingProfileMap = map;
}
final ProcessorConfigProfile profile = map.get(module);
return profile != null? profile : getDefaultAnnotationProcessingProfile();
}
}
@@ -80,7 +80,7 @@ public class JpsJavaCompilerConfigurationSerializer extends JpsProjectExtensionS
for (Element profileTag : profiles) {
boolean isDefault = Boolean.parseBoolean(profileTag.getAttributeValue("default"));
if (isDefault) {
AnnotationProcessorProfileSerializer.readExternal(configuration.getDefaultAnnotationProcessingConfiguration(), profileTag);
AnnotationProcessorProfileSerializer.readExternal(configuration.getDefaultAnnotationProcessingProfile(), profileTag);
}
else {
AnnotationProcessorProfileSerializer.readExternal(configuration.addAnnotationProcessingProfile(), profileTag);
@@ -38,7 +38,7 @@ public class JpsCompilerConfigurationTest extends JpsSerializationTestCase {
assertNotNull(configuration);
assertFalse(configuration.isClearOutputDirectoryOnRebuild());
assertFalse(configuration.isAddNotNullAssertions());
ProcessorConfigProfile defaultProfile = configuration.getDefaultAnnotationProcessingConfiguration();
ProcessorConfigProfile defaultProfile = configuration.getDefaultAnnotationProcessingProfile();
assertTrue(defaultProfile.isEnabled());
assertFalse(defaultProfile.isObtainProcessorsFromClasspath());
assertEquals(FileUtil.toSystemDependentName(JpsPathUtil.urlToPath(getUrl("src"))), defaultProfile.getProcessorPath());
@@ -60,7 +60,6 @@ public class AndroidLibraryPackagingBuilder extends ModuleLevelBuilder {
continue;
}
final ProjectPaths projectPaths = context.getProjectPaths();
File outputDir = AndroidJpsUtil.getDirectoryForIntermediateArtifacts(context, module);
outputDir = AndroidJpsUtil.createDirIfNotExist(outputDir, context, BUILDER_NAME);
if (outputDir == null) {
@@ -68,7 +67,7 @@ public class AndroidLibraryPackagingBuilder extends ModuleLevelBuilder {
continue;
}
final File classesDir = projectPaths.getModuleOutputDir(module, false);
final File classesDir = ProjectPaths.getModuleOutputDir(module, false);
if (classesDir == null || !classesDir.isDirectory()) {
continue;
}
@@ -370,11 +370,10 @@ public class AndroidPackagingBuilder extends TargetBuilder<BuildRootDescriptor,
}
final String[] sourceRoots = AndroidJpsUtil.toPaths(AndroidJpsUtil.getSourceRootsForModuleAndDependencies(module));
final ProjectPaths paths = context.getProjectPaths();
final File intArtifactsDir = AndroidJpsUtil.getDirectoryForIntermediateArtifacts(context, module);
final File moduleOutputDir = paths.getModuleOutputDir(module, false);
final File moduleOutputDir = ProjectPaths.getModuleOutputDir(module, false);
if (moduleOutputDir == null) {
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, AndroidJpsBundle
.message("android.jps.errors.output.dir.not.specified", module.getName())));
@@ -3,6 +3,7 @@ package org.jetbrains.jps.android.builder;
import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.android.util.AndroidCommonUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.ProjectPaths;
import org.jetbrains.jps.android.AndroidJpsUtil;
import org.jetbrains.jps.android.model.JpsAndroidModuleExtension;
import org.jetbrains.jps.builders.BuildRootDescriptor;
@@ -39,7 +40,7 @@ public class AndroidPackagingBuildTarget extends AndroidBuildTarget {
@NotNull
@Override
public Collection<File> getOutputRoots(CompileContext context) {
final File moduleOutputDir = context.getProjectPaths().getModuleOutputDir(myModule, false);
final File moduleOutputDir = ProjectPaths.getModuleOutputDir(myModule, false);
final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(myModule);
if (moduleOutputDir == null || extension == null) {
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.asm4.ClassReader;
import org.jetbrains.jps.ModuleChunk;
import org.jetbrains.jps.ProjectPaths;
import org.jetbrains.jps.builders.BuildRootIndex;
import org.jetbrains.jps.builders.DirtyFilesHolder;
import org.jetbrains.jps.builders.FileProcessor;
@@ -372,7 +373,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
// IMPORTANT! must be the first in classpath
cp.add(getGroovyRtRoot().getPath());
for (File file : context.getProjectPaths().getCompilationClasspathFiles(chunk, chunk.containsTests(), false, false)) {
for (File file : ProjectPaths.getCompilationClasspathFiles(chunk, chunk.containsTests(), false, false)) {
cp.add(FileUtil.toCanonicalPath(file.getPath()));
}
@@ -85,11 +85,10 @@ public class FormsInstrumenter extends FormsBuilder {
}
try {
final ProjectPaths paths = context.getProjectPaths();
final Collection<File> platformCp = paths.getPlatformCompilationClasspath(chunk, false);
final Collection<File> platformCp = ProjectPaths.getPlatformCompilationClasspath(chunk, false);
final List<File> classpath = new ArrayList<File>();
classpath.addAll(paths.getCompilationClasspath(chunk, false));
classpath.addAll(ProjectPaths.getCompilationClasspath(chunk, false));
classpath.add(getResourcePath(GridConstraints.class)); // forms_rt.jar
final Map<File, String> chunkSourcePath = ProjectPaths.getSourceRootsWithDependents(chunk);
classpath.addAll(chunkSourcePath.keySet()); // sourcepath for loading forms resources