external compiler for plugin modules: fixed references to IDEA sdk & test added

This commit is contained in:
nik
2012-09-20 09:02:29 +04:00
parent c8f6c6c24d
commit 3e9b3fe17a
15 changed files with 654 additions and 219 deletions
+1
View File
@@ -24,6 +24,7 @@
<orderEntry type="module" module-name="java-impl" />
<orderEntry type="module" module-name="jps-builders" />
<orderEntry type="library" name="Netty" level="project" />
<orderEntry type="module" module-name="testFramework-java" scope="TEST" />
</component>
<component name="copyright">
<Base>
@@ -0,0 +1,397 @@
package com.intellij.compiler;
import com.intellij.ide.highlighter.ModuleFileType;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.application.ex.PathManagerEx;
import com.intellij.openapi.compiler.*;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
import com.intellij.openapi.roots.CompilerModuleExtension;
import com.intellij.openapi.roots.CompilerProjectExtension;
import com.intellij.openapi.roots.ModuleRootModificationUtil;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.artifacts.ArtifactManager;
import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
import com.intellij.testFramework.ModuleTestCase;
import com.intellij.testFramework.PlatformTestCase;
import com.intellij.testFramework.PsiTestUtil;
import com.intellij.testFramework.VfsTestUtil;
import com.intellij.util.ParameterizedRunnable;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.io.TestFileSystemBuilder;
import com.intellij.util.ui.UIUtil;
import gnu.trove.THashSet;
import junit.framework.Assert;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.JpsPathUtil;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* @author nik
*/
public abstract class BaseCompilerTestCase extends ModuleTestCase {
protected boolean useExternalCompiler() {
return false;
}
@Override
protected void setUpModule() {
}
@Override
protected void setUp() throws Exception {
super.setUp();
if (useExternalCompiler()) {
CompilerTestUtil.enableExternalCompiler(myProject);
}
}
@Override
protected Sdk getTestProjectJdk() {
if (useExternalCompiler()) {
return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
}
return super.getTestProjectJdk();
}
@Override
protected void tearDown() throws Exception {
for (Artifact artifact : getArtifactManager().getArtifacts()) {
final String outputPath = artifact.getOutputPath();
if (!StringUtil.isEmpty(outputPath)) {
FileUtil.delete(new File(FileUtil.toSystemDependentName(outputPath)));
}
}
if (useExternalCompiler()) {
CompilerTestUtil.disableExternalCompiler(myProject);
}
super.tearDown();
}
protected ArtifactManager getArtifactManager() {
return ArtifactManager.getInstance(myProject);
}
protected String getProjectBasePath() {
return getBaseDir().getPath();
}
protected VirtualFile getBaseDir() {
final VirtualFile baseDir = myProject.getBaseDir();
Assert.assertNotNull(baseDir);
return baseDir;
}
protected void copyToProject(String relativePath) {
File dir = PathManagerEx.findFileUnderProjectHome(relativePath, getClass());
final File target = new File(FileUtil.toSystemDependentName(getProjectBasePath()));
try {
FileUtil.copyDir(dir, target);
}
catch (IOException e) {
throw new RuntimeException(e);
}
new WriteAction() {
protected void run(final Result result) {
VirtualFile virtualDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(target);
assertNotNull(target.getAbsolutePath() + " not found", virtualDir);
virtualDir.refresh(false, true);
}
}.execute();
}
protected Module addModule(final String moduleName, final @Nullable VirtualFile sourceRoot) {
return new WriteAction<Module>() {
@Override
protected void run(final Result<Module> result) {
final Module module = createModule(moduleName);
if (sourceRoot != null) {
PsiTestUtil.addSourceContentToRoots(module, sourceRoot);
}
ModuleRootModificationUtil.setModuleSdk(module, getTestProjectJdk());
result.setResult(module);
}
}.execute().getResultObject();
}
protected VirtualFile createFile(final String path) {
return createFile(path, "");
}
protected VirtualFile createFile(final String path, final String text) {
return VfsTestUtil.createFile(getBaseDir(), path, text);
}
protected CompilationLog make(final Artifact... artifacts) {
final CompileScope scope = ArtifactCompileScope.createArtifactsScope(myProject, Arrays.asList(artifacts));
return make(scope, CompilerFilter.ALL);
}
protected CompilationLog make(Module module) {
return make(getCompilerManager().createModuleCompileScope(module, false), CompilerFilter.ALL);
}
private CompilerManager getCompilerManager() {
return CompilerManager.getInstance(myProject);
}
protected void assertModulesUpToDate() {
//todo[nik,jeka] uncomment this when isUpToDate become supported in external compiler
//boolean upToDate = getCompilerManager().isUpToDate(getCompilerManager().createProjectCompileScope(myProject));
//assertTrue("Modules are not up to date", upToDate);
}
protected CompilationLog compile(boolean force, VirtualFile... files) {
return compile(getCompilerManager().createFilesCompileScope(files), CompilerFilter.ALL, force);
}
protected CompilationLog make(final CompileScope scope, final CompilerFilter filter) {
return compile(scope, filter, false);
}
protected CompilationLog compile(final CompileScope scope, final CompilerFilter filter, final boolean forceCompile) {
return compile(scope, filter, forceCompile, false);
}
protected CompilationLog compile(final CompileScope scope, final CompilerFilter filter, final boolean forceCompile,
final boolean errorsExpected) {
return compile(errorsExpected, new ParameterizedRunnable<CompileStatusNotification>() {
@Override
public void run(CompileStatusNotification callback) {
final CompilerManager compilerManager = getCompilerManager();
if (forceCompile) {
Assert.assertSame("Only 'ALL' filter is supported for forced compilation", CompilerFilter.ALL, filter);
compilerManager.compile(scope, callback);
}
else {
compilerManager.make(scope, filter, callback);
}
}
});
}
protected void rebuild() {
compile(false, new ParameterizedRunnable<CompileStatusNotification>() {
@Override
public void run(CompileStatusNotification compileStatusNotification) {
getCompilerManager().rebuild(compileStatusNotification);
}
});
}
protected CompilationLog compile(final boolean errorsExpected, final ParameterizedRunnable<CompileStatusNotification> action) {
final Ref<CompilationLog> result = Ref.create(null);
final Semaphore semaphore = new Semaphore();
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
semaphore.down();
CompilerManagerImpl.testSetup();
final CompileStatusNotification callback = new CompileStatusNotification() {
@Override
public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
try {
if (aborted) {
Assert.fail("compilation aborted");
}
if (errorsExpected && errors == 0) {
Assert.fail("compilation finished without errors");
}
else if (!errorsExpected && errors > 0) {
Assert
.fail("compilation finished with errors: " + Arrays.toString(compileContext.getMessages(CompilerMessageCategory.ERROR)));
}
result.set(new CompilationLog(CompilerManagerImpl.getPathsToRecompile(), CompilerManagerImpl.getPathsToDelete()));
}
finally {
semaphore.up();
}
}
};
if (useExternalCompiler()) {
myProject.save();
CompilerTestUtil.saveSdkTable();
CompilerTestUtil.scanSourceRootsToRecompile(myProject);
}
action.run(callback);
}
});
long start = System.currentTimeMillis();
while (!semaphore.waitFor(10)) {
if (System.currentTimeMillis() - start > 60 * 1000) {
throw new RuntimeException("timeout");
}
UIUtil.dispatchAllInvocationEvents();
}
UIUtil.dispatchAllInvocationEvents();
return result.get();
}
private Set<String> getRelativePaths(String[] paths) {
final Set<String> set = new THashSet<String>();
final String basePath = myProject.getBaseDir().getPath();
for (String path : paths) {
set.add(StringUtil.trimStart(StringUtil.trimStart(FileUtil.toSystemIndependentName(path), basePath), "/"));
}
return set;
}
protected void changeFile(VirtualFile file) throws Exception {
changeFile(file, null);
}
protected void changeFile(VirtualFile file, final String newText) {
try {
if (newText != null) {
VfsUtil.saveText(file, newText);
}
((NewVirtualFile)file).setTimeStamp(file.getTimeStamp() + 10);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
protected void deleteFile(final VirtualFile file) {
new WriteAction() {
@Override
protected void run(final Result result) {
try {
file.delete(this);
}
catch (IOException e) {
throw new AssertionError(e);
}
}
}.execute();
}
@Override
protected void setUpProject() throws Exception {
super.setUpProject();
final String baseUrl = myProject.getBaseDir().getUrl();
CompilerProjectExtension.getInstance(myProject).setCompilerOutputUrl(baseUrl + "/out");
}
@Override
protected File getIprFile() throws IOException {
File iprFile = super.getIprFile();
if (useExternalCompiler()) {
FileUtil.delete(iprFile);
}
return iprFile;
}
@Override
protected Module doCreateRealModule(String moduleName) {
if (useExternalCompiler()) {
//todo[nik] reuse code from PlatformTestCase
final VirtualFile baseDir = myProject.getBaseDir();
Assert.assertNotNull(baseDir);
final File moduleFile = new File(baseDir.getPath().replace('/', File.separatorChar), moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
PlatformTestCase.myFilesToDelete.add(moduleFile);
return new WriteAction<Module>() {
@Override
protected void run(Result<Module> result) throws Throwable {
Module module = ModuleManager.getInstance(myProject)
.newModule(FileUtil.toSystemIndependentName(moduleFile.getAbsolutePath()), getModuleType().getId());
module.getModuleFile();
result.setResult(module);
}
}.execute().getResultObject();
}
return super.doCreateRealModule(moduleName);
}
@Override
protected boolean isRunInWriteAction() {
return false;
}
protected static void assertOutput(Module module, TestFileSystemBuilder item) {
File outputDir = getOutputDir(module);
Assert.assertTrue("Output directory " + outputDir.getAbsolutePath() + " doesn't exist", outputDir.exists());
item.build().assertDirectoryEqual(outputDir);
}
protected static void assertNoOutput(Module module) {
File dir = getOutputDir(module);
Assert.assertFalse("Output directory " + dir.getAbsolutePath() + " does exist", dir.exists());
}
protected static File getOutputDir(Module module) {
CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
Assert.assertNotNull(extension);
String outputUrl = extension.getCompilerOutputUrl();
Assert.assertNotNull("Output directory for module '" + module.getName() + "' isn't specified", outputUrl);
return JpsPathUtil.urlToFile(outputUrl);
}
protected class CompilationLog {
private final Set<String> myRecompiledPaths;
private final Set<String> myDeletedPaths;
public CompilationLog(String[] recompiledPaths, String[] deletedPaths) {
myRecompiledPaths = getRelativePaths(recompiledPaths);
myDeletedPaths = getRelativePaths(deletedPaths);
}
public void assertUpToDate() {
checkRecompiled();
checkDeleted();
}
public void assertRecompiled(String... expected) {
checkRecompiled(expected);
checkDeleted();
}
public void assertDeleted(String... expected) {
checkRecompiled();
checkDeleted(expected);
}
public void assertRecompiledAndDeleted(String[] recompiled, String... deleted) {
checkRecompiled(recompiled);
checkDeleted(deleted);
}
private void checkRecompiled(String... expected) {
assertSet("recompiled", myRecompiledPaths, expected);
}
private void checkDeleted(String... expected) {
assertSet("deleted", myDeletedPaths, expected);
}
private void assertSet(String name, Set<String> actual, String[] expected) {
for (String path : expected) {
if (!actual.remove(path)) {
Assert.fail("'" + path + "' is not " + name + ". " + name + ": " + new HashSet<String>(actual));
}
}
if (!actual.isEmpty()) {
Assert.fail("'" + actual.iterator().next() + "' must not be " + name);
}
}
}
}
@@ -1,7 +1,6 @@
package org.jetbrains.jps;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Conditions;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Consumer;
import org.jetbrains.annotations.NotNull;
@@ -60,10 +59,10 @@ public class ProjectPaths {
enumerator = enumerator.exportedOnly();
}
if (classpathPart == ClasspathPart.BEFORE_JDK) {
enumerator = enumerator.satisfying(new BeforeSdkItemFilter(module));
enumerator = enumerator.satisfying(new BeforeJavaSdkItemFilter(module));
}
else if (classpathPart == ClasspathPart.AFTER_JDK) {
enumerator = enumerator.satisfying(Conditions.not(new BeforeSdkItemFilter(module))).withoutSdk();
enumerator = enumerator.satisfying(new AfterJavaSdkItemFilter(module));
}
JpsJavaDependenciesRootsEnumerator rootsEnumerator = enumerator.classes();
if (excludeMainModuleOutput) {
@@ -179,20 +178,40 @@ public class ProjectPaths {
private enum ClasspathPart {WHOLE, BEFORE_JDK, AFTER_JDK}
private static class BeforeSdkItemFilter implements Condition<JpsDependencyElement> {
private static class BeforeJavaSdkItemFilter implements Condition<JpsDependencyElement> {
private JpsModule myModule;
private boolean mySdkFound;
private BeforeSdkItemFilter(JpsModule module) {
private BeforeJavaSdkItemFilter(JpsModule module) {
myModule = module;
}
@Override
public boolean value(JpsDependencyElement dependency) {
if (myModule.equals(dependency.getContainingModule()) && dependency instanceof JpsSdkDependency) {
boolean isJavaSdk = dependency instanceof JpsSdkDependency && ((JpsSdkDependency)dependency).getSdkType().equals(JpsJavaSdkType.INSTANCE);
if (myModule.equals(dependency.getContainingModule()) && isJavaSdk) {
mySdkFound = true;
}
return !mySdkFound && !(dependency instanceof JpsSdkDependency);
return !mySdkFound && !isJavaSdk;
}
}
private static class AfterJavaSdkItemFilter implements Condition<JpsDependencyElement> {
private JpsModule myModule;
private boolean mySdkFound;
private AfterJavaSdkItemFilter(JpsModule module) {
myModule = module;
}
@Override
public boolean value(JpsDependencyElement dependency) {
if (myModule.equals(dependency.getContainingModule()) &&
dependency instanceof JpsSdkDependency && ((JpsSdkDependency)dependency).getSdkType().equals(JpsJavaSdkType.INSTANCE)) {
mySdkFound = true;
return false;
}
return mySdkFound;
}
}
@@ -8,6 +8,7 @@ import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration;
import org.jetbrains.jps.model.library.JpsTypedLibrary;
import org.jetbrains.jps.model.library.sdk.JpsSdk;
import org.jetbrains.jps.model.library.sdk.JpsSdkReference;
import org.jetbrains.jps.model.module.JpsDependencyElement;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsModuleReference;
@@ -93,4 +94,8 @@ public abstract class JpsJavaExtensionService {
@NotNull
public abstract JpsJavaCompilerConfiguration getOrCreateCompilerConfiguration(@NotNull JpsProject project);
@NotNull
public abstract JpsSdkReference<JpsDummyElement> createWrappedJavaSdkReference(@NotNull JpsJavaSdkTypeWrapper sdkType,
@NotNull JpsSdkReference<?> wrapperReference);
}
@@ -14,6 +14,7 @@ import org.jetbrains.jps.model.java.impl.compiler.JpsJavaCompilerConfigurationIm
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.library.sdk.JpsSdkReference;
import org.jetbrains.jps.model.module.*;
import java.io.File;
@@ -161,6 +162,13 @@ public class JpsJavaExtensionServiceImpl extends JpsJavaExtensionService {
return configuration;
}
@NotNull
@Override
public JpsSdkReference<JpsDummyElement> createWrappedJavaSdkReference(@NotNull JpsJavaSdkTypeWrapper sdkType,
@NotNull JpsSdkReference<?> wrapperReference) {
return new JpsWrappedJavaSdkReferenceImpl(sdkType, wrapperReference);
}
@Override
@NotNull
public JpsProductionModuleOutputPackagingElement createProductionModuleOutput(@NotNull JpsModuleReference moduleReference) {
@@ -0,0 +1,66 @@
package org.jetbrains.jps.model.java.impl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsDummyElement;
import org.jetbrains.jps.model.JpsElement;
import org.jetbrains.jps.model.JpsElementReference;
import org.jetbrains.jps.model.JpsModel;
import org.jetbrains.jps.model.impl.JpsCompositeElementBase;
import org.jetbrains.jps.model.impl.JpsElementChildRoleBase;
import org.jetbrains.jps.model.java.JpsJavaSdkType;
import org.jetbrains.jps.model.java.JpsJavaSdkTypeWrapper;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsTypedLibrary;
import org.jetbrains.jps.model.library.sdk.JpsSdk;
import org.jetbrains.jps.model.library.sdk.JpsSdkReference;
/**
* @author nik
*/
public class JpsWrappedJavaSdkReferenceImpl extends JpsCompositeElementBase<JpsWrappedJavaSdkReferenceImpl> implements JpsSdkReference<JpsDummyElement> {
private static final JpsElementChildRoleBase<JpsSdkReference<?>> WRAPPER_ROLE = JpsElementChildRoleBase.create("wrapper reference");
private final JpsJavaSdkTypeWrapper mySdkType;
public JpsWrappedJavaSdkReferenceImpl(JpsJavaSdkTypeWrapper sdkType, JpsSdkReference<?> wrapperReference) {
mySdkType = sdkType;
myContainer.setChild(WRAPPER_ROLE, wrapperReference);
}
private JpsWrappedJavaSdkReferenceImpl(JpsWrappedJavaSdkReferenceImpl original) {
super(original);
mySdkType = original.mySdkType;
}
@NotNull
@Override
public JpsWrappedJavaSdkReferenceImpl createCopy() {
return new JpsWrappedJavaSdkReferenceImpl(this);
}
@Override
public String getSdkName() {
JpsTypedLibrary<JpsSdk<JpsDummyElement>> sdk = resolve();
return sdk != null ? sdk.getName() : "<unknown>";
}
@Nullable
@Override
public JpsTypedLibrary<JpsSdk<JpsDummyElement>> resolve() {
JpsTypedLibrary<? extends JpsSdk<? extends JpsElement>> wrapper = myContainer.getChild(WRAPPER_ROLE).resolve();
if (wrapper == null) return null;
JpsModel model = getModel();
if (model == null) return null;
String sdkName = mySdkType.getJavaSdkName(wrapper.getProperties().getSdkProperties());
if (sdkName == null) return null;
JpsLibrary library = model.getGlobal().getLibraryCollection().findLibrary(sdkName);
return library != null ? library.asTyped(JpsJavaSdkType.INSTANCE) : null;
}
@Override
public JpsElementReference<JpsTypedLibrary<JpsSdk<JpsDummyElement>>> asExternal(@NotNull JpsModel model) {
model.registerExternalReference(this);
return this;
}
}
@@ -7,6 +7,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsDummyElement;
import org.jetbrains.jps.model.JpsElement;
import org.jetbrains.jps.model.JpsElementFactory;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.java.JpsJavaSdkType;
import org.jetbrains.jps.model.java.JpsJavaSdkTypeWrapper;
import org.jetbrains.jps.model.library.*;
@@ -219,13 +220,9 @@ public class JpsSdkTableSerializer {
JpsSdkReference<P> reference = JpsElementFactory.getInstance().createSdkReference(sdkName, sdkType);
table.setSdkReference(sdkType, reference);
if (sdkType instanceof JpsJavaSdkTypeWrapper) {
JpsLibrary jpsLibrary = reference.resolve();
if (jpsLibrary != null) {
String name = ((JpsJavaSdkTypeWrapper)sdkType).getJavaSdkName(((JpsSdk<?>)jpsLibrary.getProperties()).getSdkProperties());
if (name != null) {
table.setSdkReference(JpsJavaSdkType.INSTANCE, JpsElementFactory.getInstance().createSdkReference(name, JpsJavaSdkType.INSTANCE));
}
}
JpsSdkReference<P> wrapperRef = JpsElementFactory.getInstance().createSdkReference(sdkName, sdkType);
table.setSdkReference(JpsJavaSdkType.INSTANCE, JpsJavaExtensionService.getInstance().createWrappedJavaSdkReference((JpsJavaSdkTypeWrapper)sdkType,
wrapperRef));
}
}
}
@@ -10,6 +10,7 @@ import org.jetbrains.jps.model.JpsSimpleElement;
import org.jetbrains.jps.model.java.JavaSourceRootProperties;
import org.jetbrains.jps.model.java.JavaSourceRootType;
import org.jetbrains.jps.model.java.JpsJavaSdkType;
import org.jetbrains.jps.model.java.JpsJavaSdkTypeWrapper;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsLibraryReference;
import org.jetbrains.jps.model.library.sdk.JpsSdkType;
@@ -82,6 +83,9 @@ public class JpsModuleRootModelSerializer {
final JpsSdkType<?> sdkType = JpsSdkTableSerializer.getSdkType(sdkTypeId);
dependenciesList.addSdkDependency(sdkType);
JpsSdkTableSerializer.setSdkReference(module.getSdkReferencesTable(), sdkName, sdkType);
if (sdkType instanceof JpsJavaSdkTypeWrapper) {
dependenciesList.addSdkDependency(JpsJavaSdkType.INSTANCE);
}
}
else if (INHERITED_JDK_TYPE.equals(type)) {
dependenciesList.addSdkDependency(projectSdkType != null ? projectSdkType : JpsJavaSdkType.INSTANCE);
@@ -6,7 +6,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="IDEA IU-111.277" jdkType="IDEA JDK" />
<orderEntry type="jdk" jdkName="IDEA plugin SDK" jdkType="IDEA JDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AntConfiguration">
<defaultAnt bundledAnt="true" />
</component>
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
@@ -24,214 +21,13 @@
</profile>
</annotationProcessing>
</component>
<component name="CopyrightManager" default="">
<module2copyright />
</component>
<component name="DependencyValidationManager">
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</component>
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
<component name="ProjectKey">
<option name="state" value="project://708ad4a1-478d-4ce8-9ff1-4a9aeb2291e0" />
</component>
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/pluginProject.iml" filepath="$PROJECT_DIR$/pluginProject.iml" />
</modules>
</component>
<component name="ProjectResources">
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA IU-111.277" project-jdk-type="IDEA JDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="PyConsoleOptionsProvider">
<option name="myPythonConsoleState">
<PyConsoleSettings />
</option>
<option name="myDjangoConsoleState">
<PyConsoleSettings />
</option>
</component>
<component name="SvnConfiguration" maxAnnotateRevisions="500" myUseAcceleration="nothing" myAutoUpdateAfterCommit="false" cleanupOnStartRun="false">
<option name="USER" value="" />
<option name="PASSWORD" value="" />
<option name="mySSHConnectionTimeout" value="30000" />
<option name="mySSHReadTimeout" value="30000" />
<option name="LAST_MERGED_REVISION" />
<option name="MERGE_DRY_RUN" value="false" />
<option name="MERGE_DIFF_USE_ANCESTRY" value="true" />
<option name="UPDATE_LOCK_ON_DEMAND" value="false" />
<option name="IGNORE_SPACES_IN_MERGE" value="false" />
<option name="DETECT_NESTED_COPIES" value="true" />
<option name="CHECK_NESTED_FOR_QUICK_MERGE" value="false" />
<option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
<option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
<option name="FORCE_UPDATE" value="false" />
<option name="IGNORE_EXTERNALS" value="false" />
<myIsUseDefaultProxy>false</myIsUseDefaultProxy>
</component>
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
<component name="VssConfiguration">
<option name="CLIENT_PATH" value="" />
<option name="SRCSAFEINI_PATH" value="" />
<option name="USER_NAME" value="" />
<option name="PWD" value="" />
<CheckoutOptions>
<option name="COMMENT" value="" />
<option name="DO_NOT_GET_LATEST_VERSION" value="false" />
<option name="REPLACE_WRITABLE" value="false" />
<option name="RECURSIVE" value="false" />
</CheckoutOptions>
<CheckinOptions>
<option name="COMMENT" value="" />
<option name="KEEP_CHECKED_OUT" value="false" />
<option name="RECURSIVE" value="false" />
</CheckinOptions>
<AddOptions>
<option name="STORE_ONLY_LATEST_VERSION" value="false" />
<option name="CHECK_OUT_IMMEDIATELY" value="false" />
</AddOptions>
<UndocheckoutOptions>
<option name="MAKE_WRITABLE" value="false" />
<option name="REPLACE_LOCAL_COPY" value="2" />
<option name="RECURSIVE" value="false" />
</UndocheckoutOptions>
<GetOptions>
<option name="REPLACE_WRITABLE" value="0" />
<option name="MAKE_WRITABLE" value="false" />
<option name="ANSWER_NEGATIVELY" value="false" />
<option name="ANSWER_POSITIVELY" value="false" />
<option name="RECURSIVE" value="false" />
<option name="VERSION" />
</GetOptions>
</component>
<component name="antWorkspaceConfiguration">
<option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
<option name="FILTER_TARGETS" value="false" />
</component>
</project>
@@ -15,7 +15,12 @@
*/
package org.jetbrains.jps.devkit.model;
import org.jetbrains.jps.model.JpsDummyElement;
import org.jetbrains.jps.model.JpsElementFactory;
import org.jetbrains.jps.model.JpsSimpleElement;
import org.jetbrains.jps.model.java.JpsJavaSdkType;
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.module.JpsTypedModule;
import org.jetbrains.jps.model.serialization.JpsSerializationTestCase;
@@ -32,5 +37,13 @@ public class JpsPluginProjectSerializationTest extends JpsSerializationTestCase
assertNotNull(pluginModule);
String url = pluginModule.getProperties().getData().getPluginXmlUrl();
assertEquals(getUrl("META-INF/plugin.xml"), url);
JpsTypedLibrary<JpsSdk<JpsDummyElement>> javaSdk = myModel.getGlobal().addSdk("1.6", null, null, JpsJavaSdkType.INSTANCE);
JpsSimpleElement<JpsIdeaSdkProperties> properties =
JpsElementFactory.getInstance().createSimpleElement(new JpsIdeaSdkProperties(null, "1.6"));
JpsTypedLibrary<JpsSdk<JpsSimpleElement<JpsIdeaSdkProperties>>> pluginSdk = myModel.getGlobal()
.addSdk("IDEA plugin SDK", null, null, JpsIdeaSdkType.INSTANCE, properties);
assertSame(pluginSdk.getProperties(), module.getSdk(JpsIdeaSdkType.INSTANCE));
assertSame(javaSdk.getProperties(), module.getSdk(JpsJavaSdkType.INSTANCE));
}
}
@@ -0,0 +1,9 @@
<idea-plugin version="2">
<id>test.plugin</id>
<name>Test Plugin</name>
<version>1.0</version>
<actions>
<action id="xxx.MyAction" class="xxx.MyAction" text="Something"/>
</actions>
</idea-plugin>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PLUGIN_MODULE" version="4">
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/META-INF/plugin.xml" />
<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="jdk" jdkName="IDEA plugin SDK" jdkType="IDEA JDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
@@ -0,0 +1,9 @@
package xxx;
import com.intellij.openapi.util.io.FileUtilRt ;
public class MyAction {
public void actionPerformed() {
FileUtilRt.toSystemDependentName("myPath");
}
}
@@ -0,0 +1,98 @@
/*
* 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.idea.devkit.build;
import com.intellij.compiler.BaseCompilerTestCase;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.impl.ModuleImpl;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkModificator;
import com.intellij.openapi.projectRoots.SdkType;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.LocalFileSystem;
import org.jetbrains.idea.devkit.projectRoots.IdeaJdk;
import org.jetbrains.idea.devkit.projectRoots.Sandbox;
import java.io.File;
import static com.intellij.util.io.TestFileSystemBuilder.fs;
/**
* @author nik
*/
public class PluginModuleCompilationTest extends BaseCompilerTestCase {
private Sdk myPluginSdk;
@Override
protected void setUpJdk() {
super.setUpJdk();
new WriteAction() {
protected void run(final Result result) {
ProjectJdkTable table = ProjectJdkTable.getInstance();
myPluginSdk = table.createSdk("IDEA plugin SDK", SdkType.findInstance(IdeaJdk.class));
SdkModificator modificator = myPluginSdk.getSdkModificator();
modificator.setSdkAdditionalData(new Sandbox(getSandboxPath(), getTestProjectJdk(), myPluginSdk));
String rootPath = FileUtil.toSystemIndependentName(PathManager.getJarPathForClass(FileUtilRt.class));
modificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByPath(rootPath), OrderRootType.CLASSES);
modificator.commitChanges();
table.addJdk(myPluginSdk);
}
}.execute();
}
private String getSandboxPath() {
return getProjectBasePath() + "/sandbox";
}
@Override
protected boolean useExternalCompiler() {
return true;
}
@Override
protected void tearDown() throws Exception {
new WriteAction() {
protected void run(final Result result) {
ProjectJdkTable.getInstance().removeJdk(myPluginSdk);
}
}.execute();
super.tearDown();
}
public void testMakeModule() {
copyToProject("plugins/devkit/testData/build/simple");
Module module = loadModule(getProjectBasePath() + "/pluginProject.iml");
readJdomExternalizables((ModuleImpl)module);
make(module);
assertOutput(module, fs().dir("xxx").file("MyAction.class"));
File sandbox = new File(FileUtil.toSystemDependentName(getSandboxPath()));
assertTrue(sandbox.exists());
fs().dir("plugins")
.dir("pluginProject")
.dir("META-INF").file("plugin.xml").end()
.dir("classes")
.dir("xxx").file("MyAction.class")
.build().assertDirectoryEqual(sandbox);
}
}