IDEA-89930: I have to invoke Make multiple times and get "package doesn't exist" after updating code

This commit is contained in:
nik
2012-08-21 15:13:26 +04:00
parent d2dcc40aad
commit ebb7b40808
19 changed files with 262 additions and 217 deletions
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="?*.properties" />
<entry name="?*.xml" />
<entry name="?*.gif" />
<entry name="?*.png" />
<entry name="?*.jpeg" />
<entry name="?*.jpg" />
<entry name="?*.html" />
<entry name="?*.dtd" />
<entry name="?*.tld" />
<entry name="?*.ftl" />
</wildcardResourcePatterns>
<annotationProcessing enabled="false" useClasspath="true" />
</component>
</project>
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
@@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" />
<option name="OPTION_SCOPE" value="protected" />
<option name="OPTION_HIERARCHY" value="true" />
<option name="OPTION_NAVIGATOR" value="true" />
<option name="OPTION_INDEX" value="true" />
<option name="OPTION_SEPARATE_INDEX" value="true" />
<option name="OPTION_DOCUMENT_TAG_USE" value="false" />
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
<option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
<option name="OPTION_DEPRECATED_LIST" value="true" />
<option name="OTHER_OPTIONS" value="" />
<option name="HEAP_SIZE" />
<option name="LOCALE" />
<option name="OPEN_IN_BROWSER" value="true" />
</component>
<component name="ModuleEditorState">
<option name="LAST_EDITED_MODULE_NAME" />
<option name="LAST_EDITED_TAB_NAME" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA jdk" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<splitter-proportions />
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<splitter-proportions />
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions />
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<splitter-proportions />
</settings>
</state>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>IDEA jdk</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions />
</settings>
</state>
</states>
</component>
</project>
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/RecompileDependent.iml" filepath="$PROJECT_DIR$/RecompileDependent.iml" />
</modules>
</component>
</project>
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
@@ -0,0 +1,20 @@
Cleaning output files:
out/production/RecompileDependentTests/Server.class
End of files
Compiling files:
src/Server.java
End of files
Cleaning output files:
out/production/RecompileDependentTests/Client.class
out/production/RecompileDependentTests/Server.class
End of files
Compiling files:
src/Client.java
src/Server.java
End of files
Cleaning output files:
out/test/RecompileDependentTests/TestClient.class
End of files
Compiling files:
testSrc/TestClient.java
End of files
@@ -0,0 +1,3 @@
public class Server{
public static final int CONSTANT = 200;
}
@@ -0,0 +1,20 @@
/*
* 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.
*/
class Client {
public static void main(String[] args) {
System.out.println(Server.CONSTANT);
}
}
@@ -0,0 +1,18 @@
/*
* 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.
*/
public class Server{
public static final int CONSTANT = 100;
}
@@ -0,0 +1,20 @@
/*
* 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.
*/
class TestClient {
public static void main(String[] args) {
System.out.println(Server.CONSTANT + new com.MyClass().get());
}
}
@@ -70,20 +70,28 @@ public class BuildFSState extends FSState {
public boolean markDirty(@Nullable CompileContext context, File file, final RootDescriptor rd, @Nullable Timestamps tsStorage) throws IOException {
final FilesDelta roundDelta = getRoundDelta(CURRENT_ROUND_DELTA_KEY, context);
if (roundDelta != null) {
if (getContextModules(context).contains(rd.module)) {
if (isInCurrentContextModules(context, rd)) {
roundDelta.markRecompile(rd.root, file);
}
}
return super.markDirty(context, file, rd, tsStorage);
}
private static boolean isInCurrentContextModules(CompileContext context, RootDescriptor rd) {
if (context == null) {
return false;
}
Set<String> modules = CONTEXT_MODULES_KEY.get(context, Collections.<String>emptySet());
return modules.contains(rd.module) && rd.isTestRoot == context.isCompilingTests();
}
@Override
public boolean markDirtyIfNotDeleted(@Nullable CompileContext context, File file, final RootDescriptor rd, @Nullable Timestamps tsStorage) throws IOException {
final boolean marked = super.markDirtyIfNotDeleted(context, file, rd, tsStorage);
if (marked) {
final FilesDelta roundDelta = getRoundDelta(CURRENT_ROUND_DELTA_KEY, context);
if (roundDelta != null) {
if (getContextModules(context).contains(rd.module)) {
if (isInCurrentContextModules(context, rd)) {
roundDelta.markRecompile(rd.root, file);
}
}
@@ -207,11 +215,6 @@ public class BuildFSState extends FSState {
return marked;
}
@NotNull
private static Set<String> getContextModules(@Nullable CompileContext context) {
return context != null? CONTEXT_MODULES_KEY.get(context, Collections.<String>emptySet()) : Collections.<String>emptySet();
}
private static void setContextModules(@Nullable CompileContext context, @Nullable Set<String> modules) {
if (context != null) {
CONTEXT_MODULES_KEY.set(context, modules);
@@ -16,18 +16,25 @@
package org.jetbrains.ether;
import com.intellij.openapi.application.ex.PathManagerEx;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.jps.JpsPathUtil;
import org.jetbrains.jps.builders.BuildResult;
import org.jetbrains.jps.builders.JpsBuildTestCase;
import org.jetbrains.jps.cmdline.ProjectDescriptor;
import org.jetbrains.jps.incremental.*;
import org.jetbrains.jps.incremental.artifacts.ArtifactBuilderLoggerImpl;
import org.jetbrains.jps.incremental.java.JavaBuilderLogger;
import org.jetbrains.jps.incremental.messages.BuildMessage;
import org.jetbrains.jps.model.JpsDummyElement;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.library.sdk.JpsSdk;
import org.jetbrains.jps.model.module.JpsModule;
import java.io.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.PrintStream;
import java.util.Collections;
/**
@@ -38,6 +45,7 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
private final String groupName;
private File baseDir;
private File workDir;
private JpsSdk<JpsDummyElement> myJdk;
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
protected IncrementalTestCase(final String name) throws Exception {
@@ -55,6 +63,16 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
FileUtil.copyDir(baseDir, workDir);
Utils.setSystemRoot(workDir);
String outputPath = getAbsolutePath("out");
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myJpsProject).setOutputUrl(JpsPathUtil.pathToUrl(outputPath));
}
protected String getUrl(String pathRelativeToProjectRoot) {
return JpsPathUtil.pathToUrl(getAbsolutePath(pathRelativeToProjectRoot));
}
protected String getAbsolutePath(final String pathRelativeToProjectRoot) {
return FileUtil.toSystemIndependentName(workDir.getAbsolutePath()) + "/" + pathRelativeToProjectRoot;
}
@Override
@@ -96,45 +114,39 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
}
public void doTest() throws Exception {
final String projectPath = workDir.getAbsolutePath();
if (new File(workDir, ".idea").exists()) {
getOrCreateJdk();
loadProject(workDir.getAbsolutePath());
}
else {
addModule();
}
initJdk("IDEA jdk");
doTestBuild();
}
loadProject(projectPath);
protected JpsModule addModule() {
String moduleName = StringUtil.capitalize(getProjectName());
String srcPath = getAbsolutePath("src");
return addModule(moduleName, new String[]{srcPath}, null, getOrCreateJdk());
}
final TestJavaBuilderLogger javaBuilderLogger = new TestJavaBuilderLogger(FileUtil.toSystemIndependentName(workDir.getAbsolutePath()) + "/");
final ProjectDescriptor projectDescriptor = createProjectDescriptor(new BuildLoggingManager(new ArtifactBuilderLoggerImpl(), javaBuilderLogger));
protected BuildResult doTestBuild() throws Exception {
final TestJavaBuilderLogger
javaBuilderLogger = new TestJavaBuilderLogger(FileUtil.toSystemIndependentName(workDir.getAbsolutePath()) + "/");
final ProjectDescriptor
projectDescriptor = createProjectDescriptor(new BuildLoggingManager(new ArtifactBuilderLoggerImpl(), javaBuilderLogger));
try {
final IncProjectBuilder builder = createBuilder(projectDescriptor);
doBuild(builder, new AllProjectScope(myProject, myJpsProject, Collections.<JpsArtifact>emptySet(), true), false, false, true);
doBuild(projectDescriptor, new AllProjectScope(myProject, myJpsProject, Collections.<JpsArtifact>emptySet(), true), false,
true, false).assertSuccessful();
modify();
if (SystemInfo.isUnix) {
Thread.sleep(1000L);
}
final IncProjectBuilder makeBuilder = createBuilder(projectDescriptor);
class MH implements MessageHandler {
boolean myErrors = false;
@Override
public void processMessage(final BuildMessage msg) {
if (msg.getKind() == BuildMessage.Kind.ERROR)
myErrors = true;
}
}
final MH handler = new MH();
makeBuilder.addMessageHandler(handler);
makeBuilder.build(new AllProjectScope(myProject, myJpsProject, Collections.<JpsArtifact>emptySet(), false), true, false, false);
BuildResult result = doBuild(projectDescriptor, new AllProjectScope(myProject, myJpsProject, Collections.<JpsArtifact>emptySet(), false), true, false, false);
final ByteArrayOutputStream makeDump = new ByteArrayOutputStream();
if (!handler.myErrors) {
if (result.isSuccessful()) {
projectDescriptor.dataManager.getMappings().toStream(new PrintStream(makeDump));
}
@@ -145,8 +157,9 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
assertEquals(expected, actual);
if (!handler.myErrors) {
createBuilder(projectDescriptor).build(new AllProjectScope(myProject, myJpsProject, Collections.<JpsArtifact>emptySet(), true), false, true, false);
if (result.isSuccessful()) {
doBuild(projectDescriptor, new AllProjectScope(myProject, myJpsProject, Collections.<JpsArtifact>emptySet(), true), false,
true, false).assertSuccessful();
final ByteArrayOutputStream rebuildDump = new ByteArrayOutputStream();
@@ -156,12 +169,20 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
assertEquals(rebuildDump.toString(), makeDump.toString());
}
return result;
}
finally {
projectDescriptor.release();
}
}
private JpsSdk<JpsDummyElement> getOrCreateJdk() {
if (myJdk == null) {
myJdk = addJdk("IDEA jdk");
}
return myJdk;
}
private static class TestJavaBuilderLogger implements JavaBuilderLogger {
private final String myRoot;
private final StringBuilder myLog;
@@ -1,5 +1,15 @@
package org.jetbrains.ether;
import org.jetbrains.jps.model.JpsModuleRootModificationUtil;
import org.jetbrains.jps.model.java.JavaSourceRootType;
import org.jetbrains.jps.model.java.JpsJavaDependencyScope;
import org.jetbrains.jps.model.java.JpsJavaLibraryType;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.module.JpsModule;
import java.io.File;
/**
* Created by IntelliJ IDEA.
* User: db
@@ -15,4 +25,18 @@ public class MarkDirtyTest extends IncrementalTestCase {
public void testRecompileDependent() throws Exception {
doTest();
}
public void testRecompileDependentTests() throws Exception {
JpsModule module = addModule();
module.addSourceRoot(getUrl("testSrc"), JavaSourceRootType.TEST_SOURCE);
JpsLibrary library = addLibrary();
JpsModuleRootModificationUtil.addDependency(module, library, JpsJavaDependencyScope.TEST, false);
doTestBuild().assertSuccessful();
}
private JpsLibrary addLibrary() {
JpsLibrary library = myJpsProject.addLibrary("l", JpsJavaLibraryType.INSTANCE);
library.addRoot(new File(getAbsolutePath("lib/a.jar")), JpsOrderRootType.COMPILED);
return library;
}
}
@@ -0,0 +1,47 @@
package org.jetbrains.jps.builders;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import junit.framework.Assert;
import org.jetbrains.jps.incremental.MessageHandler;
import org.jetbrains.jps.incremental.messages.BuildMessage;
import java.util.ArrayList;
import java.util.List;
/**
* @author nik
*/
public class BuildResult implements MessageHandler {
private final List<BuildMessage> myErrorMessages;
private final List<BuildMessage> myInfoMessages;
public BuildResult() {
myErrorMessages = new ArrayList<BuildMessage>();
myInfoMessages = new ArrayList<BuildMessage>();
}
@Override
public void processMessage(BuildMessage msg) {
if (msg.getKind() == BuildMessage.Kind.ERROR) {
myErrorMessages.add(msg);
}
else {
myInfoMessages.add(msg);
}
}
public void assertFailed() {
Assert.assertFalse("Build not failed as expected", isSuccessful());
}
public boolean isSuccessful() {
return myErrorMessages.isEmpty();
}
public void assertSuccessful() {
final Function<BuildMessage,String> toStringFunction = StringUtil.createToStringFunction(BuildMessage.class);
Assert.assertTrue("Build failed. \nErrors:\n" + StringUtil.join(myErrorMessages, toStringFunction, "\n") +
"\nInfo messages:\n" + StringUtil.join(myInfoMessages, toStringFunction, "\n"), isSuccessful());
}
}
@@ -3,7 +3,6 @@ package org.jetbrains.jps.builders;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.testFramework.UsefulTestCase;
import com.intellij.util.Function;
import junit.framework.Assert;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.JpsPathUtil;
@@ -14,24 +13,22 @@ import org.jetbrains.jps.cmdline.ProjectDescriptor;
import org.jetbrains.jps.idea.IdeaProjectLoader;
import org.jetbrains.jps.incremental.*;
import org.jetbrains.jps.incremental.fs.BuildFSState;
import org.jetbrains.jps.incremental.messages.BuildMessage;
import org.jetbrains.jps.incremental.storage.BuildDataManager;
import org.jetbrains.jps.incremental.storage.ProjectTimestamps;
import org.jetbrains.jps.model.JpsDummyElement;
import org.jetbrains.jps.model.JpsElementFactory;
import org.jetbrains.jps.model.JpsModel;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.java.JpsJavaSdkType;
import org.jetbrains.jps.model.java.*;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.library.JpsTypedLibrary;
import org.jetbrains.jps.model.library.sdk.JpsSdk;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.serialization.JpsProjectLoader;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
@@ -52,16 +49,16 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
Utils.setSystemRoot(FileUtil.createTempDirectory("compile-server", null));
}
protected JpsSdk<JpsDummyElement> initJdk(final String name) {
protected JpsSdk<JpsDummyElement> addJdk(final String name) {
try {
return initJdk(name, FileUtil.toSystemIndependentName(ClasspathBootstrap.getResourcePath(Object.class).getCanonicalPath()));
return addJdk(name, FileUtil.toSystemIndependentName(ClasspathBootstrap.getResourcePath(Object.class).getCanonicalPath()));
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
protected JpsSdk<JpsDummyElement> initJdk(final String name, final String path) {
protected JpsSdk<JpsDummyElement> addJdk(final String name, final String path) {
String homePath = System.getProperty("java.home");
String versionString = System.getProperty("java.version");
JpsTypedLibrary<JpsSdk<JpsDummyElement>> jdk = myModel.getGlobal().addSdk(name, homePath, versionString, JpsJavaSdkType.INSTANCE);
@@ -112,39 +109,40 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
return null;
}
protected static IncProjectBuilder createBuilder(ProjectDescriptor projectDescriptor) {
return new IncProjectBuilder(projectDescriptor, BuilderRegistry.getInstance(), Collections.<String, String>emptyMap(), CanceledStatus.NULL, null);
protected JpsModule addModule(String moduleName,
String[] srcPaths,
@Nullable final String outputPath,
final JpsSdk<JpsDummyElement> jdk) {
final JpsModule module = myJpsProject.addModule(moduleName, JpsJavaModuleType.INSTANCE);
module.getSdkReferencesTable().setSdkReference(JpsJavaSdkType.INSTANCE, jdk.createReference());
module.getDependenciesList().addSdkDependency(JpsJavaSdkType.INSTANCE);
if (srcPaths.length > 0) {
for (String srcPath : srcPaths) {
module.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(srcPath));
module.addSourceRoot(JpsPathUtil.pathToUrl(srcPath), JavaSourceRootType.SOURCE);
}
JpsJavaModuleExtension extension = JpsJavaExtensionService.getInstance().getOrCreateModuleExtension(module);
if (outputPath != null) {
extension.setOutputUrl(JpsPathUtil.pathToUrl(outputPath));
}
else {
extension.setInheritOutput(true);
}
}
return module;
}
protected static void doBuild(IncProjectBuilder builder, CompileScope scope, boolean shouldFail, final boolean isMake,
final boolean isRebuild) {
final List<BuildMessage> errorMessages = new ArrayList<BuildMessage>();
final List<BuildMessage> infoMessages = new ArrayList<BuildMessage>();
builder.addMessageHandler(new MessageHandler() {
@Override
public void processMessage(BuildMessage msg) {
if (msg.getKind() == BuildMessage.Kind.ERROR) {
errorMessages.add(msg);
}
else {
infoMessages.add(msg);
}
}
});
protected BuildResult doBuild(final ProjectDescriptor descriptor, CompileScope scope,
final boolean make, final boolean rebuild, final boolean forceCleanCaches) {
IncProjectBuilder builder = new IncProjectBuilder(descriptor, BuilderRegistry.getInstance(), Collections.<String, String>emptyMap(), CanceledStatus.NULL, null);
BuildResult result = new BuildResult();
builder.addMessageHandler(result);
try {
builder.build(scope, isMake, isRebuild, false);
builder.build(scope, make, rebuild, forceCleanCaches);
}
catch (RebuildRequestedException e) {
Assert.fail(e.getMessage());
}
if (shouldFail) {
Assert.assertFalse("Build not failed as expected", errorMessages.isEmpty());
}
else {
final Function<BuildMessage,String> toStringFunction = StringUtil.createToStringFunction(BuildMessage.class);
Assert.assertTrue("Build failed. \nErrors:\n" + StringUtil.join(errorMessages, toStringFunction, "\n") +
"\nInfo messages:\n" + StringUtil.join(infoMessages, toStringFunction, "\n"), errorMessages.isEmpty());
}
return result;
}
}
@@ -12,8 +12,8 @@ public class ModuleClasspathTest extends JpsRebuildTestCase {
protected void setUp() {
super.setUp()
myModel.getGlobal().getLibraryCollection().findLibrary("1.6").delete()
initJdk("1.6", "/jdk.jar")
initJdk("1.5", "/jdk15.jar")
addJdk("1.6", "/jdk.jar")
addJdk("1.5", "/jdk15.jar")
loadProject("moduleClasspath/moduleClasspath.ipr")
}
@@ -21,7 +21,7 @@ abstract class JpsRebuildTestCase extends JpsBuildTestCase {
@Override
protected void setUp() {
super.setUp()
initJdk("1.6")
addJdk("1.6")
}
def doTest(String projectPath, Closure initProject, Closure expectedOutput) {
@@ -52,7 +52,7 @@ abstract class JpsRebuildTestCase extends JpsBuildTestCase {
def descriptor = createProjectDescriptor(new BuildLoggingManager(new ArtifactBuilderLoggerImpl(), new JavaBuilderLoggerImpl()))
try {
def scope = new AllProjectScope(myProject, myJpsProject, new HashSet<JpsArtifact>(JpsArtifactService.getInstance().getArtifacts(myJpsProject)), true)
doBuild(createBuilder(descriptor), scope, false, false, true)
doBuild(descriptor, scope, false, true, false).assertSuccessful()
}
finally {
descriptor.release();
@@ -21,19 +21,19 @@ import com.intellij.util.io.TestFileSystemBuilder;
import com.intellij.util.text.UniqueNameGenerator;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.JpsPathUtil;
import org.jetbrains.jps.builders.BuildResult;
import org.jetbrains.jps.builders.JpsBuildTestCase;
import org.jetbrains.jps.cmdline.ProjectDescriptor;
import org.jetbrains.jps.incremental.AllProjectScope;
import org.jetbrains.jps.incremental.BuildLoggingManager;
import org.jetbrains.jps.incremental.CompileScope;
import org.jetbrains.jps.incremental.IncProjectBuilder;
import org.jetbrains.jps.incremental.java.JavaBuilderLoggerImpl;
import org.jetbrains.jps.model.JpsDummyElement;
import org.jetbrains.jps.model.JpsElementFactory;
import org.jetbrains.jps.model.artifact.DirectoryArtifactType;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.JpsArtifactService;
import org.jetbrains.jps.model.java.*;
import org.jetbrains.jps.model.java.JpsJavaLibraryType;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.library.sdk.JpsSdk;
@@ -127,20 +127,9 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
protected JpsModule addModule(String moduleName, String... srcPaths) {
if (myJdk == null) {
myJdk = initJdk("1.6");
myJdk = addJdk("1.6");
}
final JpsModule module = myJpsProject.addModule(moduleName, JpsJavaModuleType.INSTANCE);
module.getSdkReferencesTable().setSdkReference(JpsJavaSdkType.INSTANCE, myJdk.createReference());
module.getDependenciesList().addSdkDependency(JpsJavaSdkType.INSTANCE);
if (srcPaths.length > 0) {
for (String srcPath : srcPaths) {
module.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(srcPath));
module.addSourceRoot(JpsPathUtil.pathToUrl(srcPath), JavaSourceRootType.SOURCE);
}
final String outputUrl = JpsPathUtil.pathToUrl(getAbsolutePath("out/production/" + moduleName));
JpsJavaExtensionService.getInstance().getOrCreateModuleExtension(module).setOutputUrl(outputUrl);
}
return module;
return addModule(moduleName, srcPaths, getAbsolutePath("out/production/" + moduleName), myJdk);
}
protected JpsLibrary addProjectLibrary(String name, String jarPath) {
@@ -155,19 +144,18 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
}
protected void buildArtifacts(JpsArtifact... artifact) {
doBuild(false, false, artifact);
doBuild(false, artifact).assertSuccessful();
}
private void doBuild(boolean force, final boolean shouldFail, JpsArtifact... artifacts) {
private BuildResult doBuild(boolean force, JpsArtifact... artifacts) {
if (myDescriptor == null) {
myDescriptor = createProjectDescriptor(new BuildLoggingManager(myArtifactBuilderLogger, new JavaBuilderLoggerImpl()));
myDescriptor.incUsageCounter();
}
myArtifactBuilderLogger.clear();
IncProjectBuilder builder = createBuilder(myDescriptor);
final CompileScope scope = new AllProjectScope(myDescriptor.project, myDescriptor.jpsProject,
new HashSet<JpsArtifact>(Arrays.asList(artifacts)), force);
doBuild(builder, scope, shouldFail, !force, false);
return doBuild(myDescriptor, scope, !force, false, false);
}
protected static String getJUnitJarPath() {
@@ -181,7 +169,7 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
}
protected void assertBuildFailed(JpsArtifact a) {
doBuild(false, true, a);
doBuild(false, a).assertFailed();
}
protected static void change(String filePath) {