mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
compiler-openapi
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" 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" />
|
||||
<orderEntry type="module" module-name="openapi" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
<setting name="state" value="0" />
|
||||
</Base>
|
||||
<LanguageOptions name="HTML">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="2" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
<LanguageOptions name="JAVA">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="/* * Copyright (c) &#36;today.year Your Corporation. All Rights Reserved. */" />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="2" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
<LanguageOptions name="JSP">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="2" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
<LanguageOptions name="JavaScript">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="2" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
<LanguageOptions name="Properties">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="2" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
<LanguageOptions name="XML">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="2" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
<LanguageOptions name="__TEMPLATE__">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="Copyright 2000-&#36;{today.year} 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." />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="4" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
public abstract class CompilerConfiguration {
|
||||
// need this flag for profiling purposes. In production code is always set to 'true'
|
||||
public static final boolean MAKE_ENABLED = true;
|
||||
|
||||
public static CompilerConfiguration getInstance(Project project) {
|
||||
return project.getComponent(CompilerConfiguration.class);
|
||||
}
|
||||
|
||||
public abstract boolean isExcludedFromCompilation(VirtualFile virtualFile);
|
||||
|
||||
public abstract boolean isResourceFile(VirtualFile virtualFile);
|
||||
|
||||
public abstract boolean isResourceFile(String path);
|
||||
|
||||
public abstract void addResourceFilePattern(String namePattern) throws MalformedPatternException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author Eugene Zhuravlev
|
||||
*/
|
||||
package com.intellij.compiler;
|
||||
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
|
||||
@State(
|
||||
name = "CompilerWorkspaceConfiguration",
|
||||
storages = {
|
||||
@Storage(
|
||||
id ="other",
|
||||
file = "$WORKSPACE_FILE$"
|
||||
)}
|
||||
)
|
||||
public class CompilerWorkspaceConfiguration implements PersistentStateComponent<CompilerWorkspaceConfiguration> {
|
||||
|
||||
public boolean COMPILE_IN_BACKGROUND = true;
|
||||
public boolean AUTO_SHOW_ERRORS_IN_EDITOR = true;
|
||||
@Deprecated public boolean CLOSE_MESSAGE_VIEW_IF_SUCCESS = true;
|
||||
public boolean COMPILE_DEPENDENT_FILES = false;
|
||||
public boolean CLEAR_OUTPUT_DIRECTORY = false;
|
||||
public boolean ASSERT_NOT_NULL = true;
|
||||
|
||||
public static CompilerWorkspaceConfiguration getInstance(Project project) {
|
||||
return ServiceManager.getService(project, CompilerWorkspaceConfiguration.class);
|
||||
}
|
||||
|
||||
public CompilerWorkspaceConfiguration getState() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void loadState(CompilerWorkspaceConfiguration state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.intellij.compiler;
|
||||
|
||||
public class MalformedPatternException extends RuntimeException {
|
||||
public MalformedPatternException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedMessage() {
|
||||
return getCause().getLocalizedMessage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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;
|
||||
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.util.Chunk;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.graph.CachingSemiGraph;
|
||||
import com.intellij.util.graph.DFSTBuilder;
|
||||
import com.intellij.util.graph.Graph;
|
||||
import com.intellij.util.graph.GraphGenerator;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import gnu.trove.TIntProcedure;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dsl
|
||||
*/
|
||||
public final class ModuleCompilerUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.ModuleCompilerUtil");
|
||||
private ModuleCompilerUtil() { }
|
||||
|
||||
public static Module[] getDependencies(Module module) {
|
||||
return ModuleRootManager.getInstance(module).getDependencies();
|
||||
}
|
||||
|
||||
public static Graph<Module> createModuleGraph(final Module[] modules) {
|
||||
return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<Module>() {
|
||||
public Collection<Module> getNodes() {
|
||||
return Arrays.asList(modules);
|
||||
}
|
||||
|
||||
public Iterator<Module> getIn(Module module) {
|
||||
return Arrays.asList(getDependencies(module)).iterator();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static List<Chunk<Module>> getSortedModuleChunks(Project project, List<Module> modules) {
|
||||
final Module[] allModules = ModuleManager.getInstance(project).getModules();
|
||||
final List<Chunk<Module>> chunks = getSortedChunks(createModuleGraph(allModules));
|
||||
|
||||
final Set<Module> modulesSet = new HashSet<Module>(modules);
|
||||
// leave only those chunks that contain at least one module from modules
|
||||
for (Iterator<Chunk<Module>> it = chunks.iterator(); it.hasNext();) {
|
||||
final Chunk<Module> chunk = it.next();
|
||||
if (!ContainerUtil.intersects(chunk.getNodes(), modulesSet)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
||||
public static <Node> List<Chunk<Node>> getSortedChunks(final Graph<Node> graph) {
|
||||
final Graph<Chunk<Node>> chunkGraph = toChunkGraph(graph);
|
||||
final List<Chunk<Node>> chunks = new ArrayList<Chunk<Node>>(chunkGraph.getNodes().size());
|
||||
for (final Chunk<Node> chunk : chunkGraph.getNodes()) {
|
||||
chunks.add(chunk);
|
||||
}
|
||||
DFSTBuilder<Chunk<Node>> builder = new DFSTBuilder<Chunk<Node>>(chunkGraph);
|
||||
if (!builder.isAcyclic()) {
|
||||
LOG.error("Acyclic graph expected");
|
||||
return null;
|
||||
}
|
||||
|
||||
Collections.sort(chunks, builder.comparator());
|
||||
return chunks;
|
||||
}
|
||||
|
||||
public static <Node> Graph<Chunk<Node>> toChunkGraph(final Graph<Node> graph) {
|
||||
final DFSTBuilder<Node> builder = new DFSTBuilder<Node>(graph);
|
||||
final TIntArrayList sccs = builder.getSCCs();
|
||||
|
||||
final List<Chunk<Node>> chunks = new ArrayList<Chunk<Node>>(sccs.size());
|
||||
final Map<Node, Chunk<Node>> nodeToChunkMap = new LinkedHashMap<Node, Chunk<Node>>();
|
||||
sccs.forEach(new TIntProcedure() {
|
||||
int myTNumber = 0;
|
||||
public boolean execute(int size) {
|
||||
final Set<Node> chunkNodes = new LinkedHashSet<Node>();
|
||||
final Chunk<Node> chunk = new Chunk<Node>(chunkNodes);
|
||||
chunks.add(chunk);
|
||||
for (int j = 0; j < size; j++) {
|
||||
final Node node = builder.getNodeByTNumber(myTNumber + j);
|
||||
chunkNodes.add(node);
|
||||
nodeToChunkMap.put(node, chunk);
|
||||
}
|
||||
|
||||
myTNumber += size;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<Chunk<Node>>() {
|
||||
public Collection<Chunk<Node>> getNodes() {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
public Iterator<Chunk<Node>> getIn(Chunk<Node> chunk) {
|
||||
final Set<Node> chunkNodes = chunk.getNodes();
|
||||
final Set<Chunk<Node>> ins = new LinkedHashSet<Chunk<Node>>();
|
||||
for (final Node node : chunkNodes) {
|
||||
for (Iterator<Node> nodeIns = graph.getIn(node); nodeIns.hasNext();) {
|
||||
final Node in = nodeIns.next();
|
||||
if (!chunk.containsNode(in)) {
|
||||
ins.add(nodeToChunkMap.get(in));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ins.iterator();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static void sortModules(final Project project, final List<Module> modules) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
Runnable sort = new Runnable() {
|
||||
public void run() {
|
||||
Comparator<Module> comparator = ModuleManager.getInstance(project).moduleDependencyComparator();
|
||||
Collections.sort(modules, comparator);
|
||||
}
|
||||
};
|
||||
if (application.isDispatchThread()) {
|
||||
sort.run();
|
||||
}
|
||||
else {
|
||||
application.runReadAction(sort);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 19-Dec-2006
|
||||
*/
|
||||
package com.intellij.compiler.ant;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class BuildProperties extends CompositeGenerator {
|
||||
public static final @NonNls String TARGET_ALL = "all";
|
||||
public static final @NonNls String TARGET_CLEAN = "clean";
|
||||
public static final @NonNls String TARGET_INIT = "init";
|
||||
public static final @NonNls String DEFAULT_TARGET = TARGET_ALL;
|
||||
public static final @NonNls String PROPERTY_COMPILER_NAME = "compiler.name";
|
||||
public static final @NonNls String PROPERTY_COMPILER_ADDITIONAL_ARGS = "compiler.args";
|
||||
public static final @NonNls String PROPERTY_COMPILER_MAX_MEMORY = "compiler.max.memory";
|
||||
public static final @NonNls String PROPERTY_COMPILER_EXCLUDES = "compiler.excluded";
|
||||
public static final @NonNls String PROPERTY_COMPILER_RESOURCE_PATTERNS = "compiler.resources";
|
||||
public static final @NonNls String PROPERTY_IGNORED_FILES = "ignored.files";
|
||||
public static final @NonNls String PROPERTY_COMPILER_GENERATE_DEBUG_INFO = "compiler.debug";
|
||||
public static final @NonNls String PROPERTY_COMPILER_GENERATE_NO_WARNINGS = "compiler.generate.no.warnings";
|
||||
public static final @NonNls String PROPERTY_PROJECT_JDK_HOME = "project.jdk.home";
|
||||
public static final @NonNls String PROPERTY_PROJECT_JDK_BIN = "project.jdk.bin";
|
||||
public static final @NonNls String PROPERTY_PROJECT_JDK_CLASSPATH = "project.jdk.classpath";
|
||||
public static final @NonNls String PROPERTY_SKIP_TESTS = "skip.tests";
|
||||
public static final @NonNls String PROPERTY_LIBRARIES_PATTERNS = "library.patterns";
|
||||
public static final @NonNls String PROPERTY_IDEA_HOME = "idea.home";
|
||||
public static final @NonNls String PROPERTY_JAVAC2_HOME = "javac2.home";
|
||||
public static final @NonNls String PROPERTY_JAVAC2_CLASSPATH_ID = "javac2.classpath";
|
||||
|
||||
protected abstract void createJdkGenerators(Project project);
|
||||
|
||||
public static Sdk[] getUsedJdks(Project project) {
|
||||
final Set<Sdk> jdks = new HashSet<Sdk>();
|
||||
Module[] modules = ModuleManager.getInstance(project).getModules();
|
||||
for (Module module : modules) {
|
||||
Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
|
||||
if (jdk != null) {
|
||||
jdks.add(jdk);
|
||||
}
|
||||
}
|
||||
return jdks.toArray(new Sdk[jdks.size()]);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getPropertyFileName(Project project) {
|
||||
return getProjectBuildFileName(project) + ".properties";
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getJdkPathId(@NonNls final String jdkName) {
|
||||
return "jdk.classpath." + convertName(jdkName);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getModuleChunkJdkClasspathProperty(@NonNls final String moduleChunkName) {
|
||||
return "module.jdk.classpath." + convertName(moduleChunkName);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getModuleChunkJdkHomeProperty(@NonNls final String moduleChunkName) {
|
||||
return "module.jdk.home." + convertName(moduleChunkName);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getModuleChunkJdkBinProperty(@NonNls final String moduleChunkName) {
|
||||
return "module.jdk.bin." + convertName(moduleChunkName);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getModuleChunkCompilerArgsProperty(@NonNls final String moduleName) {
|
||||
return "compiler.args." + convertName(moduleName);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getLibraryPathId(@NonNls final String libraryName) {
|
||||
return "library." + convertName(libraryName) + ".classpath";
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getJdkHomeProperty(@NonNls final String jdkName) {
|
||||
return "jdk.home." + convertName(jdkName);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getJdkBinProperty(@NonNls final String jdkName) {
|
||||
return "jdk.bin." + convertName(jdkName);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getCompileTargetName(@NonNls String moduleName) {
|
||||
return "compile.module." + convertName(moduleName);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getOutputPathProperty(@NonNls String moduleName) {
|
||||
return convertName(moduleName) + ".output.dir";
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getOutputPathForTestsProperty(@NonNls String moduleName) {
|
||||
return convertName(moduleName) + ".testoutput.dir";
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getClasspathProperty(@NonNls String moduleName) {
|
||||
return convertName(moduleName) + ".module.classpath";
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getRuntimeClasspathProperty(@NonNls String moduleName) {
|
||||
return convertName(moduleName) + ".runtime.module.classpath";
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getBootClasspathProperty(@NonNls String moduleName) {
|
||||
return convertName(moduleName) + ".module.bootclasspath";
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getSourcepathProperty(@NonNls String moduleName) {
|
||||
return convertName(moduleName) + ".module.sourcepath";
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getTestSourcepathProperty(@NonNls String moduleName) {
|
||||
return convertName(moduleName) + ".module.test.sourcepath";
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getExcludedFromModuleProperty(@NonNls String moduleName) {
|
||||
return "excluded.from.module." + convertName(moduleName);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getExcludedFromCompilationProperty(@NonNls String moduleName) {
|
||||
return "excluded.from.compilation." + convertName(moduleName);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getProjectBuildFileName(Project project) {
|
||||
return convertName(project.getName());
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getModuleChunkBuildFileName(final ModuleChunk chunk) {
|
||||
return "module_" + convertName(chunk.getName());
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getModuleCleanTargetName(@NonNls String moduleName) {
|
||||
return "clean.module." + convertName(moduleName);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getModuleChunkBasedirProperty(ModuleChunk chunk) {
|
||||
return "module." + convertName(chunk.getName()) + ".basedir";
|
||||
}
|
||||
|
||||
/**
|
||||
* left for compatibility
|
||||
*
|
||||
* @param module the module to get property for
|
||||
* @return name of the property
|
||||
*/
|
||||
@NonNls
|
||||
public static String getModuleBasedirProperty(Module module) {
|
||||
return "module." + convertName(module.getName()) + ".basedir";
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getProjectBaseDirProperty() {
|
||||
return "basedir";
|
||||
}
|
||||
|
||||
public static File getModuleChunkBaseDir(ModuleChunk chunk) {
|
||||
return chunk.getBaseDir();
|
||||
}
|
||||
|
||||
public static File getProjectBaseDir(final Project project) {
|
||||
final VirtualFile baseDir = project.getBaseDir();
|
||||
assert baseDir != null;
|
||||
return VfsUtil.virtualToIoFile(baseDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert name. All double quotes are removed and spaces are replaced with underscore.
|
||||
*
|
||||
* @param name a name to convert
|
||||
* @return a converted name
|
||||
*/
|
||||
@NonNls
|
||||
public static String convertName(@NonNls final String name) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
return name.replaceAll("\"", "").replaceAll("\\s+", "_").toLowerCase();
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getPathMacroProperty(@NonNls String pathMacro) {
|
||||
return "path.variable." + convertName(pathMacro);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String propertyRef(@NonNls String propertyName) {
|
||||
return "${" + propertyName + "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct path relative to the specified property
|
||||
*
|
||||
* @param propertyName the property name
|
||||
* @param relativePath the relative path
|
||||
* @return the path relative to the property
|
||||
*/
|
||||
@NonNls
|
||||
public static String propertyRelativePath(@NonNls String propertyName, @NonNls String relativePath) {
|
||||
return "${" + propertyName + "}/" + relativePath;
|
||||
}
|
||||
|
||||
|
||||
public static File toCanonicalFile(final File file) {
|
||||
File canonicalFile;
|
||||
try {
|
||||
canonicalFile = file.getCanonicalFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
canonicalFile = file;
|
||||
}
|
||||
return canonicalFile;
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getTempDirForModuleProperty(@NonNls String moduleName) {
|
||||
return "tmp.dir." + convertName(moduleName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 19-Dec-2006
|
||||
*/
|
||||
package com.intellij.compiler.ant;
|
||||
|
||||
import com.intellij.compiler.ant.taskdefs.Target;
|
||||
import com.intellij.openapi.compiler.make.BuildRecipe;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class BuildTargetsFactory {
|
||||
public static BuildTargetsFactory getInstance() {
|
||||
return ServiceManager.getService(BuildTargetsFactory.class);
|
||||
}
|
||||
|
||||
public abstract CompositeGenerator createCompositeBuildTarget(ExplodedAndJarTargetParameters parameters, @NonNls String targetName,
|
||||
String description, String depends, @Nullable String jarPath);
|
||||
|
||||
public abstract Target createBuildExplodedTarget(ExplodedAndJarTargetParameters parameters, BuildRecipe buildRecipe, String description);
|
||||
|
||||
public abstract Target createBuildJarTarget(ExplodedAndJarTargetParameters parameters, BuildRecipe buildRecipe, String description);
|
||||
|
||||
public abstract Generator createComment(String comment);
|
||||
|
||||
//for test
|
||||
public abstract GenerationOptions getDefaultOptions(Project project);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.ExtensionPoints;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public abstract class ChunkBuildExtension {
|
||||
public static final ExtensionPointName<ChunkBuildExtension> EP_NAME = ExtensionPointName.create(ExtensionPoints.ANT_BUILD_GEN);
|
||||
|
||||
public abstract boolean haveSelfOutputs(Module[] modules);
|
||||
|
||||
@NotNull
|
||||
@NonNls
|
||||
public abstract String[] getTargets(final ModuleChunk chunk);
|
||||
|
||||
public abstract void process(Project project, ModuleChunk chunk, GenerationOptions genOptions, CompositeGenerator generator);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static String[] getAllTargets(ModuleChunk chunk) {
|
||||
List<String> allTargets = new ArrayList<String>();
|
||||
final ChunkBuildExtension[] extensions = Extensions.getRootArea().getExtensionPoint(EP_NAME).getExtensions();
|
||||
for (ChunkBuildExtension extension : extensions) {
|
||||
allTargets.addAll(Arrays.asList(extension.getTargets(chunk)));
|
||||
}
|
||||
if (allTargets.isEmpty()) {
|
||||
allTargets.add(BuildProperties.getCompileTargetName(chunk.getName()));
|
||||
}
|
||||
return allTargets.toArray(new String[allTargets.size()]);
|
||||
}
|
||||
|
||||
public static void process(CompositeGenerator generator, ModuleChunk chunk, GenerationOptions genOptions) {
|
||||
final Project project = chunk.getProject();
|
||||
final ChunkBuildExtension[] extensions = Extensions.getRootArea().getExtensionPoint(EP_NAME).getExtensions();
|
||||
for (ChunkBuildExtension extension : extensions) {
|
||||
extension.process(project, chunk, genOptions, generator);
|
||||
}
|
||||
}
|
||||
|
||||
public static void generateAllProperties(final PropertyFileGenerator propertyFileGenerator, final Project project,
|
||||
final GenerationOptions genOptions) {
|
||||
ChunkBuildExtension[] extensions = Extensions.getRootArea().getExtensionPoint(EP_NAME).getExtensions();
|
||||
for (ChunkBuildExtension extension : extensions) {
|
||||
extension.generateProperties(propertyFileGenerator, project, genOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.intellij.compiler.ant;
|
||||
|
||||
import com.intellij.ExtensionPoints;
|
||||
import com.intellij.compiler.ant.taskdefs.PatternSetRef;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* The extenstion point for the custom compilers
|
||||
*/
|
||||
public abstract class ChunkCustomCompilerExtension {
|
||||
/**
|
||||
* Extension point name
|
||||
*/
|
||||
public static final ExtensionPointName<ChunkCustomCompilerExtension> EP_NAME =
|
||||
ExtensionPointName.create(ExtensionPoints.ANT_CUSTOM_COMPILER);
|
||||
/**
|
||||
* Comparator that compares extensions using names. It is used for make order of elements predictable.
|
||||
*/
|
||||
protected static final Comparator<ChunkCustomCompilerExtension> COMPARATOR = new Comparator<ChunkCustomCompilerExtension>() {
|
||||
public int compare(ChunkCustomCompilerExtension o1, ChunkCustomCompilerExtension o2) {
|
||||
return o1.getClass().getName().compareTo(o2.getClass().getName());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate custom compile task inside compile target. Note that if more
|
||||
* than one extension requested custom compilation, all of them are included into ant
|
||||
* build and fail task is added to the compile target.
|
||||
*
|
||||
* @param project the context project
|
||||
* @param chunk the chunk to compile
|
||||
* @param genOptions an options to compile
|
||||
* @param generator a generator where custom compilation tasks will be added.
|
||||
* @param compileTests if true, tests are compiled
|
||||
* @param compilerArgs the javac compilier arguements
|
||||
* @param bootclasspathTag the boot classpath element for the javac compiler
|
||||
* @param classpathTag the classpath tag for the javac compiler
|
||||
* @param compilerExcludes the compiler excluded tag
|
||||
* @param srcTag the soruce tag
|
||||
* @param outputPathRef the output path references
|
||||
*/
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public abstract void generateCustomCompile(Project project,
|
||||
ModuleChunk chunk,
|
||||
GenerationOptions genOptions,
|
||||
boolean compileTests,
|
||||
CompositeGenerator generator,
|
||||
Tag compilerArgs,
|
||||
Tag bootclasspathTag,
|
||||
Tag classpathTag,
|
||||
PatternSetRef compilerExcludes,
|
||||
Tag srcTag,
|
||||
String outputPathRef);
|
||||
|
||||
/**
|
||||
* Generate task registration for custom compiler if needed.
|
||||
*
|
||||
* @param project the context project
|
||||
* @param genOptions an options to compile
|
||||
* @param generator a generator where custom compilation tasks will be added.
|
||||
*/
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public abstract void generateCustomCompilerTaskRegistration(Project project, GenerationOptions genOptions, CompositeGenerator generator);
|
||||
|
||||
/**
|
||||
* Allows to check if the custom compilation task is required to compile module sources.
|
||||
* Such task should be able to process standard java sources as well.
|
||||
*
|
||||
* @param chunk a chunk to check
|
||||
* @return true if the facet requires custom comiplation.
|
||||
*/
|
||||
@SuppressWarnings({"UnusedDeclaration", "MethodMayBeStatic"})
|
||||
public abstract boolean hasCustomCompile(final ModuleChunk chunk);
|
||||
|
||||
/**
|
||||
* Get custom compilation providers for module chunk
|
||||
*
|
||||
* @param chunk a chunk to examine
|
||||
* @return a list of custom compilators
|
||||
*/
|
||||
public static ChunkCustomCompilerExtension[] getCustomCompile(ModuleChunk chunk) {
|
||||
final ChunkCustomCompilerExtension[] extensions = Extensions.getRootArea().getExtensionPoint(EP_NAME).getExtensions();
|
||||
LinkedList<ChunkCustomCompilerExtension> compilers = new LinkedList<ChunkCustomCompilerExtension>();
|
||||
for (ChunkCustomCompilerExtension extension : extensions) {
|
||||
if (extension.hasCustomCompile(chunk)) {
|
||||
compilers.add(extension);
|
||||
}
|
||||
}
|
||||
final ChunkCustomCompilerExtension[] rc = compilers.toArray(new ChunkCustomCompilerExtension[compilers.size()]);
|
||||
Arrays.sort(rc, ChunkCustomCompilerExtension.COMPARATOR);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.util.Pair;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A composite generator
|
||||
*
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 25, 2004
|
||||
*/
|
||||
public class CompositeGenerator extends Generator {
|
||||
/**
|
||||
* child generators
|
||||
*/
|
||||
private final List<Pair<Generator, Integer>> myGenerators = new ArrayList<Pair<Generator, Integer>>();
|
||||
/**
|
||||
* New line property
|
||||
*/
|
||||
private boolean hasLeadingNewline = true;
|
||||
|
||||
/**
|
||||
* A constructor
|
||||
*/
|
||||
public CompositeGenerator() {
|
||||
}
|
||||
|
||||
/**
|
||||
* A constructor that adds two elements
|
||||
*
|
||||
* @param generator1 the first generator
|
||||
* @param generator2 the second generator
|
||||
* @param emptyLinesCount the amount of new lines between two generators
|
||||
*/
|
||||
public CompositeGenerator(Generator generator1, Generator generator2, int emptyLinesCount) {
|
||||
add(generator1);
|
||||
add(generator2, emptyLinesCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, the composite generator generates an empty newline before generating nested eleemnts.
|
||||
* Setting the property to the false, allows suppressing it.
|
||||
*
|
||||
* @param value the new value of the property
|
||||
*/
|
||||
public void setHasLeadingNewline(boolean value) {
|
||||
hasLeadingNewline = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add child generator with no emtpy lines before it
|
||||
*
|
||||
* @param generator the generator to add
|
||||
*/
|
||||
public final void add(Generator generator) {
|
||||
add(generator, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add child generator with the specified amount of empty lines before it
|
||||
*
|
||||
* @param generator a generator
|
||||
* @param emptyLinesCount amount of empty lines
|
||||
*/
|
||||
public final void add(Generator generator, int emptyLinesCount) {
|
||||
myGenerators.add(new Pair<Generator, Integer>(generator, new Integer(emptyLinesCount)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate content.
|
||||
*
|
||||
* @param out output stream
|
||||
* @throws IOException in case of IO propblem
|
||||
* @see #setHasLeadingNewline(boolean)
|
||||
*/
|
||||
public void generate(PrintWriter out) throws IOException {
|
||||
boolean first = true;
|
||||
for (final Pair<Generator, Integer> pair : myGenerators) {
|
||||
if (first) {
|
||||
if (hasLeadingNewline) {
|
||||
crlf(out);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
else {
|
||||
crlf(out);
|
||||
}
|
||||
final int emptyLinesCount = pair.getSecond().intValue();
|
||||
for (int idx = 0; idx < emptyLinesCount; idx++) {
|
||||
crlf(out);
|
||||
}
|
||||
pair.getFirst().generate(out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return amount of the child generators
|
||||
*/
|
||||
public final int getGeneratorCount() {
|
||||
return myGenerators.size();
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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 org.jetbrains.annotations.NonNls;
|
||||
import com.intellij.openapi.compiler.make.CompoundBuildInstruction;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class CompoundBuildInstructionNaming {
|
||||
@NonNls
|
||||
public abstract String getBuildExplodedTargetName(CompoundBuildInstruction instruction);
|
||||
|
||||
@NonNls
|
||||
public abstract String getBuildJarTargetName(CompoundBuildInstruction instruction);
|
||||
|
||||
@NonNls
|
||||
public abstract String getExplodedPathProperty(CompoundBuildInstruction instruction);
|
||||
|
||||
@NonNls
|
||||
public abstract String getJarPathProperty(CompoundBuildInstruction instruction);
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make.BuildConfiguration;
|
||||
import com.intellij.openapi.compiler.make.CompoundBuildInstruction;
|
||||
import com.intellij.openapi.module.Module;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ExplodedAndJarTargetParameters {
|
||||
private final ModuleChunk myChunk;
|
||||
private final Module myContainingModule;
|
||||
private final GenerationOptions myGenerationOptions;
|
||||
private final String myExplodedPathParameter;
|
||||
private final String myJarPathParameter;
|
||||
private final String myBuildExplodedTargetName;
|
||||
private final String myBuildJarTargetName;
|
||||
private final String myExplodedPathProperty;
|
||||
private final String myJarPathProperty;
|
||||
private final BuildConfiguration myBuildConfiguration;
|
||||
private final CompoundBuildInstructionNaming myCompoundBuildInstructionNaming;
|
||||
|
||||
public ExplodedAndJarTargetParameters(final ModuleChunk chunk,
|
||||
final Module containingModule,
|
||||
final GenerationOptions generationOptions,
|
||||
final BuildConfiguration buildConfiguration,
|
||||
final String explodedPathParameter,
|
||||
final String jarPathParameter,
|
||||
final String buildExplodedTargetName,
|
||||
final String buildJarTargetName,
|
||||
final String explodedPathProperty,
|
||||
final String jarPathProperty, final CompoundBuildInstructionNaming compoundBuildInstructionNaming) {
|
||||
myCompoundBuildInstructionNaming = compoundBuildInstructionNaming;
|
||||
myBuildConfiguration = buildConfiguration;
|
||||
myChunk = chunk;
|
||||
myContainingModule = containingModule;
|
||||
myGenerationOptions = generationOptions;
|
||||
myExplodedPathParameter = explodedPathParameter;
|
||||
myJarPathParameter = jarPathParameter;
|
||||
myBuildExplodedTargetName = buildExplodedTargetName;
|
||||
myBuildJarTargetName = buildJarTargetName;
|
||||
myExplodedPathProperty = explodedPathProperty;
|
||||
myJarPathProperty = jarPathProperty;
|
||||
}
|
||||
|
||||
public ModuleChunk getChunk() {
|
||||
return myChunk;
|
||||
}
|
||||
|
||||
public GenerationOptions getGenerationOptions() {
|
||||
return myGenerationOptions;
|
||||
}
|
||||
|
||||
public String getExplodedPathParameter() {
|
||||
return myExplodedPathParameter;
|
||||
}
|
||||
|
||||
public String getJarPathParameter() {
|
||||
return myJarPathParameter;
|
||||
}
|
||||
|
||||
public Module getContainingModule() {
|
||||
return myContainingModule;
|
||||
}
|
||||
|
||||
public String getBuildExplodedTargetName() {
|
||||
return myBuildExplodedTargetName;
|
||||
}
|
||||
|
||||
public String getBuildJarTargetName() {
|
||||
return myBuildJarTargetName;
|
||||
}
|
||||
|
||||
public String getExplodedPathProperty() {
|
||||
return myExplodedPathProperty;
|
||||
}
|
||||
|
||||
public String getJarPathProperty() {
|
||||
return myJarPathProperty;
|
||||
}
|
||||
|
||||
public CompoundBuildInstructionNaming getCompoundBuildInstructionNaming() {
|
||||
return myCompoundBuildInstructionNaming;
|
||||
}
|
||||
|
||||
public BuildConfiguration getBuildConfiguration() {
|
||||
return myBuildConfiguration;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.module.Module;
|
||||
|
||||
/**
|
||||
* Ant file generation options. This object is availalbe during construction of ant object tree.
|
||||
*
|
||||
* @author anna
|
||||
*/
|
||||
public abstract class GenerationOptions {
|
||||
/**
|
||||
* This option specifies whether mulitfile or single file ant script is created.
|
||||
*/
|
||||
public final boolean generateSingleFile;
|
||||
/**
|
||||
* This option specifies whehter standard javac or javac2 task is used
|
||||
*/
|
||||
public final boolean enableFormCompiler;
|
||||
/**
|
||||
* This option speciries whether files are backed up before generation
|
||||
*/
|
||||
public final boolean backupPreviouslyGeneratedFiles;
|
||||
/**
|
||||
* This option specifies whether target JDK is forced during compilation or default ant JDK is used.
|
||||
*/
|
||||
public final boolean forceTargetJdk;
|
||||
/**
|
||||
* if true, the runtime classpath is inlined
|
||||
*/
|
||||
public final boolean inlineRuntimeClasspath;
|
||||
/**
|
||||
* if true, the runtime classpath is inlined
|
||||
*/
|
||||
public final boolean expandJarDirectories;
|
||||
|
||||
|
||||
/**
|
||||
* A constructor
|
||||
*
|
||||
* @param forceTargetJdk a value of corresponding option
|
||||
* @param generateSingleFile a value of corresponding option
|
||||
* @param enableFormCompiler a value of corresponding option
|
||||
* @param backupPreviouslyGeneratedFiles a value of corresponding option
|
||||
* @param inlineRuntimeClasspath if true, a runtiem classpaths are inlined
|
||||
* @param expandJarDirectories if true, jar directories are expaned
|
||||
*/
|
||||
public GenerationOptions(boolean forceTargetJdk,
|
||||
boolean generateSingleFile,
|
||||
boolean enableFormCompiler,
|
||||
boolean backupPreviouslyGeneratedFiles,
|
||||
boolean inlineRuntimeClasspath,
|
||||
boolean expandJarDirectories) {
|
||||
this.forceTargetJdk = forceTargetJdk;
|
||||
this.generateSingleFile = generateSingleFile;
|
||||
this.enableFormCompiler = enableFormCompiler;
|
||||
this.backupPreviouslyGeneratedFiles = backupPreviouslyGeneratedFiles;
|
||||
this.inlineRuntimeClasspath = inlineRuntimeClasspath;
|
||||
this.expandJarDirectories = expandJarDirectories;
|
||||
}
|
||||
|
||||
/**
|
||||
* A constructor
|
||||
*
|
||||
* @param forceTargetJdk a value of corresponding option
|
||||
* @param generateSingleFile a value of corresponding option
|
||||
* @param enableFormCompiler a value of corresponding option
|
||||
* @param backupPreviouslyGeneratedFiles a value of corresponding option
|
||||
* @param inlineRuntimeClasspath if true a runtiem classpaths are inlined
|
||||
*/
|
||||
public GenerationOptions(boolean forceTargetJdk,
|
||||
boolean generateSingleFile,
|
||||
boolean enableFormCompiler,
|
||||
boolean backupPreviouslyGeneratedFiles,
|
||||
boolean inlineRuntimeClasspath) {
|
||||
this(forceTargetJdk, generateSingleFile, enableFormCompiler, backupPreviouslyGeneratedFiles, inlineRuntimeClasspath, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* A constructor
|
||||
*
|
||||
* @param forceTargetJdk a value of corresponding option
|
||||
* @param generateSingleFile a value of corresponding option
|
||||
* @param enableFormCompiler a value of corresponding option
|
||||
* @param backupPreviouslyGeneratedFiles a value of corresponding option
|
||||
*/
|
||||
@Deprecated
|
||||
public GenerationOptions(boolean forceTargetJdk,
|
||||
boolean generateSingleFile,
|
||||
boolean enableFormCompiler,
|
||||
boolean backupPreviouslyGeneratedFiles) {
|
||||
this(forceTargetJdk, generateSingleFile, enableFormCompiler, backupPreviouslyGeneratedFiles, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Substitute path prefix with macro reference if it matches some macro.
|
||||
*
|
||||
* @param path a path to update
|
||||
* @return an updated path or argument
|
||||
*/
|
||||
public abstract String subsitutePathWithMacros(String path);
|
||||
|
||||
/**
|
||||
* Get property reference for the specified url of module output directory
|
||||
*
|
||||
* @param url an URL to map
|
||||
* @return the property reference in the form ${..}
|
||||
*/
|
||||
public abstract String getPropertyRefForUrl(String url);
|
||||
|
||||
/**
|
||||
* @return an array of module chunks. an array must not be modified by the clients.
|
||||
*/
|
||||
public abstract ModuleChunk[] getModuleChunks();
|
||||
|
||||
/**
|
||||
* Get the chunk that contains the specified module.
|
||||
*
|
||||
* @param module the module to find
|
||||
* @return the chunk that contains specifid module
|
||||
*/
|
||||
public abstract ModuleChunk getChunkByModule(Module module);
|
||||
|
||||
/**
|
||||
* @return a set of custom compilers, each compiler is used at least once in some chunk.
|
||||
*/
|
||||
public abstract ChunkCustomCompilerExtension[] getCustomCompilers();
|
||||
|
||||
/**
|
||||
* @return true if the idea home property must be generated
|
||||
*/
|
||||
public abstract boolean isIdeaHomeGenerated();
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.module.Module;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.PathUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class GenerationUtils {
|
||||
private GenerationUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get relative file
|
||||
*
|
||||
* @param file a valid file (must be either belong to {@link com.intellij.openapi.vfs.LocalFileSystem} or to point to the root entry on
|
||||
* {@link com.intellij.openapi.vfs.JarFileSystem}.
|
||||
* @param chunk a module chunk.
|
||||
* @param genOptions generation options
|
||||
* @return a relative path
|
||||
*/
|
||||
@Nullable
|
||||
public static String toRelativePath(final VirtualFile file, final ModuleChunk chunk, final GenerationOptions genOptions) {
|
||||
final Module module = chunk.getModules()[0];
|
||||
final File moduleBaseDir = chunk.getBaseDir();
|
||||
return toRelativePath(file, moduleBaseDir, BuildProperties.getModuleBasedirProperty(module), genOptions,
|
||||
!chunk.isSavePathsRelative());
|
||||
}
|
||||
|
||||
public static String toRelativePath(final String file, final File baseDir, final Module module, final GenerationOptions genOptions) {
|
||||
return toRelativePath(file, baseDir, BuildProperties.getModuleBasedirProperty(module), genOptions, !module.isSavePathsRelative());
|
||||
}
|
||||
|
||||
public static String toRelativePath(final String path, final ModuleChunk chunk, final GenerationOptions genOptions) {
|
||||
return GenerationUtils.toRelativePath(path, chunk.getBaseDir(), BuildProperties.getModuleChunkBasedirProperty(chunk), genOptions,
|
||||
!chunk.isSavePathsRelative());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get relative file
|
||||
*
|
||||
* @param file a valid file (must be either belong to {@link com.intellij.openapi.vfs.LocalFileSystem} or to point to the root entry on
|
||||
* {@link com.intellij.openapi.vfs.JarFileSystem}.
|
||||
* @param baseDir base director for relative path calculation
|
||||
* @param baseDirPropertyName property name for the base directory
|
||||
* @param genOptions generation options
|
||||
* @param useAbsolutePathsForOuterPaths if true absolute paths will be used for outer paths.
|
||||
* @return a relative path
|
||||
*/
|
||||
@Nullable
|
||||
public static String toRelativePath(final VirtualFile file,
|
||||
final File baseDir,
|
||||
final String baseDirPropertyName,
|
||||
final GenerationOptions genOptions,
|
||||
final boolean useAbsolutePathsForOuterPaths) {
|
||||
final String localPath = PathUtil.getLocalPath(file);
|
||||
if (localPath == null) {
|
||||
return null;
|
||||
}
|
||||
return toRelativePath(localPath, baseDir, baseDirPropertyName, genOptions, useAbsolutePathsForOuterPaths);
|
||||
}
|
||||
|
||||
public static String toRelativePath(String path,
|
||||
File baseDir,
|
||||
@NonNls final String baseDirPropertyName,
|
||||
GenerationOptions genOptions,
|
||||
boolean useAbsolutePathsForOuterPaths) {
|
||||
path = normalizePath(path);
|
||||
final String substitutedPath = genOptions.subsitutePathWithMacros(path);
|
||||
if (!substitutedPath.equals(path)) {
|
||||
// path variable substitution has highest priority
|
||||
return substitutedPath;
|
||||
}
|
||||
if (baseDir != null) {
|
||||
File base;
|
||||
try {
|
||||
// use canonical paths in order to resolve symlinks
|
||||
base = baseDir.getCanonicalFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
base = baseDir;
|
||||
}
|
||||
final String relativepath = FileUtil.getRelativePath(base, new File(path));
|
||||
if (relativepath != null) {
|
||||
final boolean shouldUseAbsolutePath = useAbsolutePathsForOuterPaths && relativepath.indexOf("..") >= 0;
|
||||
if (!shouldUseAbsolutePath) {
|
||||
final String _relativePath = relativepath.replace(File.separatorChar, '/');
|
||||
final String root = BuildProperties.propertyRef(baseDirPropertyName);
|
||||
return ".".equals(_relativePath) ? root : root + "/" + _relativePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
return substitutedPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize path by ensuring that only "/" is used as file name separator.
|
||||
*
|
||||
* @param path the path to normalize
|
||||
* @return the normalized path
|
||||
*/
|
||||
public static String normalizePath(String path) {
|
||||
return path.replace(File.separatorChar, '/');
|
||||
}
|
||||
|
||||
public static String trimJarSeparator(final String path) {
|
||||
return path.endsWith(JarFileSystem.JAR_SEPARATOR) ? path.substring(0, path.length() - JarFileSystem.JAR_SEPARATOR.length()) : path;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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 java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 16, 2004
|
||||
*/
|
||||
public abstract class Generator {
|
||||
private static int ourIndent = 0;
|
||||
private static final int INDENT_SHIFT = 2;
|
||||
|
||||
public abstract void generate(PrintWriter out) throws IOException;
|
||||
|
||||
protected static void crlf(PrintWriter out) throws IOException {
|
||||
out.println();
|
||||
indent(out);
|
||||
}
|
||||
|
||||
protected static void shiftIndent() {
|
||||
ourIndent += INDENT_SHIFT;
|
||||
}
|
||||
|
||||
protected static void unshiftIndent() {
|
||||
ourIndent -= INDENT_SHIFT;
|
||||
}
|
||||
|
||||
protected static void indent(PrintWriter out) throws IOException {
|
||||
for (int idx = 0; idx < ourIndent; idx++) {
|
||||
out.print(" ");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write XML header
|
||||
* @param out a writer
|
||||
* @throws IOException in case of IO problem
|
||||
*/
|
||||
protected static void writeXmlHeader(final PrintWriter out) throws IOException {
|
||||
//noinspection HardCodedStringLiteral
|
||||
out.print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||
crlf(out);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.CompilerModuleExtension;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Module chunk consists of interdependent modules.
|
||||
*
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Nov 19, 2004
|
||||
*/
|
||||
public class ModuleChunk {
|
||||
/**
|
||||
* Modules in the chunk
|
||||
*/
|
||||
private final Module[] myModules;
|
||||
/**
|
||||
* A array of custom compilation providers.
|
||||
*/
|
||||
private final ChunkCustomCompilerExtension[] myCustomCompilers;
|
||||
/**
|
||||
* The main module in the chunck (guessed by heuristic or selected by user)
|
||||
*/
|
||||
private Module myMainModule;
|
||||
/**
|
||||
* Chucnk dependendencies
|
||||
*/
|
||||
private ModuleChunk[] myDependentChunks;
|
||||
private File myBaseDir = null;
|
||||
|
||||
public ModuleChunk(Module[] modules) {
|
||||
myModules = modules;
|
||||
Arrays.sort(myModules, new Comparator<Module>() {
|
||||
public int compare(final Module o1, final Module o2) {
|
||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
||||
}
|
||||
});
|
||||
myMainModule = myModules[0];
|
||||
myCustomCompilers = ChunkCustomCompilerExtension.getCustomCompile(this);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myMainModule.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an array of custom compilers for the module chunk
|
||||
*/
|
||||
public ChunkCustomCompilerExtension[] getCustomCompilers() {
|
||||
return myCustomCompilers;
|
||||
}
|
||||
|
||||
public Module[] getModules() {
|
||||
return myModules;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getOutputDirUrl() {
|
||||
return CompilerModuleExtension.getInstance(myMainModule).getCompilerOutputUrl();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTestsOutputDirUrl() {
|
||||
return CompilerModuleExtension.getInstance(myMainModule).getCompilerOutputUrlForTests();
|
||||
}
|
||||
|
||||
public boolean isSavePathsRelative() {
|
||||
return myMainModule.isSavePathsRelative();
|
||||
}
|
||||
|
||||
public boolean isJdkInherited() {
|
||||
return ModuleRootManager.getInstance(myMainModule).isSdkInherited();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Sdk getJdk() {
|
||||
return ModuleRootManager.getInstance(myMainModule).getSdk();
|
||||
}
|
||||
|
||||
public ModuleChunk[] getDependentChunks() {
|
||||
return myDependentChunks;
|
||||
}
|
||||
|
||||
public void setDependentChunks(ModuleChunk[] dependentChunks) {
|
||||
myDependentChunks = dependentChunks;
|
||||
}
|
||||
|
||||
public File getBaseDir() {
|
||||
if (myBaseDir != null) {
|
||||
return myBaseDir;
|
||||
}
|
||||
return new File(myMainModule.getModuleFilePath()).getParentFile();
|
||||
}
|
||||
|
||||
public void setBaseDir(File baseDir) {
|
||||
myBaseDir = baseDir;
|
||||
}
|
||||
|
||||
public void setMainModule(Module module) {
|
||||
myMainModule = module;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return myMainModule.getProject();
|
||||
}
|
||||
|
||||
public boolean contains(final Module module) {
|
||||
for (Module chunkModule : myModules) {
|
||||
if (chunkModule.equals(module)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.intellij.compiler.ant;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class PropertyFileGenerator extends Generator {
|
||||
/**
|
||||
* Add property. Note that property name and value
|
||||
* are automatically escaped when the property file
|
||||
* is generated.
|
||||
*
|
||||
* @param name a property name
|
||||
* @param value a property value
|
||||
*/
|
||||
public abstract void addProperty(String name, String value);
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class Tag extends CompositeGenerator {
|
||||
public static final Tag[] EMPTY_ARRAY = new Tag[0];
|
||||
private final String myTagName;
|
||||
private final Pair[] myTagOptions;
|
||||
|
||||
public Tag(@NonNls String tagName, Pair... tagOptions) {
|
||||
myTagName = tagName;
|
||||
myTagOptions = tagOptions;
|
||||
}
|
||||
|
||||
public void generate(PrintWriter out) throws IOException {
|
||||
out.print("<");
|
||||
out.print(myTagName);
|
||||
if (myTagOptions != null && myTagOptions.length > 0) {
|
||||
out.print(" ");
|
||||
int generated = 0;
|
||||
for (final Pair option : myTagOptions) {
|
||||
if (option == null) {
|
||||
continue;
|
||||
}
|
||||
if (generated > 0) {
|
||||
out.print(" ");
|
||||
}
|
||||
out.print((String)option.getFirst());
|
||||
out.print("=\"");
|
||||
out.print(StringUtil.escapeXml((String)option.getSecond()));
|
||||
out.print("\"");
|
||||
generated += 1;
|
||||
}
|
||||
}
|
||||
if (getGeneratorCount() > 0) {
|
||||
out.print(">");
|
||||
shiftIndent();
|
||||
try {
|
||||
super.generate(out);
|
||||
}
|
||||
finally {
|
||||
unshiftIndent();
|
||||
}
|
||||
crlf(out);
|
||||
out.print("</");
|
||||
out.print(myTagName);
|
||||
out.print(">");
|
||||
}
|
||||
else {
|
||||
out.print("/>");
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static Pair<String, String> pair(@NonNls String v1, @Nullable @NonNls String v2) {
|
||||
if (v2 == null) {
|
||||
return null;
|
||||
}
|
||||
return new Pair<String, String>(v1, v2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class AntCall extends Tag{
|
||||
|
||||
public AntCall(final String target) {
|
||||
super("antcall", new Pair[] {new Pair<String, String>("target", target)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 25, 2004
|
||||
*/
|
||||
public class AntProject extends Tag {
|
||||
public AntProject(@NonNls String name, @NonNls String defaultTarget) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("project", new Pair[]{new Pair<String, String>("name", name), new Pair<String, String>("default", defaultTarget)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class Attribute extends Tag{
|
||||
public Attribute(@NonNls String name, String value) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("attribute", new Pair[] {Pair.create("name", name),Pair.create("value", value)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 23, 2004
|
||||
*/
|
||||
public class Copy extends Tag {
|
||||
public Copy(@NonNls String toDir) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("copy", new Pair[] {new Pair<String, String>("todir", toDir)});
|
||||
}
|
||||
public Copy(@NonNls String file, @NonNls String toFile) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("copy", new Pair[] {new Pair<String, String>("file", file), new Pair<String, String>("tofile", toFile)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class Delete extends Tag{
|
||||
public Delete(@NonNls String dir) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("delete", new Pair[] {Pair.create("dir", dir)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class DirSet extends Tag{
|
||||
|
||||
public DirSet(@NonNls final String dir) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("dirset", new Pair[] {new Pair<String, String>("dir", dir)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 25, 2004
|
||||
*/
|
||||
public class Dirname extends Tag{
|
||||
public Dirname(@NonNls String property, @NonNls String file) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("dirname", new Pair[] {new Pair<String, String>("property", property), new Pair<String, String>("file", file)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class Exclude extends Tag {
|
||||
|
||||
public Exclude(@NonNls final String name) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("exclude", new Pair[] {new Pair<String, String>("name", name)});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class FileSet extends Tag{
|
||||
|
||||
public FileSet(@NonNls final String dir) {
|
||||
super("fileset", pair("dir", dir));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 24, 2004
|
||||
*/
|
||||
public class Import extends Tag{
|
||||
public Import(@NonNls String file, boolean optional) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("import", new Pair[] {new Pair<String, String>("file", file), new Pair<String, String>("optional", optional? "true" : "false")});
|
||||
}
|
||||
|
||||
public Import(@NonNls String file) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("import", new Pair[] {new Pair<String, String>("file", file)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class Include extends Tag {
|
||||
|
||||
public Include(@NonNls final String name) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("include", new Pair[] {new Pair<String, String>("name", name)});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class Jar extends Tag {
|
||||
public Jar(@NonNls final String destFile, @NonNls String duplicate) {
|
||||
this(destFile, duplicate, false);
|
||||
}
|
||||
|
||||
public Jar(@NonNls final String destFile, @NonNls String duplicate, final boolean useManifestFromFileSets) {
|
||||
super("jar", pair("destfile", destFile), pair("duplicate", duplicate), useManifestFromFileSets ? pair("filesetmanifest", "mergewithoutmain") : null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.BuildProperties;
|
||||
import com.intellij.compiler.ant.GenerationOptions;
|
||||
import com.intellij.compiler.ant.ModuleChunk;
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 16, 2004
|
||||
*/
|
||||
public class Javac extends Tag {
|
||||
|
||||
public Javac(GenerationOptions genOptions, ModuleChunk moduleChunk, final String outputDir) {
|
||||
super(getTagName(genOptions, moduleChunk), getAttributes(genOptions, outputDir, moduleChunk));
|
||||
}
|
||||
|
||||
private static String getTagName(GenerationOptions genOptions, ModuleChunk moduleChunk) {
|
||||
if (moduleChunk.getCustomCompilers().length > 0) {
|
||||
return "instrumentIdeaExtensions";
|
||||
}
|
||||
return genOptions.enableFormCompiler ? "javac2" : "javac";
|
||||
}
|
||||
|
||||
private static Pair[] getAttributes(GenerationOptions genOptions, String outputDir, ModuleChunk moduleChunk) {
|
||||
final List<Pair> pairs = new ArrayList<Pair>();
|
||||
pairs.add(pair("destdir", outputDir));
|
||||
if (moduleChunk.getCustomCompilers().length == 0) {
|
||||
pairs.add(pair("debug", BuildProperties.propertyRef(BuildProperties.PROPERTY_COMPILER_GENERATE_DEBUG_INFO)));
|
||||
pairs.add(pair("nowarn", BuildProperties.propertyRef(BuildProperties.PROPERTY_COMPILER_GENERATE_NO_WARNINGS)));
|
||||
pairs.add(pair("memorymaximumsize", BuildProperties.propertyRef(BuildProperties.PROPERTY_COMPILER_MAX_MEMORY)));
|
||||
pairs.add(pair("fork", "true"));
|
||||
if (genOptions.forceTargetJdk) {
|
||||
pairs.add(pair("executable", getExecutable(moduleChunk.getName())));
|
||||
}
|
||||
}
|
||||
return pairs.toArray(new Pair[pairs.size()]);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NonNls
|
||||
private static String getExecutable(String moduleName) {
|
||||
if (moduleName == null) {
|
||||
return null;
|
||||
}
|
||||
return BuildProperties.propertyRef(BuildProperties.getModuleChunkJdkBinProperty(moduleName)) + "/javac";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.compiler.make.ManifestBuilder;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class Manifest extends Tag{
|
||||
public Manifest() {
|
||||
super("manifest", new Pair[] {});
|
||||
}
|
||||
|
||||
public void applyAttributes(final java.util.jar.Manifest manifest) {
|
||||
ManifestBuilder.setGlobalAttributes(manifest.getMainAttributes());
|
||||
final Attributes mainAttributes = manifest.getMainAttributes();
|
||||
|
||||
List<Object> keys = new ArrayList<Object>(mainAttributes.keySet());
|
||||
Collections.sort(keys, new Comparator<Object>() {
|
||||
public int compare(final Object o1, final Object o2) {
|
||||
Attributes.Name name1 = (Attributes.Name)o1;
|
||||
Attributes.Name name2 = (Attributes.Name)o2;
|
||||
return name1.toString().compareTo(name2.toString());
|
||||
}
|
||||
});
|
||||
for (final Object o : keys) {
|
||||
Attributes.Name name = (Attributes.Name)o;
|
||||
String value = (String)mainAttributes.get(name);
|
||||
add(new Attribute(name.toString(), value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 17, 2004
|
||||
*/
|
||||
public class Mkdir extends Tag {
|
||||
public Mkdir(@NonNls String directory) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("mkdir", new Pair[] {new Pair<String, String>("dir", directory)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class Param extends Tag {
|
||||
public Param(@NonNls final String name, final String value) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("param", new Pair[] {
|
||||
new Pair<String, String>("name", name),
|
||||
new Pair<String, String>("value", value)
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class Path extends Tag {
|
||||
|
||||
public Path(@NonNls final String id) {
|
||||
super("path", pair("id", id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class PathElement extends Tag {
|
||||
|
||||
public PathElement(@NonNls String dir) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("pathelement", pair("location", dir));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class PathRef extends Tag{
|
||||
|
||||
public PathRef(@NonNls final String refid) {
|
||||
super("path", new Pair[] {pair("refid", refid)});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class PatternSet extends Tag{
|
||||
public PatternSet(@NonNls final String id) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("patternset", new Pair[] {new Pair<String, String>("id", id)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class PatternSetRef extends Tag{
|
||||
public PatternSetRef(@NonNls final String refid) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("patternset", new Pair[] {new Pair<String, String>("refid", refid)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class Property extends Tag {
|
||||
|
||||
public Property(@NonNls final String name, final String value) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("property", new Pair[] {
|
||||
new Pair<String, String>("name", name),
|
||||
new Pair<String, String>("value", value)
|
||||
});
|
||||
}
|
||||
|
||||
public Property(@NonNls final String filePath) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("property", new Pair[] {
|
||||
new Pair<String, String>("file", filePath),
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class Target extends Tag{
|
||||
public Target(@NonNls String name, String depends, String description, String unlessCondition) {
|
||||
super("target", getOptions(name, depends, description, unlessCondition));
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
private static Pair[] getOptions(@NonNls String name, @NonNls String depends, String description, @NonNls String unlessCondition) {
|
||||
final List<Pair> options = new ArrayList<Pair>();
|
||||
options.add(new Pair<String, String>("name", name));
|
||||
if (depends != null && depends.length() > 0) {
|
||||
options.add(new Pair<String, String>("depends", depends));
|
||||
}
|
||||
if (description != null && description.length() > 0) {
|
||||
options.add(new Pair<String, String>("description", description));
|
||||
}
|
||||
if (unlessCondition != null && unlessCondition.length() > 0) {
|
||||
options.add(new Pair<String, String>("unless", unlessCondition));
|
||||
}
|
||||
return options.toArray(new Pair[options.size()]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 19-Dec-2006
|
||||
*/
|
||||
package com.intellij.compiler.ant.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class Zip extends Tag {
|
||||
public Zip(@NonNls final String destFile) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
super("zip", new Pair[] {Pair.create("destfile", destFile)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.taskdefs;
|
||||
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 19, 2004
|
||||
*/
|
||||
public class ZipFileSet extends Tag{
|
||||
public static final ZipFileSet[] EMPTY_ARRAY = new ZipFileSet[0];
|
||||
|
||||
public ZipFileSet(@NonNls String fileOrDir, @NonNls final String relativePath, boolean isDir) {
|
||||
super("zipfileset",
|
||||
pair(isDir ? "dir" : "file", fileOrDir),
|
||||
pair("prefix", prefix(isDir, relativePath)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String prefix(final boolean isDir, final String relativePath) {
|
||||
String path;
|
||||
if (isDir) {
|
||||
path = relativePath;
|
||||
}
|
||||
else {
|
||||
final String parent = new File(relativePath).getParent();
|
||||
path = parent == null ? "" : FileUtil.toSystemIndependentName(parent);
|
||||
}
|
||||
if (path != null) {
|
||||
path = StringUtil.trimStart(path, "/");
|
||||
}
|
||||
return !StringUtil.isEmpty(path) ? path : null;
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
|
||||
/**
|
||||
* A tag interface indicating that the compiler will instrument java classes.
|
||||
* This affects the order of compiler calls:
|
||||
* The sequence in which compilers are called:
|
||||
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
|
||||
*/
|
||||
public interface ClassInstrumentingCompiler extends FileProcessingCompiler {
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
|
||||
/**
|
||||
* A tag interface indicating that the compiler will take Java classes and perform some activities on them.
|
||||
* This affects the order of compiler calls:
|
||||
* The sequence in which compilers are called:
|
||||
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
|
||||
*/
|
||||
public interface ClassPostProcessingCompiler extends FileProcessingCompiler {
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* A listener for compiler events.
|
||||
*
|
||||
* @see CompilerManager#addCompilationStatusListener(CompilationStatusListener)
|
||||
*/
|
||||
public interface CompilationStatusListener extends EventListener {
|
||||
/**
|
||||
* Invoked in a Swing dispatch thread after the compilation is finished.
|
||||
*
|
||||
* @param aborted true if compilatioin has been cancelled
|
||||
* @param errors error count
|
||||
* @param warnings warning count
|
||||
* @param compileContext context for the finished compilation
|
||||
*/
|
||||
void compilationFinished(boolean aborted, int errors, int warnings, final CompileContext compileContext);
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An interface allowing access and modification of the data associated with the current compile session.
|
||||
*/
|
||||
public interface CompileContext extends UserDataHolder {
|
||||
/**
|
||||
* Allows to add a message to be shown in Compiler message view.
|
||||
* If correct url, line and column numbers are supplied, the navigation to the specified file is available from the view.
|
||||
*
|
||||
* @param category the category of a message (information, error, warning).
|
||||
* @param message the text of the message.
|
||||
* @param url a url to the file to which the message applies, null if not available.
|
||||
* @param lineNum a line number, -1 if not available.
|
||||
* @param columnNum a column number, -1 if not available.
|
||||
*/
|
||||
void addMessage(CompilerMessageCategory category, String message, @Nullable String url, int lineNum, int columnNum);
|
||||
|
||||
/**
|
||||
* Allows to add a message to be shown in Compiler message view, with a specified Navigatable
|
||||
* that is used to navigate to the error location.
|
||||
*
|
||||
* @param category the category of a message (information, error, warning).
|
||||
* @param message the text of the message.
|
||||
* @param url a url to the file to which the message applies, null if not available.
|
||||
* @param lineNum a line number, -1 if not available.
|
||||
* @param columnNum a column number, -1 if not available.
|
||||
* @param navigatable the navigatable pointing to the error location.
|
||||
* @since 6.0
|
||||
*/
|
||||
void addMessage(CompilerMessageCategory category, String message, @Nullable String url, int lineNum, int columnNum,
|
||||
Navigatable navigatable);
|
||||
|
||||
/**
|
||||
* Returns all messages of the specified category added during the current compile session.
|
||||
*
|
||||
* @param category the category for which messages are requested.
|
||||
* @return all compiler messages of the specified category
|
||||
*/
|
||||
CompilerMessage[] getMessages(CompilerMessageCategory category);
|
||||
|
||||
/**
|
||||
* Returns the count of messages of the specified category added during the current compile session.
|
||||
*
|
||||
* @param category the category for which messages are requested.
|
||||
* @return the number of messages of the specified category
|
||||
*/
|
||||
int getMessageCount(CompilerMessageCategory category);
|
||||
|
||||
/**
|
||||
* Returns the progress indicator of the compilation process.
|
||||
*
|
||||
* @return the progress indicator instance.
|
||||
*/
|
||||
ProgressIndicator getProgressIndicator();
|
||||
|
||||
/**
|
||||
* Returns the current compile scope.
|
||||
*
|
||||
* @return current compile scope
|
||||
*/
|
||||
CompileScope getCompileScope();
|
||||
|
||||
/**
|
||||
* Returns the compile scope which would be used if the entire project was rebuilt.
|
||||
* {@link #getCompileScope()} may return the scope, that is more narrow than ProjectCompileScope.
|
||||
*
|
||||
* @return project-wide compile scope.
|
||||
*/
|
||||
CompileScope getProjectCompileScope();
|
||||
|
||||
/**
|
||||
* A compiler may call this method in order to request complete project rebuild.
|
||||
* This may be necessary, for example, when compiler caches are corrupted.
|
||||
*/
|
||||
void requestRebuildNextTime(String message);
|
||||
|
||||
/**
|
||||
* Returns the module to which the specified file belongs. This method is aware of the file->module mapping
|
||||
* for generated files.
|
||||
*
|
||||
* @param file the file to check.
|
||||
* @return the module to which the file belongs
|
||||
*/
|
||||
Module getModuleByFile(VirtualFile file);
|
||||
|
||||
/**
|
||||
* Returns the source roots for the specified module.
|
||||
*
|
||||
* @return module's source roots as well as source roots for generated sources that are attributed to the module
|
||||
*/
|
||||
VirtualFile[] getSourceRoots(Module module);
|
||||
|
||||
/**
|
||||
* Returns the list of all output directories.
|
||||
*
|
||||
* @return a list of all configured output directories from all modules (including output directories for tests)
|
||||
*/
|
||||
VirtualFile[] getAllOutputDirectories();
|
||||
|
||||
/**
|
||||
* Returns the output directory for the specified module.
|
||||
*
|
||||
* @param module the module to check.
|
||||
* @return the output directory for the module specified, null if corresponding VirtualFile is not valid or directory not specified
|
||||
*/
|
||||
@Nullable
|
||||
VirtualFile getModuleOutputDirectory(Module module);
|
||||
|
||||
/**
|
||||
* Returns the test output directory for the specified module.
|
||||
*
|
||||
* @param module the module to check.
|
||||
* @return the tests output directory the module specified, null if corresponding VirtualFile is not valid. If in Paths settings
|
||||
* output directory for tests is not configured explicitly, but the output path is present, the output path will be returned.
|
||||
*/
|
||||
@Nullable
|
||||
VirtualFile getModuleOutputDirectoryForTests(Module module);
|
||||
|
||||
/**
|
||||
* Checks if the compilation is incremental, i.e. triggered by one of "Make" actions.
|
||||
*
|
||||
* @return true if compilation is incremental.
|
||||
*/
|
||||
boolean isMake();
|
||||
|
||||
boolean isRebuild();
|
||||
|
||||
Project getProject();
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface describing the current compilation scope.
|
||||
* Only sources that belong to the scope are compiled.
|
||||
*
|
||||
* @see CompilerManager#compile(CompileScope, CompileStatusNotification, boolean)
|
||||
*/
|
||||
public interface CompileScope extends UserDataHolder {
|
||||
CompileScope[] EMPTY_ARRAY = new CompileScope[0];
|
||||
/**
|
||||
* Returns the list of files within the scope.
|
||||
*
|
||||
* @param fileType the type of the files. Null should be passed if all available files are needed.
|
||||
* @param inSourceOnly if true, files are searched only in directories within the scope that are marked as "sources" or "test sources" in module settings.
|
||||
* Otherwise files are searched in all directories that belong to the scope.
|
||||
* @return a list of files of given type that belong to this scope.
|
||||
*/
|
||||
@NotNull
|
||||
VirtualFile[] getFiles(@Nullable FileType fileType, boolean inSourceOnly);
|
||||
|
||||
/**
|
||||
* Checks if the file with the specified URL belongs to the scope.
|
||||
*
|
||||
* @param url an VFS url. Note that actual file may not exist on the disk.
|
||||
* @return true if the url specified belongs to the scope, false otherwise.
|
||||
* Note: the method may be time-consuming.
|
||||
*/
|
||||
boolean belongs(String url);
|
||||
|
||||
/**
|
||||
* Returns the list of modules files in which belong to the scope.
|
||||
*
|
||||
* @return a list of modules this scope affects.
|
||||
*/
|
||||
@NotNull
|
||||
Module[] getAffectedModules();
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
/**
|
||||
* A callback interface passed to ComplerManager methods. Provides notification similar to
|
||||
* {@link CompilationStatusListener}.
|
||||
*
|
||||
* @see CompilerManager#compile(CompileScope, CompileStatusNotification, boolean)
|
||||
*/
|
||||
public interface CompileStatusNotification {
|
||||
/**
|
||||
* Invoked in a Swing dispatch thread after the compilation is finished.
|
||||
*
|
||||
* @param aborted true if compilation has been cancelled.
|
||||
* @param errors error count
|
||||
* @param warnings warning count
|
||||
* @param compileContext context for the finished compilation
|
||||
*/
|
||||
void finished(boolean aborted, int errors, int warnings, final CompileContext compileContext);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
/**
|
||||
* Describes a task to be executed before or after compilation.
|
||||
*
|
||||
* @see CompilerManager#addAfterTask(CompileTask)
|
||||
* @see CompilerManager#addBeforeTask(CompileTask)
|
||||
*/
|
||||
public interface CompileTask {
|
||||
/**
|
||||
* Executes the task.
|
||||
*
|
||||
* @param context current compile context
|
||||
* @return true if execution succeeded, false otherwise. If the task returns false, the compilation
|
||||
* is aborted, and it's expected that the task adds a message defining the reason for the failure
|
||||
* to the compile context.
|
||||
*/
|
||||
boolean execute(CompileContext context);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
|
||||
/**
|
||||
* Base interface for a custom compiler which participates in the IDEA build process.
|
||||
*
|
||||
* @see CompilerManager#addCompiler(Compiler)
|
||||
* @see CompilerManager#removeCompiler(Compiler)
|
||||
*/
|
||||
public interface Compiler {
|
||||
ExtensionPointName<Compiler> EP_NAME = ExtensionPointName.create("com.intellij.compiler");
|
||||
|
||||
/**
|
||||
* Returns the description of the compiler. All registered compilers should have unique description.
|
||||
*
|
||||
* @return the description string.
|
||||
*/
|
||||
@NotNull
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Called before compilation starts. If at least one of registered compilers returned false, compilation won't start.
|
||||
*
|
||||
* @param scope the scope on which the compilation is started.
|
||||
* @return true if everything is ok, false otherwise
|
||||
*/
|
||||
boolean validateConfiguration(CompileScope scope);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Sep 9, 2005
|
||||
*/
|
||||
public class CompilerBundle {
|
||||
private static Reference<ResourceBundle> ourBundle;
|
||||
|
||||
@NonNls private static final String BUNDLE = "messages.CompilerBundle";
|
||||
|
||||
private CompilerBundle() {
|
||||
}
|
||||
|
||||
public static String jdkHomeNotFoundMessage(final Sdk jdk) {
|
||||
return message("javac.error.jdk.home.missing", jdk.getName(), jdk.getHomePath());
|
||||
}
|
||||
|
||||
public static String message(@PropertyKey(resourceBundle = BUNDLE)String key, Object... params) {
|
||||
return CommonBundle.message(getBundle(), key, params);
|
||||
}
|
||||
|
||||
private static ResourceBundle getBundle() {
|
||||
ResourceBundle bundle = null;
|
||||
if (ourBundle != null) bundle = ourBundle.get();
|
||||
if (bundle == null) {
|
||||
bundle = ResourceBundle.getBundle(BUNDLE);
|
||||
ourBundle = new SoftReference<ResourceBundle>(bundle);
|
||||
}
|
||||
return bundle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.intellij.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public interface CompilerFactory {
|
||||
ExtensionPointName<CompilerFactory> EP_NAME = ExtensionPointName.create("com.intellij.compilerFactory");
|
||||
|
||||
Compiler[] createCompilers(final CompilerManager compilerManager);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.intellij.openapi.compiler;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Jul 9, 2009
|
||||
*/
|
||||
public interface CompilerFilter {
|
||||
CompilerFilter ALL = new CompilerFilter() {
|
||||
public boolean acceptCompiler(Compiler compiler) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @param compiler
|
||||
* @return true if this compiler can be executed
|
||||
*/
|
||||
boolean acceptCompiler(Compiler compiler);
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A "root" class in compiler subsystem - allows one to register a custom compiler or a compilation task, register/unregister a compilation listener
|
||||
* and invoke various types of compilations (make, compile, rebuild)
|
||||
*/
|
||||
public abstract class CompilerManager {
|
||||
/**
|
||||
* Returns the compiler manager instance for the specified project.
|
||||
*
|
||||
* @param project the project for which the manager is requested.
|
||||
* @return the manager instance.
|
||||
*/
|
||||
public static CompilerManager getInstance(Project project) {
|
||||
return ServiceManager.getService(project, CompilerManager.class);
|
||||
}
|
||||
|
||||
public abstract boolean isCompilationActive();
|
||||
|
||||
/**
|
||||
* Registers a custom compiler.
|
||||
*
|
||||
* @param compiler the compiler to register.
|
||||
*/
|
||||
public abstract void addCompiler(@NotNull Compiler compiler);
|
||||
|
||||
/**
|
||||
* Registers a custom translating compiler. Input and output filetype sets allow compiler manager
|
||||
* to sort translating compilers so that output of one compiler will be used as input for another one
|
||||
*
|
||||
* @param compiler compiler implementation
|
||||
* @param inputTypes a set of filetypes that compiler accepts as input
|
||||
* @param outputTypes a set of filetypes that compiler can generate
|
||||
*/
|
||||
public abstract void addTranslatingCompiler(@NotNull TranslatingCompiler compiler, Set<FileType> inputTypes, Set<FileType> outputTypes);
|
||||
|
||||
@NotNull
|
||||
public abstract Set<FileType> getRegisteredInputTypes(@NotNull TranslatingCompiler compiler);
|
||||
|
||||
@NotNull
|
||||
public abstract Set<FileType> getRegisteredOutputTypes(@NotNull TranslatingCompiler compiler);
|
||||
|
||||
/**
|
||||
* Unregisters a custom compiler.
|
||||
*
|
||||
* @param compiler the compiler to unregister.
|
||||
*/
|
||||
public abstract void removeCompiler(@NotNull Compiler compiler);
|
||||
|
||||
/**
|
||||
* Returns all registered compilers of the specified class.
|
||||
*
|
||||
* @param compilerClass the class for which the compilers should be returned.
|
||||
* @return all registered compilers of the specified class.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract <T extends Compiler> T[] getCompilers(@NotNull Class<T> compilerClass);
|
||||
|
||||
/**
|
||||
* Returns all registered compilers of the specified class that the filter accepts
|
||||
*
|
||||
* @param compilerClass the class for which the compilers should be returned.
|
||||
* @param filter additional filter to restrict compiler instances
|
||||
* @return all registered compilers of the specified class.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract <T extends Compiler> T[] getCompilers(@NotNull Class<T> compilerClass, CompilerFilter filter);
|
||||
|
||||
/**
|
||||
* Registers the type as a compilable type so that Compile action will be enabled on files of this type.
|
||||
*
|
||||
* @param type the type for which the Compile action is enabled.
|
||||
*/
|
||||
public abstract void addCompilableFileType(@NotNull FileType type);
|
||||
|
||||
/**
|
||||
* Unregisters the type as a compilable type so that Compile action will be disabled on files of this type.
|
||||
*
|
||||
* @param type the type for which the Compile action is disabled.
|
||||
*/
|
||||
public abstract void removeCompilableFileType(@NotNull FileType type);
|
||||
|
||||
/**
|
||||
* Checks if files of the specified type can be compiled by one of registered compilers.
|
||||
* If the compiler can process files of certain type, it should register this file type within
|
||||
* the CompilerManager as a compilable file type.
|
||||
*
|
||||
* @param type the type to check.
|
||||
* @return true if the file type is compilable, false otherwise.
|
||||
* @see com.intellij.openapi.compiler.CompilerManager#addCompilableFileType(FileType)
|
||||
*/
|
||||
public abstract boolean isCompilableFileType(@NotNull FileType type);
|
||||
|
||||
/**
|
||||
* Registers a compiler task that will be executed before the compilation.
|
||||
*
|
||||
* @param task the task to register.
|
||||
*/
|
||||
public abstract void addBeforeTask(@NotNull CompileTask task);
|
||||
|
||||
/**
|
||||
* Registers a compiler task that will be executed after the compilation.
|
||||
*
|
||||
* @param task the task to register.
|
||||
*/
|
||||
public abstract void addAfterTask(@NotNull CompileTask task);
|
||||
|
||||
/**
|
||||
* Returns the list of all tasks to be executed before compilation.
|
||||
*
|
||||
* @return all tasks to be executed before compilation.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract CompileTask[] getBeforeTasks();
|
||||
|
||||
/**
|
||||
* Returns the list of all tasks to be executed after compilation.
|
||||
*
|
||||
* @return all tasks to be executed after compilation.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract CompileTask[] getAfterTasks();
|
||||
|
||||
/**
|
||||
* Compile a set of files.
|
||||
*
|
||||
* @param files a list of files to compile. If a VirtualFile is a directory, all containing files are processed.
|
||||
* Compiler excludes are not honored.
|
||||
* @param callback a notification callback, or null if no notifications needed.
|
||||
* @param trackDependencies if true, all files that the given set depends on, recursively, will be compiled.
|
||||
*/
|
||||
public abstract void compile(@NotNull VirtualFile[] files, @Nullable CompileStatusNotification callback, boolean trackDependencies);
|
||||
|
||||
/**
|
||||
* Compile all sources (including test sources) from the module. Compiler excludes are not honored.
|
||||
*
|
||||
* @param module a module which sources are to be compiled
|
||||
* @param callback a notification callback, or null if no notifications needed
|
||||
* @param trackDependencies if true, all files that the given set depends on, recursively, will be compiled.
|
||||
*/
|
||||
public abstract void compile(@NotNull Module module, @Nullable CompileStatusNotification callback, final boolean trackDependencies);
|
||||
|
||||
/**
|
||||
* Compile all files from the scope given. Compiler excludes are not honored.
|
||||
*
|
||||
* @param scope a scope to be compiled
|
||||
* @param callback a notification callback, or null if no notifications needed
|
||||
* @param trackDependencies if true, all files that the given set depends on, recursively, will be compiled.
|
||||
*/
|
||||
public abstract void compile(@NotNull CompileScope scope, CompileStatusNotification callback, final boolean trackDependencies);
|
||||
|
||||
/**
|
||||
* Compile all modified files and all files that depend on them all over the project.
|
||||
* Files are compiled according to dependencies between the modules they belong to. Compiler excludes are honored.
|
||||
*
|
||||
* @param callback a notification callback, or null if no notifications needed
|
||||
*/
|
||||
public abstract void make(@Nullable CompileStatusNotification callback);
|
||||
|
||||
/**
|
||||
* Compile all modified files and all files that depend on them from the given module and all modules this module depends on recursively.
|
||||
* Files are compiled according to dependencies between the modules they belong to. Compiler excludes are honored.
|
||||
*
|
||||
* @param module a module which sources are to be compiled.
|
||||
* @param callback a notification callback, or null if no notifications needed.
|
||||
*/
|
||||
public abstract void make(@NotNull Module module, @Nullable CompileStatusNotification callback);
|
||||
|
||||
/**
|
||||
* Compile all modified files and all files that depend on them from the modules and all modules these modules depend on recursively.
|
||||
* Files are compiled according to dependencies between the modules they belong to. Compiler excludes are honored. All modules must belong to the same project.
|
||||
*
|
||||
* @param project a project modules belong to
|
||||
* @param modules modules to compile
|
||||
* @param callback a notification callback, or null if no notifications needed.
|
||||
*/
|
||||
public abstract void make(@NotNull Project project, @NotNull Module[] modules, @Nullable CompileStatusNotification callback);
|
||||
|
||||
/**
|
||||
* Compile all modified files and all files that depend on them from the scope given.
|
||||
* Files are compiled according to dependencies between the modules they belong to. Compiler excludes are honored. All modules must belong to the same project
|
||||
*
|
||||
* @param scope a scope to be compiled
|
||||
* @param callback a notification callback, or null if no notifications needed
|
||||
*/
|
||||
public abstract void make(@NotNull CompileScope scope, @Nullable CompileStatusNotification callback);
|
||||
|
||||
/**
|
||||
* Compile all modified files and all files that depend on them from the scope given.
|
||||
* Files are compiled according to dependencies between the modules they belong to. Compiler excludes are honored. All modules must belong to the same project
|
||||
*
|
||||
* @param scope a scope to be compiled
|
||||
* @param filter filter allowing choose what compilers should be executed
|
||||
* @param callback a notification callback, or null if no notifications needed
|
||||
*/
|
||||
public abstract void make(@NotNull CompileScope scope, CompilerFilter filter, @Nullable CompileStatusNotification callback);
|
||||
|
||||
/**
|
||||
* Checks if compile scope given is up-to-date
|
||||
* @param scope
|
||||
* @return true if make on the scope specified wouldn't do anything or false if something is to be compiled or deleted
|
||||
*/
|
||||
public abstract boolean isUpToDate(@NotNull CompileScope scope);
|
||||
/**
|
||||
* Rebuild the whole project from scratch. Compiler excludes are honored.
|
||||
*
|
||||
* @param callback a notification callback, or null if no notifications needed
|
||||
*/
|
||||
public abstract void rebuild(@Nullable CompileStatusNotification callback);
|
||||
|
||||
/**
|
||||
* Execute a custom compile task.
|
||||
*
|
||||
* @param task the task to execute.
|
||||
* @param scope compile scope for which the task is executed.
|
||||
* @param contentName the name of a tab in message view where the execution results will be displayed.
|
||||
* @param onTaskFinished a runnable to be executed when the task finishes, null if nothing should be executed.
|
||||
*/
|
||||
public abstract void executeTask(@NotNull CompileTask task, @NotNull CompileScope scope, String contentName,
|
||||
@Nullable Runnable onTaskFinished);
|
||||
|
||||
/**
|
||||
* Register a listener to track compilation events.
|
||||
*
|
||||
* @param listener the listener to be registered.
|
||||
*/
|
||||
public abstract void addCompilationStatusListener(@NotNull CompilationStatusListener listener);
|
||||
|
||||
/**
|
||||
* Unregister a compilation listener.
|
||||
*
|
||||
* @param listener the listener to be unregistered.
|
||||
*/
|
||||
public abstract void removeCompilationStatusListener(@NotNull CompilationStatusListener listener);
|
||||
|
||||
/**
|
||||
* Checks if the specified file is excluded from compilation.
|
||||
*
|
||||
* @param file the file to check.
|
||||
* @return true if the file is excluded from compilation, false otherwise
|
||||
*/
|
||||
public abstract boolean isExcludedFromCompilation(@NotNull VirtualFile file);
|
||||
|
||||
@NotNull
|
||||
public abstract OutputToSourceMapping getJavaCompilerOutputMapping();
|
||||
|
||||
/*
|
||||
* Convetience methods for creating frequently-used compile scopes
|
||||
*/
|
||||
@NotNull
|
||||
public abstract CompileScope createFilesCompileScope(@NotNull VirtualFile[] files);
|
||||
@NotNull
|
||||
public abstract CompileScope createModuleCompileScope(@NotNull Module module, final boolean includeDependentModules);
|
||||
@NotNull
|
||||
public abstract CompileScope createModulesCompileScope(@NotNull Module[] modules, final boolean includeDependentModules);
|
||||
@NotNull
|
||||
public abstract CompileScope createModuleGroupCompileScope(@NotNull Project project, @NotNull Module[] modules, final boolean includeDependentModules);
|
||||
@NotNull
|
||||
public abstract CompileScope createProjectCompileScope(@NotNull Project project);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Describes a single compiler message that is shown in compiler message view.
|
||||
*
|
||||
* @see CompileContext#addMessage(CompilerMessageCategory, String, String, int, int)
|
||||
*/
|
||||
public interface CompilerMessage {
|
||||
/**
|
||||
* An empty array of compiler messages which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
CompilerMessage[] EMPTY_ARRAY = new CompilerMessage[0];
|
||||
|
||||
/**
|
||||
* Returns the category of the message.
|
||||
*
|
||||
* @return a category this message belongs to (error, warning, information).
|
||||
*/
|
||||
CompilerMessageCategory getCategory();
|
||||
|
||||
/**
|
||||
* Returs the message text.
|
||||
*
|
||||
* @return message text
|
||||
*/
|
||||
String getMessage();
|
||||
|
||||
/**
|
||||
* Returns the navigatable object allowing to navigate to the message source.
|
||||
*
|
||||
* @return the instance.
|
||||
*/
|
||||
@Nullable
|
||||
Navigatable getNavigatable();
|
||||
|
||||
/**
|
||||
* Returns the file to which the message applies.
|
||||
*
|
||||
* @return the file to which the message applies.
|
||||
*/
|
||||
VirtualFile getVirtualFile();
|
||||
|
||||
/**
|
||||
* Returns the location prefix prepended to message while exporting compilation results to text.
|
||||
*
|
||||
* @return location prefix prepended to message while exporting compilation results to text.
|
||||
*/
|
||||
String getExportTextPrefix();
|
||||
|
||||
/**
|
||||
* Returns the location prefix prepended to message while exporting compilation results to text.
|
||||
*
|
||||
* @return location prefix prepended to message while rendering compilation results in UI.
|
||||
*/
|
||||
String getRenderTextPrefix();
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
/**
|
||||
* A set of constants describing possible message categories.
|
||||
*
|
||||
* @see CompilerMessage#getCategory()
|
||||
* @see CompileContext#addMessage(CompilerMessageCategory, String, String, int, int)
|
||||
*/
|
||||
public enum CompilerMessageCategory {
|
||||
ERROR {
|
||||
public String toString() {
|
||||
return CompilerBundle.message("message.category.error");
|
||||
}
|
||||
public String getPresentableText() {
|
||||
return toString();
|
||||
}
|
||||
},
|
||||
WARNING {
|
||||
public String toString() {
|
||||
return CompilerBundle.message("message.category.warning");
|
||||
}
|
||||
public String getPresentableText() {
|
||||
return toString();
|
||||
}
|
||||
},
|
||||
INFORMATION {
|
||||
public String toString() {
|
||||
return CompilerBundle.message("message.category.information");
|
||||
}
|
||||
public String getPresentableText() {
|
||||
return toString();
|
||||
}
|
||||
},
|
||||
STATISTICS {
|
||||
public String toString() {
|
||||
return CompilerBundle.message("message.category.statistics");
|
||||
}
|
||||
public String getPresentableText() {
|
||||
return toString();
|
||||
}
|
||||
};
|
||||
|
||||
public abstract String getPresentableText();
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import com.intellij.ide.highlighter.ProjectFileType;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.CompilerModuleExtension;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.PathUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A set of utility methods for working with paths
|
||||
*/
|
||||
public class CompilerPaths {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.compiler.CompilerPaths");
|
||||
private static volatile String ourSystemPath;
|
||||
|
||||
/**
|
||||
* Returns a directory
|
||||
* @param project
|
||||
* @param compiler
|
||||
* @return a directory where compiler may generate files. All generated files are not deleted when the application exits
|
||||
*/
|
||||
public static File getGeneratedDataDirectory(Project project, Compiler compiler) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
return new File(getGeneratedDataDirectory(project), compiler.getDescription().replaceAll("\\s+", "_"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param project
|
||||
* @return a root directory where generated files for various compilers are stored
|
||||
*/
|
||||
public static File getGeneratedDataDirectory(Project project) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
return new File(getCompilerSystemDirectory(project), ".generated");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param project
|
||||
* @return a root directory where compiler caches for the given project are stored
|
||||
*/
|
||||
public static File getCacheStoreDirectory(final Project project) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
return new File(getCompilerSystemDirectory(project), ".caches");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param project
|
||||
* @return a directory under IDEA "system" directory where all files related to compiler subsystem are stored (such as compiler caches or generated files)
|
||||
*/
|
||||
public static File getCompilerSystemDirectory(Project project) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
String projectName = getPresentableName(project);
|
||||
return new File(getCompilerSystemDirectory(), projectName + "." + project.getLocationHash());
|
||||
}
|
||||
|
||||
private static String getPresentableName(final Project project) {
|
||||
if (project.isDefault()) {
|
||||
return project.getName();
|
||||
}
|
||||
|
||||
String projectName = FileUtil.toSystemIndependentName(project.getLocation());
|
||||
if (projectName.endsWith("/")) {
|
||||
projectName = projectName.substring(0, projectName.length() - 1);
|
||||
}
|
||||
|
||||
final int lastSlash = projectName.lastIndexOf('/');
|
||||
if (lastSlash >= 0 && lastSlash + 1 < projectName.length()) {
|
||||
projectName = projectName.substring(lastSlash + 1);
|
||||
}
|
||||
|
||||
if (StringUtil.endsWithIgnoreCase(projectName, ProjectFileType.DOT_DEFAULT_EXTENSION)) {
|
||||
projectName = projectName.substring(0, projectName.length() - ProjectFileType.DOT_DEFAULT_EXTENSION.length());
|
||||
}
|
||||
|
||||
projectName = projectName.toLowerCase(Locale.US);
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public static File getCompilerSystemDirectory() {
|
||||
//noinspection HardCodedStringLiteral
|
||||
final String systemPath = ourSystemPath != null? ourSystemPath : (ourSystemPath = PathUtil.getCanonicalPath(PathManager.getSystemPath()));
|
||||
return new File(systemPath, "compiler");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param module
|
||||
* @param forTestClasses true if directory for test sources, false - for sources.
|
||||
* @return a directory to which the sources (or test sources depending on the second partameter) should be compiled.
|
||||
* Null is returned if output directory is not specified or is not valid
|
||||
*/
|
||||
@Nullable
|
||||
public static VirtualFile getModuleOutputDirectory(final Module module, boolean forTestClasses) {
|
||||
final CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module);
|
||||
VirtualFile outPath;
|
||||
if (forTestClasses) {
|
||||
final VirtualFile path = compilerModuleExtension.getCompilerOutputPathForTests();
|
||||
if (path != null) {
|
||||
outPath = path;
|
||||
}
|
||||
else {
|
||||
outPath = compilerModuleExtension.getCompilerOutputPath();
|
||||
}
|
||||
}
|
||||
else {
|
||||
outPath = compilerModuleExtension.getCompilerOutputPath();
|
||||
}
|
||||
if (outPath == null) {
|
||||
return null;
|
||||
}
|
||||
if (!outPath.isValid()) {
|
||||
LOG.info("Requested output path for module " + module.getName() + " is not valid");
|
||||
return null;
|
||||
}
|
||||
return outPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* The same as {@link #getModuleOutputDirectory} but returns String.
|
||||
* The method still returns a non-null value if the output path is specified in Settings but does not exist on disk.
|
||||
*/
|
||||
@Nullable
|
||||
public static String getModuleOutputPath(final Module module, boolean forTestClasses) {
|
||||
final String outPathUrl;
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
final CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
|
||||
if (forTestClasses) {
|
||||
if (application.isDispatchThread()) {
|
||||
final String url = extension.getCompilerOutputUrlForTests();
|
||||
outPathUrl = url != null ? url : extension.getCompilerOutputUrl();
|
||||
}
|
||||
else {
|
||||
outPathUrl = application.runReadAction(new Computable<String>() {
|
||||
public String compute() {
|
||||
final String url = extension.getCompilerOutputUrlForTests();
|
||||
return url != null ? url : extension.getCompilerOutputUrl();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else { // for ordinary classes
|
||||
if (application.isDispatchThread()) {
|
||||
outPathUrl = extension.getCompilerOutputUrl();
|
||||
}
|
||||
else {
|
||||
outPathUrl = application.runReadAction(new Computable<String>() {
|
||||
public String compute() {
|
||||
return extension.getCompilerOutputUrl();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return outPathUrl != null? VirtualFileManager.extractPath(outPathUrl) : null;
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String getGenerationOutputPath(IntermediateOutputCompiler compiler, Module module, final boolean forTestSources) {
|
||||
final String generatedCompilerDirectoryPath = getGeneratedDataDirectory(module.getProject(), compiler).getPath();
|
||||
//noinspection HardCodedStringLiteral
|
||||
final String moduleDir = module.getName().replaceAll("\\s+", "_") + "." + Integer.toHexString(module.getModuleFilePath().hashCode());
|
||||
return generatedCompilerDirectoryPath.replace(File.separatorChar, '/') + "/" + moduleDir + "/" + (forTestSources? "test" : "production");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.intellij.openapi.compiler;
|
||||
|
||||
import com.intellij.util.messages.Topic;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class CompilerTopics {
|
||||
public static final Topic<CompilationStatusListener> COMPILATION_STATUS = new Topic<CompilationStatusListener>("compilation status", CompilationStatusListener.class);
|
||||
|
||||
private CompilerTopics() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.io.IOUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Compiler which copies the compiled files to a different directory.
|
||||
*/
|
||||
public abstract class CopyingCompiler implements PackagingCompiler{
|
||||
public abstract VirtualFile[] getFilesToCopy(CompileContext context);
|
||||
public abstract String getDestinationPath(VirtualFile sourceFile);
|
||||
|
||||
public final void processOutdatedItem(CompileContext context, String url, @Nullable ValidityState state) {
|
||||
if (state != null) {
|
||||
final String destinationPath = ((DestinationFileInfo)state).getDestinationPath();
|
||||
new File(destinationPath).delete();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final ProcessingItem[] getProcessingItems(final CompileContext context) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<ProcessingItem[]>() {
|
||||
public ProcessingItem[] compute() {
|
||||
final VirtualFile[] filesToCopy = getFilesToCopy(context);
|
||||
final ProcessingItem[] items = new ProcessingItem[filesToCopy.length];
|
||||
for (int idx = 0; idx < filesToCopy.length; idx++) {
|
||||
final VirtualFile file = filesToCopy[idx];
|
||||
items[idx] = new CopyItem(file, getDestinationPath(file));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ProcessingItem[] process(CompileContext context, ProcessingItem[] items) {
|
||||
final List<ProcessingItem> successfullyProcessed = new ArrayList<ProcessingItem>(items.length);
|
||||
for (ProcessingItem item : items) {
|
||||
final CopyItem copyItem = (CopyItem)item;
|
||||
final String fromPath = copyItem.getSourcePath();
|
||||
final String toPath = copyItem.getDestinationPath();
|
||||
try {
|
||||
FileUtil.copy(new File(fromPath), new File(toPath));
|
||||
successfullyProcessed.add(copyItem);
|
||||
}
|
||||
catch (IOException e) {
|
||||
context.addMessage(
|
||||
CompilerMessageCategory.ERROR,
|
||||
CompilerBundle.message("error.copying", fromPath, toPath, e.getMessage()),
|
||||
null, -1, -1
|
||||
);
|
||||
}
|
||||
}
|
||||
return successfullyProcessed.toArray(new ProcessingItem[successfullyProcessed.size()]);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getDescription() {
|
||||
return CompilerBundle.message("file.copying.compiler.description");
|
||||
}
|
||||
|
||||
public boolean validateConfiguration(CompileScope scope) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ValidityState createValidityState(DataInput in) throws IOException {
|
||||
return new DestinationFileInfo(IOUtil.readString(in), true);
|
||||
}
|
||||
|
||||
private static class CopyItem implements FileProcessingCompiler.ProcessingItem {
|
||||
private final VirtualFile myFile;
|
||||
private final DestinationFileInfo myInfo;
|
||||
private final String mySourcePath;
|
||||
|
||||
public CopyItem(VirtualFile file, String destinationPath) {
|
||||
myFile = file;
|
||||
mySourcePath = file.getPath().replace('/', File.separatorChar);
|
||||
myInfo = new DestinationFileInfo(destinationPath, new File(destinationPath).exists());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public VirtualFile getFile() {
|
||||
return myFile;
|
||||
}
|
||||
|
||||
public ValidityState getValidityState() {
|
||||
return myInfo;
|
||||
}
|
||||
|
||||
public String getSourcePath() {
|
||||
return mySourcePath;
|
||||
}
|
||||
|
||||
public String getDestinationPath() {
|
||||
return myInfo.getDestinationPath();
|
||||
}
|
||||
}
|
||||
|
||||
private static class DestinationFileInfo implements ValidityState {
|
||||
private final String destinationPath;
|
||||
private final boolean myFileExists;
|
||||
|
||||
public DestinationFileInfo(String destinationPath, boolean fileExists) {
|
||||
this.destinationPath = destinationPath;
|
||||
myFileExists = fileExists;
|
||||
}
|
||||
|
||||
public boolean equalsTo(ValidityState otherState) {
|
||||
if (!(otherState instanceof DestinationFileInfo)) {
|
||||
return false;
|
||||
}
|
||||
DestinationFileInfo destinationFileInfo = (DestinationFileInfo)otherState;
|
||||
return (myFileExists == destinationFileInfo.myFileExists) && (destinationPath.equals(destinationFileInfo.destinationPath));
|
||||
}
|
||||
|
||||
public void save(DataOutput out) throws IOException {
|
||||
IOUtil.writeString(destinationPath, out);
|
||||
}
|
||||
|
||||
public String getDestinationPath() {
|
||||
return destinationPath;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.CompilerModuleExtension;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DummyCompileContext implements CompileContext {
|
||||
protected DummyCompileContext() {
|
||||
}
|
||||
|
||||
private static final DummyCompileContext OUR_INSTANCE = new DummyCompileContext();
|
||||
|
||||
public static DummyCompileContext getInstance() {
|
||||
return OUR_INSTANCE;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addMessage(CompilerMessageCategory category, String message, String url, int lineNum, int columnNum) {
|
||||
}
|
||||
|
||||
|
||||
public void addMessage(CompilerMessageCategory category,
|
||||
String message,
|
||||
@Nullable String url,
|
||||
int lineNum,
|
||||
int columnNum,
|
||||
Navigatable navigatable) {
|
||||
}
|
||||
|
||||
public CompilerMessage[] getMessages(CompilerMessageCategory category) {
|
||||
return CompilerMessage.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public int getMessageCount(CompilerMessageCategory category) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ProgressIndicator getProgressIndicator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public CompileScope getCompileScope() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public CompileScope getProjectCompileScope() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void requestRebuildNextTime(String message) {
|
||||
}
|
||||
|
||||
public Module getModuleByFile(VirtualFile file) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public VirtualFile[] getSourceRoots(Module module) {
|
||||
return VirtualFile.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public VirtualFile[] getAllOutputDirectories() {
|
||||
return VirtualFile.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public VirtualFile getModuleOutputDirectory(final Module module) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<VirtualFile>() {
|
||||
public VirtualFile compute() {
|
||||
return CompilerModuleExtension.getInstance(module).getCompilerOutputPath();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public VirtualFile getModuleOutputDirectoryForTests(Module module) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T> T getUserData(Key<T> key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T> void putUserData(Key<T> key, T value) {
|
||||
}
|
||||
|
||||
public boolean isMake() {
|
||||
return false; // stub implementation
|
||||
}
|
||||
|
||||
public boolean isRebuild() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* A base interface describing shared functionality for various types of file processing compilers.
|
||||
* Actual compiler implementation should implement one of these:
|
||||
* {@link ClassInstrumentingCompiler}, {@link ClassPostProcessingCompiler},
|
||||
* {@link SourceInstrumentingCompiler}.
|
||||
*/
|
||||
public interface FileProcessingCompiler extends Compiler, ValidityStateFactory {
|
||||
/**
|
||||
* Describes a processing unit for this compiler - a virtual file with associated state.
|
||||
*/
|
||||
interface ProcessingItem {
|
||||
/**
|
||||
* A utility constant used to return empty arrays of ProcessingItem objects
|
||||
*/
|
||||
ProcessingItem[] EMPTY_ARRAY = new ProcessingItem[0];
|
||||
|
||||
/**
|
||||
* Returns the file to be processed.
|
||||
*
|
||||
* @return a file to be processed; cannot be null
|
||||
*/
|
||||
@NotNull
|
||||
VirtualFile getFile();
|
||||
|
||||
/**
|
||||
* @return an object describing dependencies of the instrumented file (can be null).
|
||||
* For example, if the file "A" should be processed whenever file "B" or file "C" is changed, the ValidityState object can
|
||||
* be composed of a pair [timestamp("B"), timestamp("C")]. Thus, whenever a timestamp of any of these files is changed,
|
||||
* the current ValidityState won't be equal to the stored ValidityState and the item will be picked up by the make for recompilation.
|
||||
*/
|
||||
@Nullable
|
||||
ValidityState getValidityState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the items which will be processed in the current compile operation.
|
||||
* The method is called before the call to {@link #process} method
|
||||
*
|
||||
* @param context the current compilation context.
|
||||
* @return a non-null array of all items that potentially can be processed at the moment of method call. Even if
|
||||
* the file is not changed, it should be returned if it _can_ be processed by the compiler implementing the interface.
|
||||
*/
|
||||
@NotNull
|
||||
ProcessingItem[] getProcessingItems(CompileContext context);
|
||||
|
||||
/**
|
||||
* Compiles the specified items.
|
||||
*
|
||||
* @param context the current compilation context.
|
||||
* @param items items to be processed, selected by make subsystem. The items are selected from the list returned by the
|
||||
* {@link #getProcessingItems} method.
|
||||
* @return successfully processed items.
|
||||
*/
|
||||
ProcessingItem[] process(CompileContext context, ProcessingItem[] items);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
/**
|
||||
* A base interface for all compilers that generate new files. The generated files may be processed by other compilers.
|
||||
* Actual implementation should implement one of its subinterfaces. Currently only {@link SourceGeneratingCompiler} is available.
|
||||
*/
|
||||
public interface GeneratingCompiler extends Compiler, ValidityStateFactory, IntermediateOutputCompiler {
|
||||
/**
|
||||
* Represents a single item generated by the compiler.
|
||||
*/
|
||||
interface GenerationItem {
|
||||
/**
|
||||
* Returns the path of the generated file.
|
||||
*
|
||||
* @return path of a generated file, relative to output directory.
|
||||
*/
|
||||
String getPath();
|
||||
|
||||
/**
|
||||
* Returns the object describing dependencies of the generated file.
|
||||
*
|
||||
* @return a serializable object describing dependencies of the generated file.
|
||||
*/
|
||||
ValidityState getValidityState();
|
||||
|
||||
/**
|
||||
* Returns the module to which the generated item belongs. This affects the sequence
|
||||
* of compiling the generated files.
|
||||
*
|
||||
* @return the module to which the generated item belongs.
|
||||
*/
|
||||
Module getModule();
|
||||
|
||||
/**
|
||||
* @return true if the generated item is supposed to be located in test sources, false otherwise
|
||||
*/
|
||||
boolean isTestSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of all the files this compiler can generate.
|
||||
*
|
||||
* @param context the current compile context.
|
||||
* @return items describing all the files this compiler can generate.
|
||||
*/
|
||||
GenerationItem[] getGenerationItems(CompileContext context);
|
||||
|
||||
/**
|
||||
* Invokes the generation process.
|
||||
*
|
||||
* @param context the current compile context.
|
||||
* @param items what items to generate.
|
||||
* @param outputRootDirectory the root directory under which the items are generated (the paths
|
||||
* in {@link GenerationItem#getPath()} are relative to that directory).
|
||||
* All files generated by the compiler must be placed in that directory or
|
||||
* its subdirectories, otherwise they will not be compiled properly on
|
||||
* subsequent build steps.
|
||||
* @return successfully generated items
|
||||
*/
|
||||
GenerationItem[] generate(CompileContext context, GenerationItem[] items, VirtualFile outputRootDirectory);
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.intellij.openapi.compiler;
|
||||
|
||||
/**
|
||||
* A tag interface denoting that compiler's output should go into 'intermediate' directory
|
||||
* and can be used as input to another compiler
|
||||
*/
|
||||
public interface IntermediateOutputCompiler extends Compiler{
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
/**
|
||||
* This compiler is called right before the java sources compiler.
|
||||
*/
|
||||
public interface JavaSourceTransformingCompiler extends Compiler {
|
||||
|
||||
/**
|
||||
* Checks if the file can be transformed by the compiler.
|
||||
*
|
||||
* @param file an original file that is about to be compiled with java compiler
|
||||
* @return true if compiler would like to transform the file, false otherwise.
|
||||
* If true is returned, a copy of ariginal file will be made and {@link #transform(CompileContext,com.intellij.openapi.vfs.VirtualFile,com.intellij.openapi.vfs.VirtualFile)}
|
||||
* method will be called on it. If transformation succeeded, the transformed copy will be passed to java compiler instead of original file.
|
||||
*/
|
||||
boolean isTransformable(VirtualFile file);
|
||||
|
||||
/**
|
||||
* Transforms the specified file.
|
||||
*
|
||||
* @param context the current compile context.
|
||||
* @param file a copy of original file to be transformed
|
||||
* @param originalFile an original file. Since the copy that is supposed to be modified is located outside the project, it is not possible to use PSI for analysis.
|
||||
* So the original file is provided. Note that it is passed for reference purposes only. It MUST NOT be transformed or changed in any way.
|
||||
* For example, it is possible to obtain a PsiFile for the original file:<br><br>
|
||||
* <code>PsiJavaFile originalPsiJavaFile = (PsiJavaFile)PsiManager.getInstance(project).findFile(originalFile)</code>;<br><br>
|
||||
* The obtained originalPsiJavaFile can be analysed, searched etc. For transforming the file by the means of PSI, there should be created a copy of the originalPsiJavaFile:<br><br>
|
||||
* <code>PsiJavaFile psiFileCopy = (PsiJavaFile)originalPsiJavaFile.copy();</code><br><br>
|
||||
* The psiFileCopy can then be transformed, and its text saved to the first "file" argument:<br><br>
|
||||
* <code>String text = psiFileCopy.getText();</code><br><br>
|
||||
* <p/>
|
||||
* <b>Note that transforming files by the means of PSI may considerably slow down the overall make performance.</b>
|
||||
* @return true if transform succeeded, false otherwise.
|
||||
*/
|
||||
boolean transform(CompileContext context, VirtualFile file, VirtualFile originalFile);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface OutputToSourceMapping {
|
||||
@Nullable
|
||||
String getSourcePath(String outputPath);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* A tag interface indicating that the compiler will package the compiled Java classes.
|
||||
* This affects the order of compiler calls.
|
||||
* The sequence in which compilers are called:
|
||||
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
|
||||
*/
|
||||
public interface PackagingCompiler extends FileProcessingCompiler{
|
||||
/**
|
||||
* Called when the compiler detects that an item in the output directory is outdated
|
||||
* and will be recompiled. Note that this method will be called before, and independently from,
|
||||
* subsequent calls to {@link #process}.
|
||||
*
|
||||
* @param context the current compile context.
|
||||
* @param url the URL of a file in the output directory which will be recompiled.
|
||||
* @param state the validity state of the file specified by <code>url</code>.
|
||||
*/
|
||||
void processOutdatedItem(CompileContext context, String url, @Nullable ValidityState state);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
/**
|
||||
* A tag interface indicating that the compiler will generate Java sources.
|
||||
* This affects the order of compiler calls.
|
||||
* The sequence in which compilers are called:
|
||||
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
|
||||
*/
|
||||
public interface SourceGeneratingCompiler extends GeneratingCompiler {
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
/**
|
||||
* A tag interface indicating that the compiler will instrument java sources.
|
||||
* This affects the order of compiler calls:
|
||||
* The sequence in which compilers are called:
|
||||
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> Validator
|
||||
*/
|
||||
public interface SourceInstrumentingCompiler extends FileProcessingCompiler {
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
/**
|
||||
* A tag interface indicating that the compiler will instrument java sources.
|
||||
* This affects the order of compiler calls:
|
||||
* The sequence in which compilers are called:
|
||||
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> Validator
|
||||
*/
|
||||
public interface SourceProcessingCompiler extends FileProcessingCompiler, IntermediateOutputCompiler {
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A simple implementation of ValidityState that is enough for most cases.
|
||||
* The file is considered modified if its timestamp is changed.
|
||||
*/
|
||||
public final class TimestampValidityState implements ValidityState {
|
||||
private final long myTimestamp;
|
||||
|
||||
/**
|
||||
* Creates a validity state with the specified timestamp.
|
||||
*
|
||||
* @param timestamp the timestamp for the validity state.
|
||||
*/
|
||||
public TimestampValidityState(long timestamp) {
|
||||
myTimestamp = timestamp;
|
||||
}
|
||||
|
||||
public boolean equalsTo(ValidityState otherState) {
|
||||
if (!(otherState instanceof TimestampValidityState)) {
|
||||
return false;
|
||||
}
|
||||
return myTimestamp == ((TimestampValidityState)otherState).myTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the validity state to the specified stream.
|
||||
*
|
||||
* @param out
|
||||
* @throws IOException if the stream write fails.
|
||||
*/
|
||||
public void save(DataOutput out) throws IOException {
|
||||
out.writeLong(myTimestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the validity state from the specified stream.
|
||||
*
|
||||
* @param is the stream to load the validity state from.
|
||||
* @throws IOException if the stream read fails.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public static TimestampValidityState load(DataInput is) throws IOException {
|
||||
return new TimestampValidityState(is.readLong());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* A tag interface indicating that the compiler will translate one type of files into another (e.g. .java -> .class).
|
||||
* This affects the order of compiler calls.
|
||||
* The sequence in which compilers are called:
|
||||
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
|
||||
*/
|
||||
public interface TranslatingCompiler extends Compiler {
|
||||
|
||||
/**
|
||||
* Defines a single file compiled by the compiler.
|
||||
*/
|
||||
interface OutputItem {
|
||||
/**
|
||||
* Returns the path to the output file.
|
||||
*
|
||||
* @return absolute path of the output file ('/' slashes used)
|
||||
*/
|
||||
String getOutputPath();
|
||||
|
||||
/**
|
||||
* Returns the path to the source file.
|
||||
*
|
||||
* @return the source file to be compiled
|
||||
*/
|
||||
VirtualFile getSourceFile();
|
||||
}
|
||||
|
||||
interface OutputSink {
|
||||
/**
|
||||
*
|
||||
* @param outputRoot output directory
|
||||
* @param items output items that were successfully compiled.
|
||||
* @param filesToRecompile virtual files that should be considered as "modified" next time compilation is invoked.
|
||||
*/
|
||||
void add(String outputRoot, Collection<OutputItem> items, VirtualFile[] filesToRecompile);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the compiler can compile the specified file.
|
||||
*
|
||||
* @param file the file to check.
|
||||
* @param context the context for the current compile operation.
|
||||
* @return true if can compile the file, false otherwise. If the method returns false, <code>file</code>
|
||||
* will not be included in the list of files passed to {@link #compile(CompileContext,com.intellij.openapi.vfs.VirtualFile[], com.intellij.openapi.compiler.TranslatingCompiler.OutputSink)}.
|
||||
*/
|
||||
boolean isCompilableFile(VirtualFile file, CompileContext context);
|
||||
|
||||
/**
|
||||
* Compiles the specified files.
|
||||
*
|
||||
* @param context the context for the current compile operation.
|
||||
* @param files the source files to compile.
|
||||
* @param sink storage that accepts compiler output results
|
||||
*/
|
||||
void compile(CompileContext context, VirtualFile[] files, OutputSink sink);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
/**
|
||||
* A tag interface indicating that the compiler will perform any validation on the files in given compile scope.
|
||||
* Error/Warning messages should be added to the CompileContext object.
|
||||
* This affects the order of compiler calls.
|
||||
* The sequence in which compilers are called:
|
||||
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
|
||||
*/
|
||||
public interface Validator extends FileProcessingCompiler {
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Instances of this class are associated with the files processed by compilers.
|
||||
* A file is considered modified if currently associated ValidityState differs from the previously stored ValiditySate for this file.
|
||||
*/
|
||||
public interface ValidityState {
|
||||
/**
|
||||
* Compares this validity state to other ValidityState.
|
||||
*
|
||||
* @param otherState the state to compare with.
|
||||
* @return true if states can be considered equal, false otherwise.
|
||||
*/
|
||||
boolean equalsTo(ValidityState otherState);
|
||||
/**
|
||||
* Invoked by make subsystem in order to store the state.
|
||||
*
|
||||
* @param out the output to which the state should be stored.
|
||||
* @throws IOException if the save operation failed because of an I/O error.
|
||||
* @see TimestampValidityState#load(java.io.DataInputStream)
|
||||
*/
|
||||
void save(DataOutput out) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A factory for creating {@link ValidityState} objects.
|
||||
*/
|
||||
public interface ValidityStateFactory {
|
||||
/**
|
||||
* Used for deserialization of ValidityState objects from compiler internal caches.
|
||||
* @see ValidityState
|
||||
* @param in
|
||||
*/
|
||||
ValidityState createValidityState(DataInput in) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class BuildConfiguration {
|
||||
|
||||
@NonNls
|
||||
public abstract String getArchiveExtension();
|
||||
|
||||
@Nullable
|
||||
public abstract String getJarPath();
|
||||
|
||||
@Nullable
|
||||
public abstract String getExplodedPath();
|
||||
|
||||
public abstract boolean isJarEnabled();
|
||||
|
||||
public abstract boolean isExplodedEnabled();
|
||||
|
||||
@Deprecated
|
||||
public boolean willBuildExploded() {
|
||||
return isExplodedEnabled() && getExplodedPath() != null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarOutputStream;
|
||||
|
||||
public interface BuildInstruction {
|
||||
String getOutputRelativePath();
|
||||
Module getModule();
|
||||
|
||||
@Deprecated
|
||||
void addFilesToJar(@NotNull CompileContext context,
|
||||
@NotNull File jarFile,
|
||||
@NotNull JarOutputStream outputStream,
|
||||
BuildRecipe dependencies,
|
||||
@Nullable Set<String> writtenRelativePaths,
|
||||
@Nullable FileFilter fileFilter) throws IOException;
|
||||
|
||||
boolean accept(BuildInstructionVisitor visitor) throws Exception;
|
||||
|
||||
boolean isExternalDependencyInstruction();
|
||||
File findFileByRelativePath(String relativePath);
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make;
|
||||
|
||||
|
||||
public abstract class BuildInstructionVisitor {
|
||||
public boolean visitInstruction(BuildInstruction instruction) throws Exception {
|
||||
return true;
|
||||
}
|
||||
public boolean visitFileCopyInstruction(FileCopyInstruction instruction) throws Exception {
|
||||
return visitInstruction(instruction);
|
||||
}
|
||||
public boolean visitJarAndCopyBuildInstruction(JarAndCopyBuildInstruction instruction) throws Exception {
|
||||
return visitFileCopyInstruction(instruction);
|
||||
}
|
||||
public boolean visitCompoundBuildInstruction(CompoundBuildInstruction instruction) throws Exception {
|
||||
return visitInstruction(instruction);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class BuildParticipant {
|
||||
public static final BuildParticipant[] EMPTY_ARRAY = new BuildParticipant[0];
|
||||
|
||||
public void afterJarCreated(File jarFile, CompileContext context) throws Exception {
|
||||
}
|
||||
|
||||
public void afterExplodedCreated(File outputDir, CompileContext context) throws Exception {
|
||||
}
|
||||
|
||||
public void buildStarted(CompileContext context) {
|
||||
}
|
||||
|
||||
public void buildFinished(CompileContext context) throws Exception {
|
||||
}
|
||||
|
||||
public abstract BuildRecipe getBuildInstructions(final CompileContext context);
|
||||
|
||||
public abstract BuildConfiguration getBuildConfiguration();
|
||||
|
||||
@Nullable
|
||||
public String getOrCreateTemporaryDirForExploded() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract Module getModule();
|
||||
|
||||
public boolean willBuildExploded() {
|
||||
BuildConfiguration configuration = getBuildConfiguration();
|
||||
return configuration.isExplodedEnabled() && configuration.getExplodedPath() != null;
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.deployment.DeploymentUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.descriptors.ConfigFile;
|
||||
import com.intellij.util.descriptors.CustomConfigFile;
|
||||
import com.intellij.util.descriptors.ConfigFileMetaData;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class BuildParticipantBase extends BuildParticipant {
|
||||
private final Module myModule;
|
||||
|
||||
protected BuildParticipantBase(final Module module) {
|
||||
myModule = module;
|
||||
}
|
||||
|
||||
public Module getModule() {
|
||||
return myModule;
|
||||
}
|
||||
|
||||
public void buildStarted(final CompileContext context) {
|
||||
new ReadAction() {
|
||||
protected void run(final Result result) {
|
||||
ConfigFile[] descriptors = getDeploymentDescriptors();
|
||||
for (ConfigFile descriptor : descriptors) {
|
||||
DeploymentUtil.getInstance().checkConfigFile(descriptor, context, myModule);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
protected void registerDescriptorCopyingInstructions(final BuildRecipe instructions, final CompileContext context) {
|
||||
final ConfigFile[] deploymentDescriptors = getDeploymentDescriptors();
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
for (ConfigFile descriptor : deploymentDescriptors) {
|
||||
VirtualFile virtualFile = descriptor.getVirtualFile();
|
||||
if (virtualFile != null) {
|
||||
ConfigFileMetaData metaData = descriptor.getMetaData();
|
||||
final File file = VfsUtil.virtualToIoFile(virtualFile);
|
||||
final String fileName;
|
||||
if (metaData.isFileNameFixed()) {
|
||||
fileName = metaData.getFileName();
|
||||
}
|
||||
else {
|
||||
fileName = virtualFile.getName();
|
||||
}
|
||||
instructions.addFileCopyInstruction(file, false, myModule, metaData.getDirectoryPath() + "/" + fileName, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
final CustomConfigFile[] customDescriptors = getCustomDescriptors();
|
||||
for (CustomConfigFile descriptor : customDescriptors) {
|
||||
final String url = descriptor.getUrl();
|
||||
final VirtualFile virtualFile = VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
if (virtualFile != null) {
|
||||
File file = VfsUtil.virtualToIoFile(virtualFile);
|
||||
instructions.addFileCopyInstruction(file, false, myModule, descriptor.getOutputDirectoryPath() + "/" + virtualFile.getName(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected CustomConfigFile[] getCustomDescriptors() {
|
||||
return CustomConfigFile.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
protected abstract ConfigFile[] getDeploymentDescriptors();
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.module.Module;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class BuildParticipantProvider<P extends BuildParticipant> {
|
||||
public static final ExtensionPointName<BuildParticipantProvider> EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.compiler.buildParticipantProvider");
|
||||
|
||||
|
||||
public abstract Collection<P> getParticipants(Module module);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public interface BuildRecipe {
|
||||
void addInstruction(BuildInstruction instruction);
|
||||
|
||||
boolean visitInstructions(BuildInstructionVisitor visitor, boolean reverseOrder);
|
||||
boolean visitInstructionsWithExceptions(BuildInstructionVisitor visitor, boolean reverseOrder) throws Exception;
|
||||
|
||||
void addAll(@NotNull BuildRecipe buildRecipe);
|
||||
void addFileCopyInstruction(@NotNull File file,
|
||||
boolean isDirectory,
|
||||
@NotNull Module module,
|
||||
String outputRelativePath,
|
||||
@Nullable PackagingFileFilter fileFilter);
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make;
|
||||
|
||||
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
|
||||
public interface CompoundBuildInstruction extends BuildInstruction {
|
||||
|
||||
BuildConfiguration getBuildProperties();
|
||||
|
||||
BuildRecipe getChildInstructions(CompileContext context);
|
||||
|
||||
BuildParticipant getBuildParticipant();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public interface FileCopyInstruction extends BuildInstruction {
|
||||
File getFile();
|
||||
|
||||
boolean isDirectory();
|
||||
|
||||
@Nullable
|
||||
PackagingFileFilter getFileFilter();
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface JarAndCopyBuildInstruction extends FileCopyInstruction {
|
||||
@Deprecated
|
||||
void makeJar(@NotNull CompileContext context,
|
||||
@NotNull File jarFile,
|
||||
@Nullable FileFilter fileFilter) throws IOException;
|
||||
File getJarFile();
|
||||
|
||||
@Deprecated
|
||||
void deleteTemporaryJars();
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.jar.Attributes;
|
||||
|
||||
public class ManifestBuilder {
|
||||
@NonNls private static final String NAME = "Created-By";
|
||||
private static final Attributes.Name CREATED_BY = new Attributes.Name(NAME);
|
||||
|
||||
private ManifestBuilder() {
|
||||
}
|
||||
|
||||
public static void setGlobalAttributes(Attributes mainAttributes) {
|
||||
setVersionAttribute(mainAttributes);
|
||||
setIfNone(mainAttributes, CREATED_BY, ApplicationNamesInfo.getInstance().getFullProductName());
|
||||
}
|
||||
|
||||
public static void setVersionAttribute(Attributes mainAttributes) {
|
||||
setIfNone(mainAttributes, Attributes.Name.MANIFEST_VERSION, "1.0");
|
||||
}
|
||||
|
||||
private static void setIfNone(Attributes mainAttributes, Attributes.Name attrName, String value) {
|
||||
if (mainAttributes.getValue(attrName) == null) {
|
||||
mainAttributes.put(attrName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.make;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class PackagingFileFilter {
|
||||
|
||||
public abstract boolean accept(@NotNull VirtualFile virtualFile, @NotNull CompileContext context);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<!--
|
||||
~ Copyright 2000-2007 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.
|
||||
-->
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html><body bgcolor="white">
|
||||
Provides interfaces for extending the build process.
|
||||
</body></html>
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* created at Jan 3, 2002
|
||||
* @author Jeka
|
||||
*/
|
||||
package com.intellij.openapi.compiler.options;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointer;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ExcludeEntryDescription implements Disposable {
|
||||
|
||||
private final String myUrl;
|
||||
private final boolean myIsFile;
|
||||
private boolean myIncludeSubdirectories;
|
||||
private VirtualFilePointer myFilePointer;
|
||||
|
||||
public ExcludeEntryDescription(String url, boolean includeSubdirectories, boolean isFile, Disposable parent) {
|
||||
myUrl = url;
|
||||
myFilePointer = VirtualFilePointerManager.getInstance().create(url, parent, null);
|
||||
myIncludeSubdirectories = includeSubdirectories;
|
||||
myIsFile = isFile;
|
||||
}
|
||||
|
||||
public ExcludeEntryDescription(VirtualFile virtualFile, boolean includeSubdirectories, boolean isFile, Disposable parent) {
|
||||
this(virtualFile.getUrl(), includeSubdirectories, isFile, parent);
|
||||
}
|
||||
|
||||
public ExcludeEntryDescription copy(Disposable parent) {
|
||||
return new ExcludeEntryDescription(getUrl(), myIncludeSubdirectories, myIsFile,parent);
|
||||
}
|
||||
|
||||
public boolean isFile() {
|
||||
return myIsFile;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return myFilePointer.getUrl();
|
||||
}
|
||||
|
||||
public String getPresentableUrl() {
|
||||
return myFilePointer.getPresentableUrl();
|
||||
}
|
||||
|
||||
public boolean isIncludeSubdirectories() {
|
||||
return myIncludeSubdirectories;
|
||||
}
|
||||
|
||||
public void setIncludeSubdirectories(boolean includeSubdirectories) {
|
||||
myIncludeSubdirectories = includeSubdirectories;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public VirtualFile getVirtualFile() {
|
||||
return myFilePointer.getFile();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return myFilePointer.isValid();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof ExcludeEntryDescription)) {
|
||||
return false;
|
||||
}
|
||||
ExcludeEntryDescription entryDescription = (ExcludeEntryDescription)obj;
|
||||
if(entryDescription.myIsFile != myIsFile) {
|
||||
return false;
|
||||
}
|
||||
if(entryDescription.myIncludeSubdirectories != myIncludeSubdirectories) {
|
||||
return false;
|
||||
}
|
||||
return Comparing.equal(entryDescription.getUrl(), getUrl());
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = (myIsFile ? 1 : 0);
|
||||
result = 31 * result + (myIncludeSubdirectories ? 1 : 0);
|
||||
result = 31 * result + getUrl().hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
}
|
||||
}
|
||||
+356
@@ -0,0 +1,356 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.options;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.options.UnnamedConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.PanelWithButtons;
|
||||
import com.intellij.ui.RightAlignedLabelUI;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.util.ui.Table;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ExcludedEntriesConfigurable implements UnnamedConfigurable {
|
||||
private final Project myProject;
|
||||
private final ArrayList<ExcludeEntryDescription> myExcludeEntryDescriptions = new ArrayList<ExcludeEntryDescription>();
|
||||
private final FileChooserDescriptor myDescriptor;
|
||||
private final ExcludedEntriesConfiguration myConfiguration;
|
||||
private ExcludedEntriesConfigurable.ExcludedEntriesPanel myExcludedEntriesPanel;
|
||||
|
||||
public ExcludedEntriesConfigurable(Project project, FileChooserDescriptor descriptor, final ExcludedEntriesConfiguration configuration) {
|
||||
myDescriptor = descriptor;
|
||||
myConfiguration = configuration;
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
ExcludeEntryDescription[] descriptions = myConfiguration.getExcludeEntryDescriptions();
|
||||
disposeMyDescriptions();
|
||||
for (ExcludeEntryDescription description : descriptions) {
|
||||
myExcludeEntryDescriptions.add(description.copy(myProject));
|
||||
}
|
||||
((AbstractTableModel)myExcludedEntriesPanel.myExcludedTable.getModel()).fireTableDataChanged();
|
||||
}
|
||||
|
||||
private void disposeMyDescriptions() {
|
||||
for (ExcludeEntryDescription description : myExcludeEntryDescriptions) {
|
||||
Disposer.dispose(description);
|
||||
}
|
||||
myExcludeEntryDescriptions.clear();
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
myConfiguration.removeAllExcludeEntryDescriptions();
|
||||
for (ExcludeEntryDescription description : myExcludeEntryDescriptions) {
|
||||
myConfiguration.addExcludeEntryDescription(description);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
ExcludeEntryDescription[] excludeEntryDescriptions = myConfiguration.getExcludeEntryDescriptions();
|
||||
if(excludeEntryDescriptions.length != myExcludeEntryDescriptions.size()) {
|
||||
return true;
|
||||
}
|
||||
for(int i = 0; i < excludeEntryDescriptions.length; i++) {
|
||||
ExcludeEntryDescription description = excludeEntryDescriptions[i];
|
||||
if(!Comparing.equal(description, myExcludeEntryDescriptions.get(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public JComponent createComponent() {
|
||||
if (myExcludedEntriesPanel == null) {
|
||||
myExcludedEntriesPanel = new ExcludedEntriesPanel();
|
||||
}
|
||||
return myExcludedEntriesPanel;
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
myExcludedEntriesPanel = null;
|
||||
}
|
||||
|
||||
private class ExcludedEntriesPanel extends PanelWithButtons {
|
||||
private JButton myRemoveButton;
|
||||
private Table myExcludedTable;
|
||||
|
||||
public ExcludedEntriesPanel() {
|
||||
initPanel();
|
||||
}
|
||||
|
||||
protected String getLabelText(){
|
||||
return null;
|
||||
}
|
||||
|
||||
protected JButton[] createButtons(){
|
||||
final JButton addButton = new JButton(IdeBundle.message("button.add"));
|
||||
addButton.addActionListener(
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e){
|
||||
addPath(myDescriptor);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
myRemoveButton = new JButton(IdeBundle.message("button.remove"));
|
||||
myRemoveButton.addActionListener(
|
||||
new ActionListener(){
|
||||
public void actionPerformed(ActionEvent e){
|
||||
removePaths();
|
||||
}
|
||||
}
|
||||
);
|
||||
myRemoveButton.setEnabled(false);
|
||||
myRemoveButton.getModel().addChangeListener(new ChangeListener() {
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
if (myExcludedTable.getSelectedRow() == -1) {
|
||||
myRemoveButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return new JButton[]{addButton, myRemoveButton};
|
||||
}
|
||||
|
||||
private void addPath(FileChooserDescriptor descriptor) {
|
||||
int selected = myExcludedTable.getSelectedRow() + 1;
|
||||
if(selected < 0) {
|
||||
selected = myExcludeEntryDescriptions.size();
|
||||
}
|
||||
int savedSelected = selected;
|
||||
VirtualFile[] chosen = FileChooser.chooseFiles(myProject, descriptor);
|
||||
for (final VirtualFile chosenFile : chosen) {
|
||||
if (isFileExcluded(chosenFile)) {
|
||||
continue;
|
||||
}
|
||||
ExcludeEntryDescription description;
|
||||
if (chosenFile.isDirectory()) {
|
||||
description = new ExcludeEntryDescription(chosenFile, true, false, myProject);
|
||||
}
|
||||
else {
|
||||
description = new ExcludeEntryDescription(chosenFile, false, true, myProject);
|
||||
}
|
||||
myExcludeEntryDescriptions.add(selected, description);
|
||||
selected++;
|
||||
}
|
||||
if (selected > savedSelected) { // actually added something
|
||||
AbstractTableModel model = (AbstractTableModel)myExcludedTable.getModel();
|
||||
model.fireTableRowsInserted(savedSelected, selected-1);
|
||||
myExcludedTable.setRowSelectionInterval(savedSelected, selected-1);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isFileExcluded(VirtualFile file) {
|
||||
for (final ExcludeEntryDescription description : myExcludeEntryDescriptions) {
|
||||
final VirtualFile descriptionFile = description.getVirtualFile();
|
||||
if (descriptionFile == null) {
|
||||
continue;
|
||||
}
|
||||
if (file.equals(descriptionFile)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void removePaths() {
|
||||
int[] selected = myExcludedTable.getSelectedRows();
|
||||
if(selected == null || selected.length <= 0) {
|
||||
return;
|
||||
}
|
||||
if(myExcludedTable.isEditing()) {
|
||||
TableCellEditor editor = myExcludedTable.getCellEditor();
|
||||
if (editor != null) {
|
||||
editor.stopCellEditing();
|
||||
}
|
||||
}
|
||||
AbstractTableModel model = (AbstractTableModel)myExcludedTable.getModel();
|
||||
Arrays.sort(selected);
|
||||
int indexToSelect = selected[selected.length - 1];
|
||||
int removedCount = 0;
|
||||
for (int indexToRemove : selected) {
|
||||
final int row = indexToRemove - removedCount;
|
||||
ExcludeEntryDescription description = myExcludeEntryDescriptions.get(row);
|
||||
Disposer.dispose(description);
|
||||
myExcludeEntryDescriptions.remove(row);
|
||||
model.fireTableRowsDeleted(row, row);
|
||||
removedCount += 1;
|
||||
}
|
||||
if(indexToSelect >= myExcludeEntryDescriptions.size()) {
|
||||
indexToSelect = myExcludeEntryDescriptions.size() - 1;
|
||||
}
|
||||
if(indexToSelect >= 0) {
|
||||
myExcludedTable.setRowSelectionInterval(indexToSelect, indexToSelect);
|
||||
}
|
||||
myExcludedTable.requestFocus();
|
||||
}
|
||||
|
||||
protected JComponent createMainComponent(){
|
||||
final String[] names = {
|
||||
CompilerBundle.message("exclude.from.compile.table.path.column.name"),
|
||||
CompilerBundle.message("exclude.from.compile.table.recursively.column.name")
|
||||
};
|
||||
// Create a model of the data.
|
||||
TableModel dataModel = new AbstractTableModel() {
|
||||
public int getColumnCount() {
|
||||
return names.length;
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return myExcludeEntryDescriptions.size();
|
||||
}
|
||||
|
||||
public Object getValueAt(int row, int col) {
|
||||
ExcludeEntryDescription description = myExcludeEntryDescriptions.get(row);
|
||||
if(col == 0) {
|
||||
return description;
|
||||
}
|
||||
if(col == 1) {
|
||||
if(!description.isFile()) {
|
||||
return description.isIncludeSubdirectories() ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getColumnName(int column) {
|
||||
return names[column];
|
||||
}
|
||||
|
||||
public Class getColumnClass(int c) {
|
||||
if(c == 0) {
|
||||
return Object.class;
|
||||
}
|
||||
if(c == 1) {
|
||||
return Boolean.class;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isCellEditable(int row, int col) {
|
||||
if(col == 1) {
|
||||
ExcludeEntryDescription description = myExcludeEntryDescriptions.get(row);
|
||||
return !description.isFile();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setValueAt(Object aValue, int row, int col) {
|
||||
ExcludeEntryDescription description = myExcludeEntryDescriptions.get(row);
|
||||
description.setIncludeSubdirectories(aValue.equals(Boolean.TRUE));
|
||||
}
|
||||
};
|
||||
|
||||
myExcludedTable = new Table(dataModel);
|
||||
myExcludedTable.setPreferredScrollableViewportSize(new Dimension(300, myExcludedTable.getRowHeight() * 6));
|
||||
myExcludedTable.setDefaultRenderer(Boolean.class, new BooleanRenderer());
|
||||
myExcludedTable.setDefaultRenderer(Object.class, new MyObjectRenderer());
|
||||
myExcludedTable.getColumn(names[0]).setPreferredWidth(350);
|
||||
final int cbWidth = 15 + myExcludedTable.getFontMetrics(myExcludedTable.getFont()).stringWidth(names[1]);
|
||||
final TableColumn cbColumn = myExcludedTable.getColumn(names[1]);
|
||||
cbColumn.setPreferredWidth(cbWidth);
|
||||
cbColumn.setMaxWidth(cbWidth);
|
||||
myExcludedTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
myExcludedTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
myRemoveButton.setEnabled(myExcludedTable.getSelectedRow() >= 0);
|
||||
}
|
||||
});
|
||||
TableCellEditor editor = myExcludedTable.getDefaultEditor(String.class);
|
||||
if(editor instanceof DefaultCellEditor) {
|
||||
((DefaultCellEditor)editor).setClickCountToStart(1);
|
||||
}
|
||||
|
||||
return ScrollPaneFactory.createScrollPane(myExcludedTable);
|
||||
}
|
||||
}
|
||||
|
||||
private static class BooleanRenderer extends JCheckBox implements TableCellRenderer {
|
||||
private final JPanel myPanel = new JPanel();
|
||||
|
||||
public BooleanRenderer() {
|
||||
setHorizontalAlignment(CENTER);
|
||||
}
|
||||
|
||||
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||
boolean isSelected, boolean hasFocus,
|
||||
int row, int column) {
|
||||
if(value == null) {
|
||||
if(isSelected) {
|
||||
myPanel.setBackground(table.getSelectionBackground());
|
||||
}
|
||||
else {
|
||||
myPanel.setBackground(table.getBackground());
|
||||
}
|
||||
return myPanel;
|
||||
}
|
||||
if(isSelected) {
|
||||
setForeground(table.getSelectionForeground());
|
||||
super.setBackground(table.getSelectionBackground());
|
||||
}
|
||||
else {
|
||||
setForeground(table.getForeground());
|
||||
setBackground(table.getBackground());
|
||||
}
|
||||
setSelected(((Boolean)value).booleanValue());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyObjectRenderer extends DefaultTableCellRenderer {
|
||||
public MyObjectRenderer() {
|
||||
setUI(new RightAlignedLabelUI());
|
||||
}
|
||||
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
if (value instanceof ExcludeEntryDescription) {
|
||||
ExcludeEntryDescription description = (ExcludeEntryDescription)value;
|
||||
setText(description.getPresentableUrl());
|
||||
setForeground(description.isValid()? table.getForeground() : Color.RED);
|
||||
}
|
||||
|
||||
if (!isSelected) {
|
||||
setBackground(table.getBackground());
|
||||
}
|
||||
return component;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.options;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ExcludedEntriesConfiguration implements PersistentStateComponent<ExcludedEntriesConfiguration>, JDOMExternalizable, Disposable {
|
||||
@NonNls private static final String FILE = "file";
|
||||
@NonNls private static final String DIRECTORY = "directory";
|
||||
@NonNls private static final String URL = "url";
|
||||
@NonNls private static final String INCLUDE_SUBDIRECTORIES = "includeSubdirectories";
|
||||
private final Collection<ExcludeEntryDescription> myExcludeEntryDescriptions = new LinkedHashSet<ExcludeEntryDescription>();
|
||||
private ExcludeEntryDescription[] myCachedDescriptions = null;
|
||||
|
||||
public synchronized ExcludeEntryDescription[] getExcludeEntryDescriptions() {
|
||||
if (myCachedDescriptions == null) {
|
||||
myCachedDescriptions = myExcludeEntryDescriptions.toArray(new ExcludeEntryDescription[myExcludeEntryDescriptions.size()]);
|
||||
}
|
||||
return myCachedDescriptions;
|
||||
}
|
||||
|
||||
public synchronized void addExcludeEntryDescription(ExcludeEntryDescription description) {
|
||||
myExcludeEntryDescriptions.add(description);
|
||||
myCachedDescriptions = null;
|
||||
}
|
||||
|
||||
public synchronized void removeAllExcludeEntryDescriptions() {
|
||||
myExcludeEntryDescriptions.clear();
|
||||
myCachedDescriptions = null;
|
||||
}
|
||||
|
||||
public void readExternal(final Element node) {
|
||||
for (final Object o : node.getChildren()) {
|
||||
Element element = (Element)o;
|
||||
String url = element.getAttributeValue(URL);
|
||||
if (url == null) continue;
|
||||
if (FILE.equals(element.getName())) {
|
||||
ExcludeEntryDescription excludeEntryDescription = new ExcludeEntryDescription(url, false, true, this);
|
||||
addExcludeEntryDescription(excludeEntryDescription);
|
||||
}
|
||||
if (DIRECTORY.equals(element.getName())) {
|
||||
boolean includeSubdirectories = Boolean.parseBoolean(element.getAttributeValue(INCLUDE_SUBDIRECTORIES));
|
||||
ExcludeEntryDescription excludeEntryDescription = new ExcludeEntryDescription(url, includeSubdirectories, false,this);
|
||||
addExcludeEntryDescription(excludeEntryDescription);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeExternal(final Element element) {
|
||||
for (final ExcludeEntryDescription description : getExcludeEntryDescriptions()) {
|
||||
if (description.isFile()) {
|
||||
Element entry = new Element(FILE);
|
||||
entry.setAttribute(URL, description.getUrl());
|
||||
element.addContent(entry);
|
||||
}
|
||||
else {
|
||||
Element entry = new Element(DIRECTORY);
|
||||
entry.setAttribute(URL, description.getUrl());
|
||||
entry.setAttribute(INCLUDE_SUBDIRECTORIES, Boolean.toString(description.isIncludeSubdirectories()));
|
||||
element.addContent(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isExcluded(VirtualFile virtualFile) {
|
||||
for (final ExcludeEntryDescription entryDescription : getExcludeEntryDescriptions()) {
|
||||
VirtualFile descriptionFile = entryDescription.getVirtualFile();
|
||||
if (descriptionFile == null) {
|
||||
continue;
|
||||
}
|
||||
if (entryDescription.isFile()) {
|
||||
if (descriptionFile.equals(virtualFile)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (entryDescription.isIncludeSubdirectories()) {
|
||||
if (VfsUtil.isAncestor(descriptionFile, virtualFile, false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (virtualFile.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
if (descriptionFile.equals(virtualFile.getParent())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
for (ExcludeEntryDescription description : myExcludeEntryDescriptions) {
|
||||
Disposer.dispose(description);
|
||||
}
|
||||
}
|
||||
|
||||
public ExcludedEntriesConfiguration getState() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void loadState(final ExcludedEntriesConfiguration state) {
|
||||
for (ExcludeEntryDescription description : state.getExcludeEntryDescriptions()) {
|
||||
addExcludeEntryDescription(description.copy(this));
|
||||
}
|
||||
Disposer.dispose(state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<!--
|
||||
~ Copyright 2000-2007 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.
|
||||
-->
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html><body bgcolor="white">
|
||||
Provides interfaces for invoking the compiler, listening to compilation events and implementing
|
||||
custom compilers or compilation steps.
|
||||
</body></html>
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.compiler.util;
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInspection.InspectionToolProvider;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.CompileScope;
|
||||
import com.intellij.openapi.compiler.CompilerMessageCategory;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public abstract class InspectionValidator {
|
||||
public static final ExtensionPointName<InspectionValidator> EP_NAME = ExtensionPointName.create("com.intellij.compiler.inspectionValidator");
|
||||
private final String myDescription;
|
||||
private final String myProgressIndicatorText;
|
||||
private final Class<? extends LocalInspectionTool>[] myInspectionToolClasses;
|
||||
|
||||
protected InspectionValidator(@NotNull final String description, @NotNull final String progressIndicatorText, final Class<? extends LocalInspectionTool>... inspectionToolClasses) {
|
||||
myDescription = description;
|
||||
myProgressIndicatorText = progressIndicatorText;
|
||||
myInspectionToolClasses = inspectionToolClasses;
|
||||
}
|
||||
|
||||
protected InspectionValidator(@NotNull final String description, @NotNull final String progressIndicatorText, final InspectionToolProvider provider) {
|
||||
//noinspection unchecked
|
||||
this(description, progressIndicatorText, provider.getInspectionClasses());
|
||||
}
|
||||
|
||||
protected InspectionValidator(@NotNull final String description, @NotNull final String progressIndicatorText, final Class<? extends InspectionToolProvider> providerClass)
|
||||
throws IllegalAccessException, InstantiationException {
|
||||
this(description, progressIndicatorText, providerClass.newInstance());
|
||||
}
|
||||
|
||||
|
||||
public abstract boolean isAvailableOnScope(@NotNull CompileScope scope);
|
||||
|
||||
public abstract Collection<VirtualFile> getFilesToProcess(final Project project, final CompileContext context);
|
||||
|
||||
@NotNull
|
||||
public Collection<? extends PsiElement> getDependencies(final PsiFile psiFile) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Class<? extends LocalInspectionTool>[] getInspectionToolClasses(final CompileContext context) {
|
||||
return myInspectionToolClasses;
|
||||
}
|
||||
|
||||
public final String getDescription() {
|
||||
return myDescription;
|
||||
}
|
||||
|
||||
public final String getProgressIndicatorText() {
|
||||
return myProgressIndicatorText;
|
||||
}
|
||||
|
||||
public CompilerMessageCategory getCategoryByHighlightDisplayLevel(@NotNull final HighlightDisplayLevel severity, @NotNull final VirtualFile virtualFile, @NotNull final CompileContext context) {
|
||||
if (severity == HighlightDisplayLevel.ERROR) return CompilerMessageCategory.ERROR;
|
||||
if (severity == HighlightDisplayLevel.WARNING) return CompilerMessageCategory.WARNING;
|
||||
return CompilerMessageCategory.INFORMATION;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.deployment;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class ContainerElement implements JDOMExternalizable, Cloneable, ResolvableElement {
|
||||
private final Map<String,String> myAttributes = new LinkedHashMap<String, String>();
|
||||
private final Module myParentModule;
|
||||
@NonNls public static final String URI_ATTR = "URI";
|
||||
@NonNls public static final String PACKAGING_METHOD_ATTR = "method";
|
||||
@NonNls public static final String ELEMENT_ATTRIBUTE = "attribute";
|
||||
@NonNls public static final String ATTRIBUTE_NAME = "name";
|
||||
@NonNls public static final String ATTRIBUTE_VALUE = "value";
|
||||
|
||||
protected ContainerElement(@NotNull Module parentModule) {
|
||||
myParentModule = parentModule;
|
||||
}
|
||||
|
||||
public abstract String getPresentableName();
|
||||
|
||||
public String getURI() {
|
||||
return getAttribute(URI_ATTR);
|
||||
}
|
||||
|
||||
public void setURI(String uri) {
|
||||
setAttribute(URI_ATTR, uri);
|
||||
}
|
||||
public PackagingMethod getPackagingMethod() {
|
||||
final String attribute = getAttribute(PACKAGING_METHOD_ATTR);
|
||||
return attribute == null ? PackagingMethod.DO_NOT_PACKAGE : PackagingMethod.getDeploymentMethodById(attribute);
|
||||
}
|
||||
public void setPackagingMethod(PackagingMethod method) {
|
||||
setAttribute(PACKAGING_METHOD_ATTR, method.getId());
|
||||
}
|
||||
|
||||
public void setAttribute(String name, String value) {
|
||||
myAttributes.put(name, value);
|
||||
}
|
||||
public String getAttribute(String name) {
|
||||
return myAttributes.get(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Module getParentModule() {
|
||||
return myParentModule;
|
||||
}
|
||||
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
final List attrs = element.getChildren(ELEMENT_ATTRIBUTE);
|
||||
for (Object attr : attrs) {
|
||||
Element attribute = (Element)attr;
|
||||
final String name = attribute.getAttributeValue(ATTRIBUTE_NAME);
|
||||
final String value = attribute.getAttributeValue(ATTRIBUTE_VALUE);
|
||||
setAttribute(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
for (Object o : myAttributes.keySet()) {
|
||||
String name = (String)o;
|
||||
String value = getAttribute(name);
|
||||
final Element attr = new Element(ELEMENT_ATTRIBUTE);
|
||||
attr.setAttribute(ATTRIBUTE_NAME, name);
|
||||
attr.setAttribute(ATTRIBUTE_VALUE, value == null ? "" : value);
|
||||
element.addContent(attr);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract boolean equalsIgnoreAttributes(ContainerElement otherElement);
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ContainerElement)) return false;
|
||||
|
||||
final ContainerElement otherElement = (ContainerElement)o;
|
||||
if (!equalsIgnoreAttributes(otherElement)) return false;
|
||||
return myAttributes.equals(otherElement.myAttributes);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public abstract String getDescription();
|
||||
|
||||
public abstract String getDescriptionForPackagingMethod(PackagingMethod method);
|
||||
|
||||
public ContainerElement clone() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.deployment;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.compiler.CompilerMessageCategory;
|
||||
import com.intellij.openapi.compiler.make.BuildRecipe;
|
||||
import com.intellij.openapi.compiler.make.PackagingFileFilter;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import com.intellij.util.descriptors.ConfigFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
public abstract class DeploymentUtil {
|
||||
public static DeploymentUtil getInstance() {
|
||||
return ServiceManager.getService(DeploymentUtil.class);
|
||||
}
|
||||
|
||||
public abstract boolean addModuleOutputContents(@NotNull CompileContext context,
|
||||
@NotNull BuildRecipe items,
|
||||
@NotNull Module sourceModule,
|
||||
Module targetModule,
|
||||
@NonNls String outputRelativePath,
|
||||
@Nullable @NonNls String possibleBaseOuputPath,
|
||||
@Nullable PackagingFileFilter fileFilter);
|
||||
|
||||
public abstract void addLibraryLink(@NotNull CompileContext context,
|
||||
@NotNull BuildRecipe items,
|
||||
@NotNull LibraryLink libraryLink,
|
||||
@NotNull Module module,
|
||||
String possibleBaseOutputPath);
|
||||
|
||||
public abstract void copyFile(@NotNull File fromFile,
|
||||
@NotNull File toFile,
|
||||
@NotNull CompileContext context,
|
||||
@Nullable Set<String> writtenPaths,
|
||||
@Nullable FileFilter fileFilter) throws IOException;
|
||||
|
||||
public abstract boolean addItemsRecursively(@NotNull BuildRecipe items,
|
||||
@NotNull File root,
|
||||
@NotNull Module module,
|
||||
String outputRelativePath,
|
||||
@Nullable PackagingFileFilter fileFilter,
|
||||
@Nullable String possibleBaseOutputPath);
|
||||
|
||||
public static void reportRecursiveCopying(CompileContext context, final String sourceDirPath, String targetDirPath,
|
||||
final String dirTitle, String additionalMessage) {
|
||||
final String message = CompilerBundle.message(
|
||||
"message.text.copy.dirTitle.dirPath.to.targetDirPath.will.lead.to.recursive.copying.additionalMessage", dirTitle,
|
||||
FileUtil.toSystemDependentName(sourceDirPath), FileUtil.toSystemDependentName(targetDirPath), additionalMessage);
|
||||
context.addMessage(CompilerMessageCategory.ERROR, message,null,-1,-1);
|
||||
}
|
||||
|
||||
public static String trimForwardSlashes(@NotNull String path) {
|
||||
while (path.length() != 0 && (path.charAt(0) == '/' || path.charAt(0) == File.separatorChar)) {
|
||||
path = path.substring(1);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
public static String trimTrailingSlashes(@NotNull String path) {
|
||||
int l = path.length() - 1;
|
||||
while (l >= 0 && (path.charAt(l) == '/' || path.charAt(l) == File.separatorChar)) l--;
|
||||
return path.substring(0, l+1);
|
||||
}
|
||||
|
||||
public abstract void reportDeploymentDescriptorDoesNotExists(ConfigFile descriptor, CompileContext context, Module module);
|
||||
|
||||
@Nullable public abstract Manifest createManifest(@NotNull BuildRecipe buildRecipe);
|
||||
|
||||
public abstract void addJavaModuleOutputs(@NotNull Module module,
|
||||
@NotNull ModuleLink[] containingModules,
|
||||
@NotNull BuildRecipe instructions,
|
||||
@NotNull CompileContext context,
|
||||
String explodedPath, final String linkContainerDescription);
|
||||
@Deprecated
|
||||
/**@deprecated
|
||||
* use {@link DeploymentUtil.addJavaModuleOutputs()}
|
||||
*/
|
||||
public abstract void addJavaModuleOutputs(@NotNull Module module,
|
||||
@NotNull ModuleLink[] containingModules,
|
||||
@NotNull BuildRecipe instructions,
|
||||
@NotNull CompileContext context,
|
||||
String explodedPath);
|
||||
|
||||
public static boolean checkFileExists(final File file, CompileContext context) {
|
||||
if (!file.exists()) {
|
||||
context.addMessage(CompilerMessageCategory.ERROR, CompilerBundle.message("compiler.message.text.file.does.not.exist", file),null,-1,-1);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String concatPaths(String... paths) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
for (String path : paths) {
|
||||
if (path.length() == 0) continue;
|
||||
|
||||
final int len = builder.length();
|
||||
if (len > 0 && builder.charAt(len - 1) != '/' && builder.charAt(len - 1) != File.separatorChar) {
|
||||
builder.append('/');
|
||||
}
|
||||
builder.append(len != 0 ? trimForwardSlashes(path) : path);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static String appendToPath(@NotNull String path, @NotNull String name) {
|
||||
if (!StringUtil.endsWithChar(path, '/') && !path.endsWith(File.separator)) {
|
||||
path += "/";
|
||||
}
|
||||
return path + trimForwardSlashes(name);
|
||||
}
|
||||
|
||||
public static File canonicalRelativePath(File file, final String outputRelativePath) {
|
||||
return new File(PathUtil.getCanonicalPath(appendToPath(file.getPath(),outputRelativePath)));
|
||||
}
|
||||
|
||||
public abstract ModuleLink createModuleLink(@NotNull Module dep, @NotNull Module module);
|
||||
|
||||
public abstract LibraryLink createLibraryLink(Library library, @NotNull Module parentModule);
|
||||
|
||||
public abstract PackagingConfiguration createPackagingConfiguration(@NotNull Module module);
|
||||
|
||||
public abstract BuildRecipe createBuildRecipe();
|
||||
|
||||
public @Nullable abstract ContainerElement findElementByOrderEntry(PackagingConfiguration packagingConfiguration, OrderEntry entry);
|
||||
|
||||
@Nullable
|
||||
public abstract String getConfigFileErrorMessage(ConfigFile configFile);
|
||||
|
||||
@Nullable
|
||||
public static String getRelativePath(File baseDir, File file) {
|
||||
if (baseDir == null || file == null) return null;
|
||||
|
||||
String basePath = baseDir.getAbsolutePath();
|
||||
final String filePath = file.getAbsolutePath();
|
||||
return getRelativePath(basePath, filePath);
|
||||
}
|
||||
|
||||
@Nullable public static String getRelativePath(@NotNull String basePath, @NotNull final String filePath) {
|
||||
if (basePath.equals(filePath)) return "";
|
||||
if (!basePath.endsWith(File.separator)) basePath += File.separatorChar;
|
||||
|
||||
int len = 0;
|
||||
int lastSeparatorIndex = 0; // need this for cases like this: base="/temp/abcde/baseDir" and file="/temp/ab"
|
||||
while (len < filePath.length() && len < basePath.length() && filePath.charAt(len) == basePath.charAt(len)) {
|
||||
if (basePath.charAt(len) == File.separatorChar) {
|
||||
lastSeparatorIndex = len;
|
||||
}
|
||||
len++;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
return null;
|
||||
}
|
||||
final StringBuilder relativePath = StringBuilderSpinAllocator.alloc();
|
||||
try {
|
||||
for (int i=len; i < basePath.length(); i++) {
|
||||
if (basePath.charAt(i) == File.separatorChar) {
|
||||
relativePath.append("..");
|
||||
relativePath.append(File.separatorChar);
|
||||
}
|
||||
}
|
||||
relativePath.append(filePath.substring(lastSeparatorIndex + 1));
|
||||
|
||||
return relativePath.toString();
|
||||
}
|
||||
finally {
|
||||
StringBuilderSpinAllocator.dispose(relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract @Nullable File findUserSuppliedManifestFile(@NotNull BuildRecipe buildRecipe);
|
||||
|
||||
public abstract void checkConfigFile(final ConfigFile descriptor, final CompileContext compileContext, final Module module);
|
||||
|
||||
public abstract void addModuleOutputJarToParent(@NotNull BuildRecipe instructions,
|
||||
@NotNull Module module,
|
||||
@NotNull String relativePath,
|
||||
@NotNull CompileContext context,
|
||||
String linkContainerDescription,
|
||||
@Nullable PackagingFileFilter fileFilter);
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.deployment;
|
||||
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
|
||||
public class ElementIgnoringAttributesEquality implements TObjectHashingStrategy<ContainerElement> {
|
||||
public boolean equals(ContainerElement object, ContainerElement object1) {
|
||||
if (object1 == null || object == null) {
|
||||
return object == object1;
|
||||
}
|
||||
return object.equalsIgnoreAttributes(object1);
|
||||
}
|
||||
|
||||
public int computeHashCode(ContainerElement object) {
|
||||
String presentableName = object.getPresentableName();
|
||||
if (presentableName == null) {
|
||||
return 0;
|
||||
}
|
||||
return presentableName.hashCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.deployment;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author Alexey Kudravtsev
|
||||
*/
|
||||
public abstract class LibraryLink extends ContainerElement {
|
||||
|
||||
@NonNls public static final String MODULE_LEVEL = "module";
|
||||
|
||||
public LibraryLink(Module parentModule) {
|
||||
super(parentModule);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract Library getLibrary();
|
||||
|
||||
public abstract List<String> getUrls();
|
||||
public abstract List<String> getClassesRootUrls();
|
||||
|
||||
public abstract boolean hasDirectoriesOnly();
|
||||
|
||||
@Nullable
|
||||
public abstract String getName();
|
||||
|
||||
public abstract String getLevel();
|
||||
|
||||
@Nullable
|
||||
public static Library findLibrary(String libraryName, String libraryLevel, Project project) {
|
||||
if (libraryName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
LibraryTable table = findTable(libraryLevel, project);
|
||||
if (table == null) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return table.getLibraryByName(libraryName);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static LibraryTable findTable(String libraryLevel, Project project) {
|
||||
if (libraryLevel == null) return null;
|
||||
if (LibraryTablesRegistrar.APPLICATION_LEVEL.equals(libraryLevel)) {
|
||||
return LibraryTablesRegistrar.getInstance().getLibraryTable();
|
||||
}
|
||||
return project == null? null : LibraryTablesRegistrar.getInstance().getLibraryTableByLevel(libraryLevel, project);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.deployment;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* @author Alexey Kudravtsev
|
||||
*/
|
||||
public abstract class ModuleLink extends ContainerElement {
|
||||
|
||||
public ModuleLink(Module parentModule) {
|
||||
super(parentModule);
|
||||
}
|
||||
|
||||
public abstract @Nullable Module getModule();
|
||||
|
||||
public abstract String getName();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.deployment;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.openapi.roots.ui.configuration.FacetsProvider;
|
||||
|
||||
public interface PackagingConfiguration extends JDOMExternalizable {
|
||||
ModuleLink[] getContainingModules();
|
||||
|
||||
LibraryLink[] getContainingLibraries();
|
||||
|
||||
ContainerElement[] getElements();
|
||||
|
||||
void setElements(ContainerElement[] elements);
|
||||
|
||||
Module[] getContainingIdeaModules();
|
||||
|
||||
ContainerElement[] getElements(ModulesProvider provider, FacetsProvider facetsProvider,
|
||||
boolean includeResolved, boolean includeUnresolved, boolean includeNonPackaged);
|
||||
|
||||
void addOrReplaceElement(ContainerElement element);
|
||||
|
||||
boolean removeContainerElement(ContainerElement containerElement);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2000-2007 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.openapi.deployment;
|
||||
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import gnu.trove.THashMap;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PackagingMethod {
|
||||
public static final PackagingMethod[] EMPTY_ARRAY = new PackagingMethod[0];
|
||||
private final String myId;
|
||||
private final String myDescription;
|
||||
|
||||
private static final Map<String, PackagingMethod> ourRegisteredMethods = new THashMap<String, PackagingMethod>();
|
||||
|
||||
private PackagingMethod(String id, String description) {
|
||||
myId = id;
|
||||
myDescription = description;
|
||||
|
||||
ourRegisteredMethods.put(id, this);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return myId;
|
||||
}
|
||||
|
||||
public static final PackagingMethod DO_NOT_PACKAGE = new PackagingMethod("0", CompilerBundle.message("packaging.method.name.do.not.package"));
|
||||
public static final PackagingMethod COPY_FILES = new PackagingMethod("1",CompilerBundle.message("packaging.method.name.copy.files"));
|
||||
public static final PackagingMethod COPY_FILES_AND_LINK_VIA_MANIFEST = new PackagingMethod("2",CompilerBundle.message("packaging.method.name.copy.files.and.link.via.manifest"));
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static final PackagingMethod COPY_CLASSES = new PackagingMethod("3",CompilerBundle.message("packaging.method.name.copy.classes"));
|
||||
public static final PackagingMethod INCLUDE_MODULE_IN_BUILD = new PackagingMethod("4",CompilerBundle.message("packaging.method.name.include.module.in.build"));
|
||||
public static final PackagingMethod JAR_AND_COPY_FILE = new PackagingMethod("5",CompilerBundle.message("packaging.method.name.jar.and.copy.file"));
|
||||
public static final PackagingMethod JAR_AND_COPY_FILE_AND_LINK_VIA_MANIFEST = new PackagingMethod("6",CompilerBundle.message("packaging.method.name.jar.copy.and.link.via.manifest"));
|
||||
|
||||
public static PackagingMethod getDeploymentMethodById(String id) {
|
||||
return ourRegisteredMethods.get(id);
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof PackagingMethod)) return false;
|
||||
|
||||
final PackagingMethod method = (PackagingMethod)o;
|
||||
|
||||
if (!myId.equals(method.myId)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return myId.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return CompilerBundle.message("packaging.method.presentation.with.description", myDescription);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user