send FileGenerated event about just copied form runtime classes (affects IDEA-94779 Automatically copy form runtime classes to output directory) resurrect

This commit is contained in:
Eugene Zhuravlev
2012-11-15 21:59:44 +01:00
parent 0ba0c450d4
commit cc6afbe5a2
4 changed files with 90 additions and 1 deletions

View File

@@ -43,6 +43,7 @@ import org.jetbrains.jps.incremental.*;
import org.jetbrains.jps.incremental.Utils;
import org.jetbrains.jps.incremental.messages.BuildMessage;
import org.jetbrains.jps.incremental.messages.CompilerMessage;
import org.jetbrains.jps.incremental.messages.FileGeneratedEvent;
import org.jetbrains.jps.incremental.messages.ProgressMessage;
import org.jetbrains.jps.incremental.storage.BuildDataManager;
import org.jetbrains.jps.incremental.storage.OneToManyPathsMapping;
@@ -366,7 +367,19 @@ public class JavaBuilder extends ModuleLevelBuilder {
if (!target.isTests()) {
final File outputDir = target.getOutputDir();
if (outputDir != null) {
CopyResourcesUtil.copyFormsRuntime(outputDir.getAbsolutePath(), false);
final String outputRoot = FileUtil.toSystemIndependentName(outputDir.getPath());
final List<File> generatedFiles = CopyResourcesUtil.copyFormsRuntime(outputRoot, false);
if (!generatedFiles.isEmpty()) {
// now inform others about files just copied
final FileGeneratedEvent event = new FileGeneratedEvent();
for (File file : generatedFiles) {
final String relativePath = FileUtil.getRelativePath(outputRoot, FileUtil.toSystemIndependentName(file.getPath()), '/');
if (relativePath != null) {
event.add(outputRoot, relativePath);
}
}
context.processMessage(event);
}
}
}
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="B">
<grid id="27dc6" row-count="1" column-count="1" layout-manager="GridLayoutManager">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</form>

View File

@@ -0,0 +1,2 @@
public class B {
}

View File

@@ -0,0 +1,61 @@
/*
* 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 com.intellij.uiDesigner.make;
//import com.intellij.compiler.artifacts.ArtifactCompilerTestCase;
//import com.intellij.openapi.application.ex.PathManagerEx;
//import com.intellij.openapi.module.Module;
//import com.intellij.openapi.util.io.FileUtil;
//import com.intellij.openapi.vfs.VfsUtilCore;
//import com.intellij.openapi.vfs.VirtualFile;
//import com.intellij.packaging.artifacts.Artifact;
//import com.intellij.uiDesigner.core.AbstractLayout;
//
//import java.io.File;
//import java.io.IOException;
import java.io.IOException;
/**
* @author nik
*/
public class UiDesignerExternalBuildTest /*extends ArtifactCompilerTestCase*/ {
//@Override
//protected boolean useExternalCompiler() {
// return true;
//}
//
////IDEA-94779
public void _testCopyFormsRuntimeToArtifact() throws IOException {
// VirtualFile file = createFile("src/A.java", "class A{}");
// VirtualFile srcRoot = file.getParent();
// Module module = addModule("a", srcRoot);
// Artifact a = addArtifact(root().module(module));
// make(a);
// assertOutput(a, fs().file("A.class"));
//
// File dir = PathManagerEx.findFileUnderCommunityHome("plugins/ui-designer/testData/build/copyFormsRuntimeToArtifact");
// FileUtil.copyDir(dir, VfsUtilCore.virtualToIoFile(srcRoot));
// srcRoot.refresh(false, false);
// make(a);
// File outputDir = VfsUtilCore.virtualToIoFile(getOutputDir(a));
// assertTrue(new File(outputDir, "A.class").exists());
// assertTrue(new File(outputDir, "B.class").exists());
//
// assertTrue(new File(outputDir, AbstractLayout.class.getName().replace('.', '/') + ".class").exists());
}
}