From 47155ba44f7e0c1f933cd55e45c349d6b368ce9d Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 18 Nov 2009 16:48:58 +0300 Subject: [PATCH] "Generate Ant Build" action restored --- .../compiler/actions/GenerateAntBuildAction.java | 1 - .../src/com/intellij/compiler/ant/ChunkBuild.java | 166 ++++++++++----------- .../src/com/intellij/compiler/ant/CleanModule.java | 8 +- .../intellij/compiler/ant/ChunkBuildExtension.java | 28 ---- .../src/build/ant/ChunkBuildPluginExtension.java | 4 - 5 files changed, 85 insertions(+), 122 deletions(-) rewrite java/compiler/impl/src/com/intellij/compiler/ant/ChunkBuild.java (61%) diff --git a/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java b/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java index 2429e59961..39e9fd3cf8 100644 --- a/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java +++ b/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java @@ -106,7 +106,6 @@ public class GenerateAntBuildAction extends CompileActionBase { Presentation presentation = event.getPresentation(); Project project = PlatformDataKeys.PROJECT.getData(event.getDataContext()); presentation.setEnabled(project != null); - presentation.setVisible(ChunkBuildExtension.hasBuildExtensions()); } private void generate(final Project project, final GenerationOptions genOptions) { diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/ChunkBuild.java b/java/compiler/impl/src/com/intellij/compiler/ant/ChunkBuild.java dissimilarity index 61% index 64d51d1b6d..39e2fa1dd6 100644 --- a/java/compiler/impl/src/com/intellij/compiler/ant/ChunkBuild.java +++ b/java/compiler/impl/src/com/intellij/compiler/ant/ChunkBuild.java @@ -1,84 +1,82 @@ -/* - * Copyright 2000-2009 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.compiler.ant; - -import com.intellij.compiler.ant.taskdefs.Path; -import com.intellij.compiler.ant.taskdefs.Property; -import com.intellij.openapi.compiler.CompilerBundle; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.vfs.VirtualFileManager; - -import java.io.File; - -/** - * @author Eugene Zhuravlev - * Date: Mar 22, 2004 - */ -public class ChunkBuild extends CompositeGenerator{ - - public ChunkBuild(Project project, ModuleChunk chunk, GenerationOptions genOptions) { - final File chunkBaseDir = chunk.getBaseDir(); - if (ChunkBuildExtension.hasSelfOutput(chunk)) { - if (genOptions.forceTargetJdk) { - if (chunk.isJdkInherited()) { - add(new Property(BuildProperties.getModuleChunkJdkHomeProperty(chunk.getName()), BuildProperties.propertyRef(BuildProperties.PROPERTY_PROJECT_JDK_HOME))); - add(new Property(BuildProperties.getModuleChunkJdkBinProperty(chunk.getName()), BuildProperties.propertyRef(BuildProperties.PROPERTY_PROJECT_JDK_BIN))); - add(new Property(BuildProperties.getModuleChunkJdkClasspathProperty(chunk.getName()), BuildProperties.propertyRef(BuildProperties.PROPERTY_PROJECT_JDK_CLASSPATH))); - } - else { - final Sdk jdk = chunk.getJdk(); - add(new Property(BuildProperties.getModuleChunkJdkHomeProperty(chunk.getName()), jdk != null? BuildProperties.propertyRef(BuildProperties.getJdkHomeProperty(jdk.getName())): "")); - add(new Property(BuildProperties.getModuleChunkJdkBinProperty(chunk.getName()), jdk != null? BuildProperties.propertyRef(BuildProperties.getJdkBinProperty(jdk.getName())): "")); - add(new Property(BuildProperties.getModuleChunkJdkClasspathProperty(chunk.getName()), jdk != null? BuildProperties.getJdkPathId(jdk.getName()) : "")); - } - } - - add(new Property(BuildProperties.getModuleChunkCompilerArgsProperty(chunk.getName()), BuildProperties.propertyRef(BuildProperties.PROPERTY_COMPILER_ADDITIONAL_ARGS)), 1); - - final String outputPathUrl = chunk.getOutputDirUrl(); - String location = outputPathUrl != null? - GenerationUtils.toRelativePath(VirtualFileManager.extractPath(outputPathUrl), chunkBaseDir, BuildProperties.getModuleChunkBasedirProperty(chunk), genOptions) : - CompilerBundle.message("value.undefined"); - add(new Property(BuildProperties.getOutputPathProperty(chunk.getName()), location), 1); - - final String testOutputPathUrl = chunk.getTestsOutputDirUrl(); - if (testOutputPathUrl != null) { - location = GenerationUtils.toRelativePath(VirtualFileManager.extractPath(testOutputPathUrl), chunkBaseDir, BuildProperties.getModuleChunkBasedirProperty(chunk), genOptions); - } - add(new Property(BuildProperties.getOutputPathForTestsProperty(chunk.getName()), location)); - - add(createBootclasspath(chunk), 1); - add(new ModuleChunkClasspath(chunk, genOptions, false), 1); - add(new ModuleChunkClasspath(chunk, genOptions, true), 1); - - final ModuleChunkSourcepath moduleSources = new ModuleChunkSourcepath(project, chunk, genOptions); - add(moduleSources, 1); - add(new CompileModuleChunkTarget(project, chunk, moduleSources.getSourceRoots(), moduleSources.getTestSourceRoots(), chunkBaseDir, genOptions), 1); - add(new CleanModule(chunk), 1); - } - - ChunkBuildExtension.process(this, chunk, genOptions); - } - - private static Generator createBootclasspath(ModuleChunk chunk) { - final Path bootclasspath = new Path(BuildProperties.getBootClasspathProperty(chunk.getName())); - bootclasspath.add(new Comment(CompilerBundle.message("generated.ant.build.bootclasspath.comment"))); - return bootclasspath; - } - - -} +/* + * Copyright 2000-2009 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.compiler.ant; + +import com.intellij.compiler.ant.taskdefs.Path; +import com.intellij.compiler.ant.taskdefs.Property; +import com.intellij.openapi.compiler.CompilerBundle; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.vfs.VirtualFileManager; + +import java.io.File; + +/** + * @author Eugene Zhuravlev + * Date: Mar 22, 2004 + */ +public class ChunkBuild extends CompositeGenerator{ + + public ChunkBuild(Project project, ModuleChunk chunk, GenerationOptions genOptions) { + final File chunkBaseDir = chunk.getBaseDir(); + if (genOptions.forceTargetJdk) { + if (chunk.isJdkInherited()) { + add(new Property(BuildProperties.getModuleChunkJdkHomeProperty(chunk.getName()), BuildProperties.propertyRef(BuildProperties.PROPERTY_PROJECT_JDK_HOME))); + add(new Property(BuildProperties.getModuleChunkJdkBinProperty(chunk.getName()), BuildProperties.propertyRef(BuildProperties.PROPERTY_PROJECT_JDK_BIN))); + add(new Property(BuildProperties.getModuleChunkJdkClasspathProperty(chunk.getName()), BuildProperties.propertyRef(BuildProperties.PROPERTY_PROJECT_JDK_CLASSPATH))); + } + else { + final Sdk jdk = chunk.getJdk(); + add(new Property(BuildProperties.getModuleChunkJdkHomeProperty(chunk.getName()), jdk != null? BuildProperties.propertyRef(BuildProperties.getJdkHomeProperty(jdk.getName())): "")); + add(new Property(BuildProperties.getModuleChunkJdkBinProperty(chunk.getName()), jdk != null? BuildProperties.propertyRef(BuildProperties.getJdkBinProperty(jdk.getName())): "")); + add(new Property(BuildProperties.getModuleChunkJdkClasspathProperty(chunk.getName()), jdk != null? BuildProperties.getJdkPathId(jdk.getName()) : "")); + } + } + + add(new Property(BuildProperties.getModuleChunkCompilerArgsProperty(chunk.getName()), BuildProperties.propertyRef(BuildProperties.PROPERTY_COMPILER_ADDITIONAL_ARGS)), 1); + + final String outputPathUrl = chunk.getOutputDirUrl(); + String location = outputPathUrl != null? + GenerationUtils.toRelativePath(VirtualFileManager.extractPath(outputPathUrl), chunkBaseDir, BuildProperties.getModuleChunkBasedirProperty(chunk), genOptions) : + CompilerBundle.message("value.undefined"); + add(new Property(BuildProperties.getOutputPathProperty(chunk.getName()), location), 1); + + final String testOutputPathUrl = chunk.getTestsOutputDirUrl(); + if (testOutputPathUrl != null) { + location = GenerationUtils.toRelativePath(VirtualFileManager.extractPath(testOutputPathUrl), chunkBaseDir, BuildProperties.getModuleChunkBasedirProperty(chunk), genOptions); + } + add(new Property(BuildProperties.getOutputPathForTestsProperty(chunk.getName()), location)); + + add(createBootclasspath(chunk), 1); + add(new ModuleChunkClasspath(chunk, genOptions, false), 1); + add(new ModuleChunkClasspath(chunk, genOptions, true), 1); + + final ModuleChunkSourcepath moduleSources = new ModuleChunkSourcepath(project, chunk, genOptions); + add(moduleSources, 1); + add(new CompileModuleChunkTarget(project, chunk, moduleSources.getSourceRoots(), moduleSources.getTestSourceRoots(), chunkBaseDir, genOptions), 1); + add(new CleanModule(chunk), 1); + + ChunkBuildExtension.process(this, chunk, genOptions); + } + + private static Generator createBootclasspath(ModuleChunk chunk) { + final Path bootclasspath = new Path(BuildProperties.getBootClasspathProperty(chunk.getName())); + bootclasspath.add(new Comment(CompilerBundle.message("generated.ant.build.bootclasspath.comment"))); + return bootclasspath; + } + + +} diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/CleanModule.java b/java/compiler/impl/src/com/intellij/compiler/ant/CleanModule.java index d3041acca0..0b27face7e 100644 --- a/java/compiler/impl/src/com/intellij/compiler/ant/CleanModule.java +++ b/java/compiler/impl/src/com/intellij/compiler/ant/CleanModule.java @@ -27,10 +27,8 @@ public class CleanModule extends Target { public CleanModule(ModuleChunk chunk) { super(BuildProperties.getModuleCleanTargetName(chunk.getName()), null, CompilerBundle.message("generated.ant.build.cleanup.module.task.comment"), null); - if (ChunkBuildExtension.hasSelfOutput(chunk)) { - final String chunkName = chunk.getName(); - add(new Delete(BuildProperties.propertyRef(BuildProperties.getOutputPathProperty(chunkName)))); - add(new Delete(BuildProperties.propertyRef(BuildProperties.getOutputPathForTestsProperty(chunkName)))); - } + final String chunkName = chunk.getName(); + add(new Delete(BuildProperties.propertyRef(BuildProperties.getOutputPathProperty(chunkName)))); + add(new Delete(BuildProperties.propertyRef(BuildProperties.getOutputPathForTestsProperty(chunkName)))); } } diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/ChunkBuildExtension.java b/java/compiler/openapi/src/com/intellij/compiler/ant/ChunkBuildExtension.java index fb2592366f..ec48ecd1c0 100644 --- a/java/compiler/openapi/src/com/intellij/compiler/ant/ChunkBuildExtension.java +++ b/java/compiler/openapi/src/com/intellij/compiler/ant/ChunkBuildExtension.java @@ -19,7 +19,6 @@ package com.intellij.compiler.ant; import com.intellij.ExtensionPoints; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NonNls; @@ -30,15 +29,8 @@ import java.util.Arrays; import java.util.List; public abstract class ChunkBuildExtension { - /** - * true, if there are build extensions for the modules, the variable is accessed only from AWT thread - */ - private static Boolean myHasExtensions = null; - public static final ExtensionPointName EP_NAME = ExtensionPointName.create(ExtensionPoints.ANT_BUILD_GEN); - public abstract boolean haveSelfOutputs(Module[] modules); - @NotNull @NonNls public abstract String[] getTargets(final ModuleChunk chunk); @@ -48,26 +40,6 @@ public abstract class ChunkBuildExtension { public void generateProperties(final PropertyFileGenerator generator, final Project project, final GenerationOptions options) { } - public static boolean hasSelfOutput(ModuleChunk chunk) { - final ChunkBuildExtension[] extensions = Extensions.getRootArea().getExtensionPoint(EP_NAME).getExtensions(); - final Module[] modules = chunk.getModules(); - for (ChunkBuildExtension extension : extensions) { - if (extension.haveSelfOutputs(modules)) return true; - } - return false; - } - - /** - * @return true if there are build extensions registered - */ - public static boolean hasBuildExtensions() { - if (myHasExtensions == null) { - ChunkBuildExtension[] extensions = Extensions.getRootArea().getExtensionPoint(EP_NAME).getExtensions(); - myHasExtensions = extensions.length != 0; - } - return myHasExtensions; - } - public static String[] getAllTargets(ModuleChunk chunk) { List allTargets = new ArrayList(); final ChunkBuildExtension[] extensions = Extensions.getRootArea().getExtensionPoint(EP_NAME).getExtensions(); diff --git a/plugins/devkit/src/build/ant/ChunkBuildPluginExtension.java b/plugins/devkit/src/build/ant/ChunkBuildPluginExtension.java index ccea0ee633..355c6ce894 100644 --- a/plugins/devkit/src/build/ant/ChunkBuildPluginExtension.java +++ b/plugins/devkit/src/build/ant/ChunkBuildPluginExtension.java @@ -38,10 +38,6 @@ import java.util.Set; public class ChunkBuildPluginExtension extends ChunkBuildExtension { - public boolean haveSelfOutputs(Module[] modules) { - return true; - } - @NotNull public String[] getTargets(final ModuleChunk chunk) { return isPlugins(chunk.getModules()) ? new String[] {PluginBuildProperties.getBuildJarTargetName(chunk.getName())} -- 2.11.4.GIT