new project model: artifacts added

This commit is contained in:
nik
2012-07-24 10:44:29 +04:00
parent b4591256ab
commit 6f3abb799d
92 changed files with 1714 additions and 758 deletions
@@ -38,6 +38,9 @@ import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.serialization.artifact.ArtifactManagerState;
import org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState;
import org.jetbrains.jps.model.serialization.artifact.ArtifactState;
import java.util.*;
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.text.UniqueNameGenerator;
import org.jdom.Element;
import org.jetbrains.jps.model.serialization.artifact.ArtifactState;
import java.util.ArrayList;
import java.util.List;
@@ -16,6 +16,7 @@
package com.intellij.packaging.impl.artifacts;
import com.intellij.packaging.elements.PackagingElementFactory;
import org.jetbrains.jps.model.serialization.artifact.ArtifactState;
/**
* @author nik
@@ -18,9 +18,9 @@ package com.intellij.packaging.impl.elements;
import com.intellij.openapi.compiler.CompilerBundle;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.packaging.elements.CompositePackagingElement;
import com.intellij.packaging.elements.CompositePackagingElementType;
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
import com.intellij.packaging.impl.ui.properties.ArchiveElementPropertiesPanel;
import com.intellij.packaging.ui.ArtifactEditorContext;
import com.intellij.packaging.ui.PackagingElementPropertiesPanel;
@@ -53,7 +53,7 @@ class ArchiveElementType extends CompositePackagingElementType<ArchivePackagingE
public PackagingElementPropertiesPanel createElementPropertiesPanel(@NotNull ArchivePackagingElement element,
@NotNull ArtifactEditorContext context) {
final String name = element.getArchiveFileName();
if (name.length() >= 4 && name.charAt(name.length() - 4) == '.' && StringUtil.endsWithIgnoreCase(name, "ar")) {
if (ArtifactUtil.isArchiveName(name)) {
return new ArchiveElementPropertiesPanel(element, context);
}
return null;
@@ -17,7 +17,6 @@ import org.jetbrains.ether.dependencyView.Callbacks;
import org.jetbrains.jps.JpsPathUtil;
import org.jetbrains.jps.Project;
import org.jetbrains.jps.api.*;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.idea.IdeaProjectLoader;
import org.jetbrains.jps.idea.SystemOutErrorReporter;
import org.jetbrains.jps.incremental.*;
@@ -29,6 +28,8 @@ import org.jetbrains.jps.incremental.storage.ProjectTimestamps;
import org.jetbrains.jps.incremental.storage.Timestamps;
import org.jetbrains.jps.model.JpsElementFactory;
import org.jetbrains.jps.model.JpsModel;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.JpsArtifactService;
import org.jetbrains.jps.model.java.JpsJavaLibraryType;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsOrderRootType;
@@ -596,15 +597,13 @@ final class BuildSession implements Runnable, CanceledStatus {
Collection<String> artifactNames,
Collection<String> paths) throws Exception {
final Timestamps timestamps = pd.timestamps.getStorage();
Set<Artifact> artifacts = new HashSet<Artifact>();
Set<JpsArtifact> artifacts = new HashSet<JpsArtifact>();
if (artifactNames.isEmpty() && buildType == BuildType.PROJECT_REBUILD) {
artifacts.addAll(pd.project.getArtifacts().values());
artifacts.addAll(JpsArtifactService.getInstance().getArtifacts(pd.jpsProject));
}
else {
final Map<String, Artifact> artifactMap = pd.project.getArtifacts();
for (String name : artifactNames) {
final Artifact artifact = artifactMap.get(name);
if (artifact != null && !StringUtil.isEmpty(artifact.getOutputPath())) {
for (JpsArtifact artifact : JpsArtifactService.getInstance().getArtifacts(pd.jpsProject)) {
if (artifactNames.contains(artifact.getName()) && !StringUtil.isEmpty(artifact.getOutputPath())) {
artifacts.add(artifact);
}
}
@@ -2,8 +2,8 @@ package org.jetbrains.jps.incremental;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.Project;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import java.io.File;
import java.util.Set;
@@ -16,7 +16,7 @@ public class AllProjectScope extends CompileScope {
private final boolean myIsForcedCompilation;
public AllProjectScope(Project project, JpsProject jpsProject, Set<Artifact> artifacts, boolean forcedCompilation) {
public AllProjectScope(Project project, JpsProject jpsProject, Set<JpsArtifact> artifacts, boolean forcedCompilation) {
super(project, jpsProject, artifacts);
myIsForcedCompilation = forcedCompilation;
}
@@ -3,8 +3,8 @@ package org.jetbrains.jps.incremental;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.ModuleChunk;
import org.jetbrains.jps.Project;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.module.JpsModule;
import java.io.File;
@@ -18,15 +18,15 @@ public abstract class CompileScope {
@NotNull
private final Project myProject;
private final JpsProject myJpsProject;
private final Set<Artifact> myArtifacts;
private final Set<JpsArtifact> myArtifacts;
protected CompileScope(@NotNull Project project, JpsProject jpsProject, Set<Artifact> artifacts) {
protected CompileScope(@NotNull Project project, JpsProject jpsProject, Set<JpsArtifact> artifacts) {
myProject = project;
myJpsProject = jpsProject;
myArtifacts = artifacts;
}
public boolean isAffected(Artifact artifact) {
public boolean isAffected(JpsArtifact artifact) {
return myArtifacts.contains(artifact);
}
@@ -45,7 +45,7 @@ public abstract class CompileScope {
return false;
}
public Set<Artifact> getArtifacts() {
public Set<JpsArtifact> getArtifacts() {
return myArtifacts;
}
@@ -2,8 +2,8 @@ package org.jetbrains.jps.incremental;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.Project;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.module.JpsModule;
import java.io.File;
@@ -23,7 +23,7 @@ public class ModulesAndFilesScope extends CompileScope {
private final boolean myForcedCompilation;
public ModulesAndFilesScope(Project project, JpsProject jpsProject, Collection<JpsModule> modules, Map<String, Set<File>> files,
Set<Artifact> artifacts, boolean isForcedCompilation) {
Set<JpsArtifact> artifacts, boolean isForcedCompilation) {
super(project, jpsProject, artifacts);
myFiles = files;
myForcedCompilation = isForcedCompilation;
@@ -2,8 +2,8 @@ package org.jetbrains.jps.incremental;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.Project;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.module.JpsModule;
import java.io.File;
@@ -19,7 +19,7 @@ public class ModulesScope extends CompileScope {
private final Set<String> myModules;
private final boolean myForcedCompilation;
public ModulesScope(Project project, JpsProject jpsProject, Set<JpsModule> modules, Set<Artifact> artifacts, boolean isForcedCompilation) {
public ModulesScope(Project project, JpsProject jpsProject, Set<JpsModule> modules, Set<JpsArtifact> artifacts, boolean isForcedCompilation) {
super(project, jpsProject, artifacts);
myModules = new HashSet<String>();
for (JpsModule module : modules) {
@@ -6,8 +6,6 @@ import com.intellij.util.containers.IntArrayList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.Project;
import org.jetbrains.jps.ProjectPaths;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.artifacts.LayoutElement;
import org.jetbrains.jps.incremental.ModuleRootsIndex;
import org.jetbrains.jps.incremental.artifacts.builders.LayoutElementBuildersRegistry;
import org.jetbrains.jps.incremental.artifacts.instructions.*;
@@ -15,6 +13,8 @@ import org.jetbrains.jps.incremental.storage.BuildDataManager;
import org.jetbrains.jps.incremental.storage.CompositeStorageOwner;
import org.jetbrains.jps.incremental.storage.StorageOwner;
import org.jetbrains.jps.model.JpsModel;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
import java.io.File;
import java.io.IOException;
@@ -25,7 +25,7 @@ import java.util.*;
*/
public class ArtifactSourceFilesState extends CompositeStorageOwner {
private final Project myProject;
private final Artifact myArtifact;
private final JpsArtifact myArtifact;
private final int myArtifactId;
private final JpsModel myModel;
private final ModuleRootsIndex myRootsIndex;
@@ -38,7 +38,7 @@ public class ArtifactSourceFilesState extends CompositeStorageOwner {
private final File mySrcOutMappingsFile;
private File myOutSrcMappingsFile;
public ArtifactSourceFilesState(Artifact artifact, int artifactId, Project project,
public ArtifactSourceFilesState(JpsArtifact artifact, int artifactId, Project project,
JpsModel model, ModuleRootsIndex rootsIndex,
ArtifactSourceTimestampStorage timestampStorage,
File mappingsDir) {
@@ -147,7 +147,7 @@ public class ArtifactSourceFilesState extends CompositeStorageOwner {
}
private ArtifactInstructionsBuilder computeInstructions() {
final LayoutElement rootElement = myArtifact.getRootElement();
final JpsCompositePackagingElement rootElement = myArtifact.getRootElement();
ArtifactInstructionsBuilderContext context = new ArtifactInstructionsBuilderContextImpl(myProject,
myModel, myRootsIndex, new ProjectPaths(myModel.getProject()));
final ArtifactInstructionsBuilderImpl instructionsBuilder = new ArtifactInstructionsBuilderImpl(myRootsIndex, myProject.getIgnoredFilePatterns());
@@ -3,11 +3,11 @@ package org.jetbrains.jps.incremental.artifacts;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.jps.Project;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.incremental.ModuleRootsIndex;
import org.jetbrains.jps.incremental.storage.CompositeStorageOwner;
import org.jetbrains.jps.incremental.storage.StorageOwner;
import org.jetbrains.jps.model.JpsModel;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import java.io.File;
import java.io.IOException;
@@ -19,14 +19,14 @@ import java.util.Map;
* @author nik
*/
public class ArtifactsBuildData extends CompositeStorageOwner {
private Map<Artifact, ArtifactSourceFilesState> myArtifactState;
private Map<JpsArtifact, ArtifactSourceFilesState> myArtifactState;
private final ArtifactSourceTimestampStorage myTimestampStorage;
private ArtifactCompilerPersistentData myPersistentData;
private final File myMappingsDir;
public ArtifactsBuildData(File artifactsDataDir) throws IOException {
myTimestampStorage = new ArtifactSourceTimestampStorage(new File(artifactsDataDir, "timestamps"));
myArtifactState = new HashMap<Artifact, ArtifactSourceFilesState>();
myArtifactState = new HashMap<JpsArtifact, ArtifactSourceFilesState>();
myPersistentData = new ArtifactCompilerPersistentData(artifactsDataDir);
myMappingsDir = new File(artifactsDataDir, "mappings");
if (myPersistentData.isVersionChanged()) {
@@ -36,7 +36,7 @@ public class ArtifactsBuildData extends CompositeStorageOwner {
}
}
public ArtifactSourceFilesState getOrCreateState(Artifact artifact, Project project, JpsModel model, ModuleRootsIndex index) {
public ArtifactSourceFilesState getOrCreateState(JpsArtifact artifact, Project project, JpsModel model, ModuleRootsIndex index) {
ArtifactSourceFilesState state = myArtifactState.get(artifact);
if (state == null) {
final int artifactId = myPersistentData.getId(artifact.getName());
@@ -6,7 +6,6 @@ import com.intellij.util.containers.IntArrayList;
import com.intellij.util.containers.MultiMap;
import gnu.trove.THashSet;
import gnu.trove.TIntObjectHashMap;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.cmdline.ProjectDescriptor;
import org.jetbrains.jps.incremental.CompileContext;
import org.jetbrains.jps.incremental.ProjectBuildException;
@@ -18,6 +17,8 @@ import org.jetbrains.jps.incremental.messages.BuildMessage;
import org.jetbrains.jps.incremental.messages.CompilerMessage;
import org.jetbrains.jps.incremental.messages.ProgressMessage;
import org.jetbrains.jps.incremental.messages.UptoDateFilesSavedEvent;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.JpsArtifactService;
import java.io.File;
import java.io.IOException;
@@ -35,32 +36,27 @@ public class IncArtifactBuilder extends ProjectLevelBuilder {
@Override
public void build(CompileContext context) throws ProjectBuildException {
Set<Artifact> affected = new HashSet<Artifact>();
for (Artifact artifact : context.getProjectDescriptor().project.getArtifacts().values()) {
Set<JpsArtifact> affected = new HashSet<JpsArtifact>();
for (JpsArtifact artifact : JpsArtifactService.getInstance().getArtifacts(context.getProjectDescriptor().jpsProject)) {
if (context.getScope().isAffected(artifact)) {
affected.add(artifact);
}
}
final Set<Artifact> toBuild = ArtifactSorter.addIncludedArtifacts(affected, context.getProjectDescriptor().project, context.getProjectDescriptor().jpsModel);
Map<String, Artifact> artifactsMap = new HashMap<String, Artifact>();
for (Artifact artifact : toBuild) {
artifactsMap.put(artifact.getName(), artifact);
}
final Set<JpsArtifact> toBuild = ArtifactSorter.addIncludedArtifacts(affected, context.getProjectDescriptor().project, context.getProjectDescriptor().jpsModel);
final ArtifactSorter sorter = new ArtifactSorter(context.getProjectDescriptor().project, context.getProjectDescriptor().jpsModel);
final Map<String, String> selfIncludingNameMap = sorter.getArtifactToSelfIncludingNameMap();
for (String artifactName : sorter.getArtifactsSortedByInclusion()) {
final ArtifactSorter sorter = new ArtifactSorter(context.getProjectDescriptor().jpsModel);
final Map<JpsArtifact, JpsArtifact> selfIncludingNameMap = sorter.getArtifactToSelfIncludingNameMap();
for (JpsArtifact artifact : sorter.getArtifactsSortedByInclusion()) {
context.checkCanceled();
final Artifact artifact = artifactsMap.get(artifactName);
if (artifact != null) {
final String selfIncluding = selfIncludingNameMap.get(artifactName);
if (toBuild.contains(artifact)) {
final JpsArtifact selfIncluding = selfIncludingNameMap.get(artifact);
if (selfIncluding != null) {
String name = selfIncluding.equals(artifact.getName()) ? "it" : "'" + selfIncluding + "' artifact";
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, "Cannot build '" + artifactName + "' artifact: " + name + " includes itself in the output layout"));
String name = selfIncluding.equals(artifact) ? "it" : "'" + selfIncluding.getName() + "' artifact";
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, "Cannot build '" + artifact.getName() + "' artifact: " + name + " includes itself in the output layout"));
break;
}
if (StringUtil.isEmpty(artifact.getOutputPath())) {
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, "Cannot build '" + artifactName + "' artifact: output path is not specified"));
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, "Cannot build '" + artifact.getName() + "' artifact: output path is not specified"));
break;
}
buildArtifact(artifact, context);
@@ -68,7 +64,7 @@ public class IncArtifactBuilder extends ProjectLevelBuilder {
}
}
private static void buildArtifact(Artifact artifact, final CompileContext context) throws ProjectBuildException {
private static void buildArtifact(JpsArtifact artifact, final CompileContext context) throws ProjectBuildException {
final ProjectDescriptor pd = context.getProjectDescriptor();
try {
final ArtifactSourceFilesState state = pd.dataManager.getArtifactsBuildData().getOrCreateState(artifact, pd.project, pd.jpsModel, pd.rootsIndex);
@@ -1,13 +1,13 @@
package org.jetbrains.jps.incremental.artifacts.builders;
import org.jetbrains.jps.artifacts.LayoutElement;
import org.jetbrains.jps.incremental.artifacts.instructions.ArtifactCompilerInstructionCreator;
import org.jetbrains.jps.incremental.artifacts.instructions.ArtifactInstructionsBuilderContext;
import org.jetbrains.jps.model.artifact.elements.JpsPackagingElement;
/**
* @author nik
*/
public abstract class LayoutElementBuilderService<E extends LayoutElement> {
public abstract class LayoutElementBuilderService<E extends JpsPackagingElement> {
private final Class<E> myElementClass;
protected LayoutElementBuilderService(Class<E> elementClass) {
@@ -4,11 +4,14 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ClassMap;
import org.jetbrains.jps.artifacts.*;
import org.jetbrains.jps.JpsPathUtil;
import org.jetbrains.jps.idea.OwnServiceLoader;
import org.jetbrains.jps.incremental.artifacts.instructions.ArtifactCompilerInstructionCreator;
import org.jetbrains.jps.incremental.artifacts.instructions.ArtifactInstructionsBuilderContext;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.elements.*;
import org.jetbrains.jps.model.java.JpsProductionModuleOutputPackagingElement;
import org.jetbrains.jps.model.java.JpsTestModuleOutputPackagingElement;
import java.io.File;
import java.util.List;
@@ -44,94 +47,90 @@ public class LayoutElementBuildersRegistry {
}
}
public void generateInstructions(LayoutElement layoutElement, ArtifactCompilerInstructionCreator instructionCreator,
public void generateInstructions(JpsPackagingElement layoutElement, ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
final LayoutElementBuilderService builder = myBuilders.get(layoutElement.getClass());
if (builder == null) {
if (builder != null) {
//noinspection unchecked
builder.generateInstructions(layoutElement, instructionCreator, builderContext);
}
else {
LOG.error("Builder not found for artifact output layout element of class " + layoutElement.getClass());
}
builder.generateInstructions(layoutElement, instructionCreator, builderContext);
}
private void generateChildrenInstructions(CompositeLayoutElement element, ArtifactCompilerInstructionCreator instructionCreator,
private void generateChildrenInstructions(JpsCompositePackagingElement element, ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
generateInstructions(element.getChildren(), instructionCreator, builderContext);
}
private void generateSubstitutionInstructions(ComplexLayoutElement element,
private void generateSubstitutionInstructions(JpsComplexPackagingElement element,
ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
final List<LayoutElement> substitution = element.getSubstitution(builderContext.getProject(), builderContext.getJpsModel());
final List<JpsPackagingElement> substitution = element.getSubstitution();
if (substitution != null) {
generateInstructions(substitution, instructionCreator, builderContext);
}
}
private void generateInstructions(final List<LayoutElement> elements, ArtifactCompilerInstructionCreator instructionCreator,
private void generateInstructions(final List<JpsPackagingElement> elements, ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
for (LayoutElement child : elements) {
for (JpsPackagingElement child : elements) {
generateInstructions(child, instructionCreator, builderContext);
}
}
private static void generateModuleOutputInstructions(String moduleName,
boolean tests,
ArtifactCompilerInstructionCreator creator,
ArtifactInstructionsBuilderContext context) {
final JpsModule module = context.getRootsIndex().getModuleByName(moduleName);
if (module != null) {
final File outputDir = context.getProjectPaths().getModuleOutputDir(module, tests);
if (outputDir != null) {
creator.addDirectoryCopyInstructions(outputDir);
}
private static void generateModuleOutputInstructions(String outputUrl, ArtifactCompilerInstructionCreator creator) {
if (outputUrl != null) {
creator.addDirectoryCopyInstructions(JpsPathUtil.urlToFile(outputUrl));
}
}
private class RootElementBuilder extends LayoutElementBuilderService<RootElement> {
private class RootElementBuilder extends LayoutElementBuilderService<JpsArtifactRootElement> {
public RootElementBuilder() {
super(RootElement.class);
super(JpsArtifactRootElement.class);
}
@Override
public void generateInstructions(RootElement element, ArtifactCompilerInstructionCreator instructionCreator, ArtifactInstructionsBuilderContext builderContext) {
public void generateInstructions(JpsArtifactRootElement element, ArtifactCompilerInstructionCreator instructionCreator, ArtifactInstructionsBuilderContext builderContext) {
generateChildrenInstructions(element, instructionCreator, builderContext);
}
}
private class DirectoryElementBuilder extends LayoutElementBuilderService<DirectoryElement> {
private class DirectoryElementBuilder extends LayoutElementBuilderService<JpsDirectoryPackagingElement> {
public DirectoryElementBuilder() {
super(DirectoryElement.class);
super(JpsDirectoryPackagingElement.class);
}
@Override
public void generateInstructions(DirectoryElement element,
public void generateInstructions(JpsDirectoryPackagingElement element,
ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
generateChildrenInstructions(element, instructionCreator.subFolder(element.getName()), builderContext);
generateChildrenInstructions(element, instructionCreator.subFolder(element.getDirectoryName()), builderContext);
}
}
private class ArchiveElementBuilder extends LayoutElementBuilderService<ArchiveElement> {
private class ArchiveElementBuilder extends LayoutElementBuilderService<JpsArchivePackagingElement> {
public ArchiveElementBuilder() {
super(ArchiveElement.class);
super(JpsArchivePackagingElement.class);
}
@Override
public void generateInstructions(ArchiveElement element, ArtifactCompilerInstructionCreator instructionCreator,
public void generateInstructions(JpsArchivePackagingElement element, ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
generateChildrenInstructions(element, instructionCreator.archive(element.getName()), builderContext);
generateChildrenInstructions(element, instructionCreator.archive(element.getArchiveName()), builderContext);
}
}
private static class DirectoryCopyElementBuilder extends LayoutElementBuilderService<DirectoryCopyElement> {
private static class DirectoryCopyElementBuilder extends LayoutElementBuilderService<JpsDirectoryCopyPackagingElement> {
public DirectoryCopyElementBuilder() {
super(DirectoryCopyElement.class);
super(JpsDirectoryCopyPackagingElement.class);
}
@Override
public void generateInstructions(DirectoryCopyElement element, ArtifactCompilerInstructionCreator instructionCreator,
public void generateInstructions(JpsDirectoryCopyPackagingElement element, ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
final String dirPath = element.getDirPath();
final String dirPath = element.getDirectoryPath();
if (dirPath != null) {
final File directory = new File(FileUtil.toSystemDependentName(dirPath));
if (directory.isDirectory()) {
@@ -141,35 +140,35 @@ public class LayoutElementBuildersRegistry {
}
}
private static class FileCopyElementBuilder extends LayoutElementBuilderService<FileCopyElement> {
private static class FileCopyElementBuilder extends LayoutElementBuilderService<JpsFileCopyPackagingElement> {
public FileCopyElementBuilder() {
super(FileCopyElement.class);
super(JpsFileCopyPackagingElement.class);
}
@Override
public void generateInstructions(FileCopyElement element, ArtifactCompilerInstructionCreator instructionCreator,
public void generateInstructions(JpsFileCopyPackagingElement element, ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
final String filePath = element.getFilePath();
if (filePath != null) {
final File file = new File(FileUtil.toSystemDependentName(filePath));
if (file.isFile()) {
final String fileName = element.getOutputFileName();
final String fileName = element.getRenamedOutputFileName();
instructionCreator.addFileCopyInstruction(file, fileName != null ? fileName : file.getName());
}
}
}
}
private static class ExtractedDirectoryElementBuilder extends LayoutElementBuilderService<ExtractedDirectoryElement> {
private static class ExtractedDirectoryElementBuilder extends LayoutElementBuilderService<JpsExtractedDirectoryPackagingElement> {
public ExtractedDirectoryElementBuilder() {
super(ExtractedDirectoryElement.class);
super(JpsExtractedDirectoryPackagingElement.class);
}
@Override
public void generateInstructions(ExtractedDirectoryElement element,
public void generateInstructions(JpsExtractedDirectoryPackagingElement element,
ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
final String jarPath = element.getJarPath();
final String jarPath = element.getFilePath();
final String pathInJar = element.getPathInJar();
File jarFile = new File(FileUtil.toSystemDependentName(jarPath));
if (jarFile.isFile()) {
@@ -178,55 +177,55 @@ public class LayoutElementBuildersRegistry {
}
}
private static class ModuleOutputElementBuilder extends LayoutElementBuilderService<ModuleOutputElement> {
private static class ModuleOutputElementBuilder extends LayoutElementBuilderService<JpsProductionModuleOutputPackagingElement> {
public ModuleOutputElementBuilder() {
super(ModuleOutputElement.class);
super(JpsProductionModuleOutputPackagingElement.class);
}
@Override
public void generateInstructions(ModuleOutputElement element,
public void generateInstructions(JpsProductionModuleOutputPackagingElement element,
ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
generateModuleOutputInstructions(element.getModuleName(), false, instructionCreator, builderContext);
generateModuleOutputInstructions(element.getOutputUrl(), instructionCreator);
}
}
private static class ModuleTestOutputElementBuilder extends LayoutElementBuilderService<ModuleTestOutputElement> {
private static class ModuleTestOutputElementBuilder extends LayoutElementBuilderService<JpsTestModuleOutputPackagingElement> {
public ModuleTestOutputElementBuilder() {
super(ModuleTestOutputElement.class);
super(JpsTestModuleOutputPackagingElement.class);
}
@Override
public void generateInstructions(ModuleTestOutputElement element,
public void generateInstructions(JpsTestModuleOutputPackagingElement element,
ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
generateModuleOutputInstructions(element.getModuleName(), true, instructionCreator, builderContext);
generateModuleOutputInstructions(element.getOutputUrl(), instructionCreator);
}
}
private class ComplexElementBuilder extends LayoutElementBuilderService<ComplexLayoutElement> {
private class ComplexElementBuilder extends LayoutElementBuilderService<JpsComplexPackagingElement> {
public ComplexElementBuilder() {
super(ComplexLayoutElement.class);
super(JpsComplexPackagingElement.class);
}
@Override
public void generateInstructions(ComplexLayoutElement element,
public void generateInstructions(JpsComplexPackagingElement element,
ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
generateSubstitutionInstructions(element, instructionCreator, builderContext);
}
}
private class ArtifactOutputElementBuilder extends LayoutElementBuilderService<ArtifactLayoutElement> {
private class ArtifactOutputElementBuilder extends LayoutElementBuilderService<JpsArtifactOutputPackagingElement> {
public ArtifactOutputElementBuilder() {
super(ArtifactLayoutElement.class);
super(JpsArtifactOutputPackagingElement.class);
}
@Override
public void generateInstructions(ArtifactLayoutElement element,
public void generateInstructions(JpsArtifactOutputPackagingElement element,
ArtifactCompilerInstructionCreator instructionCreator,
ArtifactInstructionsBuilderContext builderContext) {
final Artifact artifact = element.findArtifact(builderContext.getProject());
final JpsArtifact artifact = element.getArtifactReference().resolve();
if (artifact == null) return;
final String outputPath = artifact.getOutputPath();
@@ -235,10 +234,10 @@ public class LayoutElementBuildersRegistry {
return;
}
final LayoutElement rootElement = artifact.getRootElement();
final JpsPackagingElement rootElement = artifact.getRootElement();
final File outputDir = new File(FileUtil.toSystemDependentName(outputPath));
if (rootElement instanceof ArchiveElement) {
final String fileName = ((ArchiveElement)rootElement).getName();
if (rootElement instanceof JpsArchivePackagingElement) {
final String fileName = ((JpsArchivePackagingElement)rootElement).getArchiveName();
instructionCreator.addFileCopyInstruction(new File(outputDir, fileName), fileName);
}
else {
@@ -17,18 +17,20 @@ package org.jetbrains.jps.incremental.artifacts.impl;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Consumer;
import com.intellij.util.Processor;
import com.intellij.util.graph.CachingSemiGraph;
import com.intellij.util.graph.DFSTBuilder;
import com.intellij.util.graph.GraphGenerator;
import gnu.trove.TIntArrayList;
import gnu.trove.TIntProcedure;
import groovy.lang.Closure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.Project;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.artifacts.ArtifactLayoutElement;
import org.jetbrains.jps.artifacts.ComplexLayoutElement;
import org.jetbrains.jps.model.JpsModel;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.JpsArtifactService;
import org.jetbrains.jps.model.artifact.elements.JpsArtifactOutputPackagingElement;
import org.jetbrains.jps.model.artifact.elements.JpsPackagingElement;
import java.util.*;
@@ -36,55 +38,53 @@ import java.util.*;
* @author nik
*/
public class ArtifactSorter {
private final Project myProject;
private final JpsModel myModel;
private Map<String, String> myArtifactToSelfIncludingName;
private List<String> mySortedArtifacts;
private Map<JpsArtifact, JpsArtifact> myArtifactToSelfIncludingName;
private List<JpsArtifact> mySortedArtifacts;
public ArtifactSorter(Project project, JpsModel model) {
myProject = project;
public ArtifactSorter(JpsModel model) {
myModel = model;
}
public Map<String, String> getArtifactToSelfIncludingNameMap() {
public Map<JpsArtifact, JpsArtifact> getArtifactToSelfIncludingNameMap() {
if (myArtifactToSelfIncludingName == null) {
myArtifactToSelfIncludingName = computeArtifactToSelfIncludingNameMap();
}
return myArtifactToSelfIncludingName;
}
public List<String> getArtifactsSortedByInclusion() {
public List<JpsArtifact> getArtifactsSortedByInclusion() {
if (mySortedArtifacts == null) {
mySortedArtifacts = doGetSortedArtifacts();
}
return mySortedArtifacts;
}
private List<String> doGetSortedArtifacts() {
GraphGenerator<String> graph = createArtifactsGraph();
DFSTBuilder<String> builder = new DFSTBuilder<String>(graph);
private List<JpsArtifact> doGetSortedArtifacts() {
GraphGenerator<JpsArtifact> graph = createArtifactsGraph();
DFSTBuilder<JpsArtifact> builder = new DFSTBuilder<JpsArtifact>(graph);
builder.buildDFST();
List<String> names = new ArrayList<String>();
List<JpsArtifact> names = new ArrayList<JpsArtifact>();
names.addAll(graph.getNodes());
Collections.sort(names, builder.comparator());
return names;
}
private Map<String, String> computeArtifactToSelfIncludingNameMap() {
final Map<String, String> result = new HashMap<String, String>();
final GraphGenerator<String> graph = createArtifactsGraph();
for (String artifactName : graph.getNodes()) {
final Iterator<String> in = graph.getIn(artifactName);
private Map<JpsArtifact, JpsArtifact> computeArtifactToSelfIncludingNameMap() {
final Map<JpsArtifact, JpsArtifact> result = new HashMap<JpsArtifact, JpsArtifact>();
final GraphGenerator<JpsArtifact> graph = createArtifactsGraph();
for (JpsArtifact artifact : graph.getNodes()) {
final Iterator<JpsArtifact> in = graph.getIn(artifact);
while (in.hasNext()) {
String next = in.next();
if (next.equals(artifactName)) {
result.put(artifactName, artifactName);
JpsArtifact next = in.next();
if (next.equals(artifact)) {
result.put(artifact, artifact);
break;
}
}
}
final DFSTBuilder<String> builder = new DFSTBuilder<String>(graph);
final DFSTBuilder<JpsArtifact> builder = new DFSTBuilder<JpsArtifact>(graph);
builder.buildDFST();
if (builder.isAcyclic() && result.isEmpty()) return Collections.emptyMap();
@@ -94,8 +94,8 @@ public class ArtifactSorter {
public boolean execute(int size) {
if (size > 1) {
for (int j = 0; j < size; j++) {
final String artifactName = builder.getNodeByTNumber(myTNumber + j);
result.put(artifactName, artifactName);
final JpsArtifact artifact = builder.getNodeByTNumber(myTNumber + j);
result.put(artifact, artifact);
}
}
myTNumber += size;
@@ -104,13 +104,13 @@ public class ArtifactSorter {
});
for (int i = 0; i < graph.getNodes().size(); i++) {
final String artifactName = builder.getNodeByTNumber(i);
if (!result.containsKey(artifactName)) {
final Iterator<String> in = graph.getIn(artifactName);
final JpsArtifact artifact = builder.getNodeByTNumber(i);
if (!result.containsKey(artifact)) {
final Iterator<JpsArtifact> in = graph.getIn(artifact);
while (in.hasNext()) {
final String name = result.get(in.next());
if (name != null) {
result.put(artifactName, name);
final JpsArtifact next = result.get(in.next());
if (next != null) {
result.put(artifact, next);
}
}
}
@@ -120,19 +120,19 @@ public class ArtifactSorter {
}
@NotNull
public static Set<Artifact> addIncludedArtifacts(@NotNull Collection<Artifact> artifacts, @NotNull Project project, JpsModel model) {
Set<Artifact> result = new HashSet<Artifact>();
for (Artifact artifact : artifacts) {
collectIncludedArtifacts(artifact, project, model, new HashSet<Artifact>(), result, true);
public static Set<JpsArtifact> addIncludedArtifacts(@NotNull Collection<JpsArtifact> artifacts, @NotNull Project project, JpsModel model) {
Set<JpsArtifact> result = new HashSet<JpsArtifact>();
for (JpsArtifact artifact : artifacts) {
collectIncludedArtifacts(artifact, project, model, new HashSet<JpsArtifact>(), result, true);
}
return result;
}
private static void collectIncludedArtifacts(Artifact artifact,
private static void collectIncludedArtifacts(JpsArtifact artifact,
final Project project,
final JpsModel model,
final Set<Artifact> processed,
final Set<Artifact> result,
final Set<JpsArtifact> processed,
final Set<JpsArtifact> result,
final boolean withOutputPathOnly) {
if (!processed.add(artifact)) {
return;
@@ -141,31 +141,27 @@ public class ArtifactSorter {
result.add(artifact);
}
processIncludedArtifacts(artifact, project, model, new Consumer<Artifact>() {
processIncludedArtifacts(artifact, new Consumer<JpsArtifact>() {
@Override
public void consume(Artifact included) {
public void consume(JpsArtifact included) {
collectIncludedArtifacts(included, project, model, processed, result, withOutputPathOnly);
}
});
}
private GraphGenerator<String> createArtifactsGraph() {
return GraphGenerator.create(CachingSemiGraph.create(new ArtifactsGraph(myProject, myModel)));
private GraphGenerator<JpsArtifact> createArtifactsGraph() {
return GraphGenerator.create(CachingSemiGraph.create(new ArtifactsGraph(myModel.getProject())));
}
private static void processIncludedArtifacts(Artifact artifact,
final Project project,
JpsModel model, final Consumer<Artifact> consumer) {
artifact.getRootElement().process(project, model, new Closure(consumer) {
private static void processIncludedArtifacts(JpsArtifact artifact, final Consumer<JpsArtifact> consumer) {
JpsArtifactUtil.processPackagingElements(artifact.getRootElement(), new Processor<JpsPackagingElement>() {
@Override
public Object call(Object arguments) {
if (arguments instanceof ArtifactLayoutElement) {
final Artifact includedArtifact = ((ArtifactLayoutElement)arguments).findArtifact(project);
if (includedArtifact != null) {
consumer.consume(includedArtifact);
public boolean process(JpsPackagingElement element) {
if (element instanceof JpsArtifactOutputPackagingElement) {
JpsArtifact included = ((JpsArtifactOutputPackagingElement)element).getArtifactReference().resolve();
if (included != null) {
consumer.consume(included);
}
}
if (arguments instanceof ComplexLayoutElement) {
return false;
}
return true;
@@ -173,37 +169,30 @@ public class ArtifactSorter {
});
}
private static class ArtifactsGraph implements GraphGenerator.SemiGraph<String> {
private final Set<String> myArtifactNames;
private final Project myProject;
private final JpsModel myModel;
private static class ArtifactsGraph implements GraphGenerator.SemiGraph<JpsArtifact> {
private final Set<JpsArtifact> myArtifactNodes;
public ArtifactsGraph(Project project, JpsModel model) {
myProject = project;
myModel = model;
myArtifactNames = new LinkedHashSet<String>(project.getArtifacts().keySet());
public ArtifactsGraph(final JpsProject project) {
myArtifactNodes = new LinkedHashSet<JpsArtifact>(JpsArtifactService.getInstance().getArtifacts(project));
}
@Override
public Collection<String> getNodes() {
return myArtifactNames;
public Collection<JpsArtifact> getNodes() {
return myArtifactNodes;
}
@Override
public Iterator<String> getIn(String name) {
final Set<String> included = new LinkedHashSet<String>();
final Artifact artifact = myProject.getArtifacts().get(name);
if (artifact != null) {
final Consumer<Artifact> consumer = new Consumer<Artifact>() {
@Override
public void consume(Artifact artifact) {
if (myArtifactNames.contains(artifact.getName())) {
included.add(artifact.getName());
}
public Iterator<JpsArtifact> getIn(JpsArtifact artifact) {
final Set<JpsArtifact> included = new LinkedHashSet<JpsArtifact>();
final Consumer<JpsArtifact> consumer = new Consumer<JpsArtifact>() {
@Override
public void consume(JpsArtifact artifact) {
if (myArtifactNodes.contains(artifact)) {
included.add(artifact);
}
};
processIncludedArtifacts(artifact, myProject, myModel, consumer);
}
}
};
processIncludedArtifacts(artifact, consumer);
return included.iterator();
}
}
@@ -0,0 +1,30 @@
package org.jetbrains.jps.incremental.artifacts.impl;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.artifact.elements.JpsComplexPackagingElement;
import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
import org.jetbrains.jps.model.artifact.elements.JpsPackagingElement;
/**
* @author nik
*/
public class JpsArtifactUtil {
public static boolean processPackagingElements(@NotNull JpsPackagingElement element, @NotNull Processor<JpsPackagingElement> processor) {
if (!processor.process(element)) {
return false;
}
if (element instanceof JpsCompositePackagingElement) {
for (JpsPackagingElement child : ((JpsCompositePackagingElement)element).getChildren()) {
processPackagingElements(child, processor);
}
}
else if (element instanceof JpsComplexPackagingElement) {
for (JpsPackagingElement child : ((JpsComplexPackagingElement)element).getSubstitution()) {
processPackagingElements(child, processor);
}
}
return true;
}
}
@@ -19,13 +19,13 @@ import com.intellij.openapi.application.ex.PathManagerEx;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.builders.JpsBuildTestCase;
import org.jetbrains.jps.cmdline.ProjectDescriptor;
import org.jetbrains.jps.incremental.*;
import org.jetbrains.jps.incremental.artifacts.ArtifactBuilderLoggerImpl;
import org.jetbrains.jps.incremental.java.JavaBuilderLogger;
import org.jetbrains.jps.incremental.messages.BuildMessage;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import java.io.*;
import java.util.Collections;
@@ -182,7 +182,7 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
final ProjectDescriptor projectDescriptor = createProjectDescriptor(new BuildLoggingManager(new ArtifactBuilderLoggerImpl(), javaBuilderLogger));
try {
final IncProjectBuilder builder = createBuilder(projectDescriptor);
doBuild(builder, new AllProjectScope(myProject, myJpsProject, Collections.<Artifact>emptySet(), true), false, false, true);
doBuild(builder, new AllProjectScope(myProject, myJpsProject, Collections.<JpsArtifact>emptySet(), true), false, false, true);
modify();
@@ -206,7 +206,7 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
makeBuilder.addMessageHandler(handler);
makeBuilder.build(new AllProjectScope(myProject, myJpsProject, Collections.<Artifact>emptySet(), false), true, false, false);
makeBuilder.build(new AllProjectScope(myProject, myJpsProject, Collections.<JpsArtifact>emptySet(), false), true, false, false);
final ByteArrayOutputStream makeDump = new ByteArrayOutputStream();
@@ -222,7 +222,7 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
assertEquals(expected, actual);
if (!handler.myErrors) {
createBuilder(projectDescriptor).build(new AllProjectScope(myProject, myJpsProject, Collections.<Artifact>emptySet(), true), false, true, false);
createBuilder(projectDescriptor).build(new AllProjectScope(myProject, myJpsProject, Collections.<JpsArtifact>emptySet(), true), false, true, false);
final ByteArrayOutputStream rebuildDump = new ByteArrayOutputStream();
@@ -1,14 +1,16 @@
package org.jetbrains.jps.builders.rebuild
import com.intellij.openapi.application.ex.PathManagerEx
import com.intellij.openapi.util.io.FileUtil
import com.intellij.util.io.TestFileSystemBuilder
import org.jetbrains.jps.JpsPathUtil
import org.jetbrains.jps.artifacts.Artifact
import org.jetbrains.jps.builders.JpsBuildTestCase
import org.jetbrains.jps.incremental.AllProjectScope
import org.jetbrains.jps.incremental.BuildLoggingManager
import org.jetbrains.jps.incremental.artifacts.ArtifactBuilderLoggerImpl
import org.jetbrains.jps.incremental.java.JavaBuilderLoggerImpl
import org.jetbrains.jps.model.artifact.JpsArtifact
import org.jetbrains.jps.model.artifact.JpsArtifactService
import org.jetbrains.jps.model.java.JpsJavaExtensionService
/**
* @author nik
@@ -49,7 +51,7 @@ abstract class JpsRebuildTestCase extends JpsBuildTestCase {
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myJpsProject).outputUrl = JpsPathUtil.pathToUrl(FileUtil.toSystemIndependentName(getOrCreateOutputDirectory().getAbsolutePath()))
def descriptor = createProjectDescriptor(new BuildLoggingManager(new ArtifactBuilderLoggerImpl(), new JavaBuilderLoggerImpl()))
try {
def scope = new AllProjectScope(myProject, myJpsProject, new HashSet<Artifact>(myProject.artifacts.values()), true)
def scope = new AllProjectScope(myProject, myJpsProject, new HashSet<JpsArtifact>(JpsArtifactService.getInstance().getArtifacts(myJpsProject)), true)
doBuild(createBuilder(descriptor), scope, false, false, true)
}
finally {
@@ -1,6 +1,6 @@
package org.jetbrains.jps.incremental.artifacts;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import static com.intellij.util.io.TestFileSystemBuilder.fs;
import static org.jetbrains.jps.incremental.artifacts.LayoutElementTestUtil.archive;
@@ -13,7 +13,7 @@ public class ArtifactBuilderOverwriteTest extends ArtifactBuilderTestCase {
public void testOverwriteArchives() {
final String aFile = createFile("aaa.txt", "a");
final String bFile = createFile("bbb.txt", "b");
final Artifact a = addArtifact(
final JpsArtifact a = addArtifact(
root()
.archive("x.jar").fileCopy(aFile).end()
.archive("x.jar")
@@ -41,7 +41,7 @@ public class ArtifactBuilderOverwriteTest extends ArtifactBuilderTestCase {
public void testOverwriteNestedArchive() {
final String cFile = createFile("c.txt", "c");
final String eFile = createFile("e.txt", "e");
final Artifact a = addArtifact(
final JpsArtifact a = addArtifact(
root()
.archive("a.jar").archive("b.jar").fileCopy(cFile).end().end()
.archive("a.jar").archive("d.jar").fileCopy(eFile));
@@ -65,7 +65,7 @@ public class ArtifactBuilderOverwriteTest extends ArtifactBuilderTestCase {
public void testOverwriteFileByArchive() {
final String xFile = createFile("x.txt", "1");
final String jarFile = createFile("junit.jar", "123");
Artifact a = addArtifact(root()
JpsArtifact a = addArtifact(root()
.archive("junit.jar").fileCopy(xFile).end()
.fileCopy(jarFile));
buildAll();
@@ -88,7 +88,7 @@ public class ArtifactBuilderOverwriteTest extends ArtifactBuilderTestCase {
public void testOverwriteArchiveByFile() {
final String xFile = createFile("x.txt", "1");
final String jarFile = createFile("jdom.jar", "123");
Artifact a = addArtifact(root()
JpsArtifact a = addArtifact(root()
.fileCopy(jarFile)
.archive("jdom.jar").fileCopy(xFile));
buildAll();
@@ -112,7 +112,7 @@ public class ArtifactBuilderOverwriteTest extends ArtifactBuilderTestCase {
final String firstFile = createFile("d1/xxx.txt", "first");
final String secondFile = createFile("d2/xxx.txt", "second");
final String fooFile = createFile("d3/xxx.txt", "foo");
final Artifact a = addArtifact(
final JpsArtifact a = addArtifact(
root().dir("ddd")
.fileCopy(firstFile)
.fileCopy(fooFile)
@@ -144,7 +144,7 @@ public class ArtifactBuilderOverwriteTest extends ArtifactBuilderTestCase {
public void testDeleteOverwritingFiles() {
final String firstFile = createFile("d1/xxx.txt", "1");
final String secondFile = createFile("d2/xxx.txt", "2");
final Artifact a = addArtifact("a",
final JpsArtifact a = addArtifact("a",
root().dir("ddd").fileCopy(firstFile).fileCopy(secondFile).fileCopy(createFile("y.txt"))
);
buildAll();
@@ -165,7 +165,7 @@ public class ArtifactBuilderOverwriteTest extends ArtifactBuilderTestCase {
public void testUpdateManifest() {
final String manifestText1 = "Manifest-Version: 1.0\r\nMain-Class: A\r\n\r\n";
final String manifest = createFile("MANIFEST.MF", manifestText1);
final Artifact a = addArtifact("a", archive("a.jar").dir("META-INF").fileCopy(manifest).fileCopy(createFile("a.txt")));
final JpsArtifact a = addArtifact("a", archive("a.jar").dir("META-INF").fileCopy(manifest).fileCopy(createFile("a.txt")));
buildAll();
assertOutput(a, fs().archive("a.jar").dir("META-INF").file("MANIFEST.MF", manifestText1).file("a.txt"));
@@ -3,7 +3,7 @@ package org.jetbrains.jps.incremental.artifacts;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.PathUtil;
import org.jetbrains.jps.JpsPathUtil;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.module.JpsModule;
@@ -22,13 +22,13 @@ import static org.jetbrains.jps.incremental.artifacts.LayoutElementTestUtil.root
*/
public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
public void testFileCopy() {
final Artifact a = addArtifact(root().fileCopy(createFile("file.txt", "foo")));
final JpsArtifact a = addArtifact(root().fileCopy(createFile("file.txt", "foo")));
buildAll();
assertOutput(a, fs().file("file.txt", "foo"));
}
public void testDir() {
final Artifact a = addArtifact(
final JpsArtifact a = addArtifact(
root()
.fileCopy(createFile("abc.txt"))
.dir("dir")
@@ -43,7 +43,7 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
}
public void testArchive() {
final Artifact a = addArtifact(
final JpsArtifact a = addArtifact(
root()
.archive("xxx.zip")
.fileCopy(createFile("X.class", "data"))
@@ -62,7 +62,7 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
public void testTwoDirsInArchive() {
final String dir1 = PathUtil.getParentPath(PathUtil.getParentPath(createFile("dir1/a/x.txt")));
final String dir2 = PathUtil.getParentPath(PathUtil.getParentPath(createFile("dir2/a/y.txt")));
final Artifact a = addArtifact(
final JpsArtifact a = addArtifact(
root()
.archive("a.jar")
.dirCopy(dir1)
@@ -80,7 +80,7 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
}
public void testArchiveInArchive() {
final Artifact a = addArtifact(
final JpsArtifact a = addArtifact(
root()
.archive("a.jar")
.archive("b.jar")
@@ -95,10 +95,10 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
}
public void testIncludedArtifact() {
final Artifact included = addArtifact("included",
final JpsArtifact included = addArtifact("included",
root()
.fileCopy(createFile("aaa.txt")));
final Artifact a = addArtifact(
final JpsArtifact a = addArtifact(
root()
.dir("dir")
.artifact(included)
@@ -117,9 +117,9 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
}
public void testMergeDirectories() {
final Artifact included = addArtifact("included",
final JpsArtifact included = addArtifact("included",
root().dir("dir").fileCopy(createFile("aaa.class")));
final Artifact a = addArtifact(
final JpsArtifact a = addArtifact(
root()
.artifact(included)
.dir("dir")
@@ -134,7 +134,7 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
public void testCopyLibrary() {
final JpsLibrary library = addProjectLibrary("lib", getJUnitJarPath());
final Artifact a = addArtifact(root().lib(library));
final JpsArtifact a = addArtifact(root().lib(library));
buildAll();
assertOutput(a, fs().file("junit.jar"));
}
@@ -142,7 +142,7 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
public void testModuleOutput() {
final String file = createFile("src/A.java", "public class A {}");
final JpsModule module = addModule("a", PathUtil.getParentPath(file));
final Artifact artifact = addArtifact(root().module(module));
final JpsArtifact artifact = addArtifact(root().module(module));
buildArtifacts(artifact);
assertOutput(artifact, fs().file("A.class"));
@@ -151,7 +151,7 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
public void testIgnoredFile() {
final String file = createFile("a/.svn/a.txt");
createFile("a/svn/b.txt");
final Artifact a = addArtifact(root().dirCopy(PathUtil.getParentPath(PathUtil.getParentPath(file))));
final JpsArtifact a = addArtifact(root().dirCopy(PathUtil.getParentPath(PathUtil.getParentPath(file))));
buildAll();
assertOutput(a, fs().dir("svn").file("b.txt"));
}
@@ -159,7 +159,7 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
public void testIgnoredFileInArchive() {
final String file = createFile("a/.svn/a.txt");
createFile("a/svn/b.txt");
final Artifact a = addArtifact(archive("a.jar").dirCopy(PathUtil.getParentPath(PathUtil.getParentPath(file))));
final JpsArtifact a = addArtifact(archive("a.jar").dirCopy(PathUtil.getParentPath(PathUtil.getParentPath(file))));
buildAll();
assertOutput(a, fs().archive("a.jar").dir("svn").file("b.txt"));
}
@@ -175,7 +175,7 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
module.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(dir));
module.getExcludeRootsList().addUrl(JpsPathUtil.pathToUrl(excluded));
final Artifact a = addArtifact(root().dirCopy(excluded));
final JpsArtifact a = addArtifact(root().dirCopy(excluded));
buildAll();
assertOutput(a, fs().file("a.txt"));
}
@@ -191,13 +191,13 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
module.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(dir));
module.getExcludeRootsList().addUrl(JpsPathUtil.pathToUrl(PathUtil.getParentPath(file)));
final Artifact a = addArtifact(root().dirCopy(dir));
final JpsArtifact a = addArtifact(root().dirCopy(dir));
buildAll();
assertOutput(a, fs().file("b.txt"));
}
public void testExtractDirectory() {
final Artifact a = addArtifact("a", root().dir("dir").extractedDir(getJUnitJarPath(), "/junit/textui/"));
final JpsArtifact a = addArtifact("a", root().dir("dir").extractedDir(getJUnitJarPath(), "/junit/textui/"));
buildAll();
assertOutput(a, fs().dir("dir")
.file("ResultPrinter.class")
@@ -205,7 +205,7 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
}
public void testPackExtractedDirectory() {
final Artifact a = addArtifact("a", root().archive("a.jar").extractedDir(getJUnitJarPath(), "/junit/textui/"));
final JpsArtifact a = addArtifact("a", root().archive("a.jar").extractedDir(getJUnitJarPath(), "/junit/textui/"));
buildAll();
assertOutput(a, fs().archive("a.jar")
.file("ResultPrinter.class")
@@ -213,14 +213,14 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
}
public void testSelfIncludingArtifact() {
final Artifact a = addArtifact("a", root());
final JpsArtifact a = addArtifact("a", root());
LayoutElementTestUtil.addArtifactToLayout(a, a);
assertBuildFailed(a);
}
public void testCircularInclusion() {
final Artifact a = addArtifact("a", root());
final Artifact b = addArtifact("b", root());
final JpsArtifact a = addArtifact("a", root());
final JpsArtifact b = addArtifact("b", root());
LayoutElementTestUtil.addArtifactToLayout(a, b);
LayoutElementTestUtil.addArtifactToLayout(b, a);
assertBuildFailed(a);
@@ -228,10 +228,10 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
}
public void testArtifactContainingSelfIncludingArtifact() {
Artifact c = addArtifact("c", root());
final Artifact a = addArtifact("a", root().artifact(c));
JpsArtifact c = addArtifact("c", root());
final JpsArtifact a = addArtifact("a", root().artifact(c));
LayoutElementTestUtil.addArtifactToLayout(a, a);
final Artifact b = addArtifact("b", root().artifact(a));
final JpsArtifact b = addArtifact("b", root().artifact(a));
buildArtifacts(c);
assertBuildFailed(b);
@@ -243,7 +243,7 @@ public class ArtifactBuilderTest extends ArtifactBuilderTestCase {
final String firstFile = createFile("src/A.txt");
final String manifestFile = createFile("src/MANIFEST.MF");
final String lastFile = createFile("src/Z.txt");
final Artifact a = addArtifact(archive("a.jar").dir("META-INF")
final JpsArtifact a = addArtifact(archive("a.jar").dir("META-INF")
.fileCopy(firstFile).fileCopy(manifestFile).fileCopy(lastFile));
buildArtifacts(a);
final String jarPath = a.getOutputPath() + "/a.jar";
@@ -21,7 +21,6 @@ import com.intellij.util.io.TestFileSystemBuilder;
import com.intellij.util.text.UniqueNameGenerator;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.JpsPathUtil;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.builders.JpsBuildTestCase;
import org.jetbrains.jps.cmdline.ProjectDescriptor;
import org.jetbrains.jps.incremental.AllProjectScope;
@@ -29,6 +28,9 @@ import org.jetbrains.jps.incremental.BuildLoggingManager;
import org.jetbrains.jps.incremental.CompileScope;
import org.jetbrains.jps.incremental.IncProjectBuilder;
import org.jetbrains.jps.incremental.java.JavaBuilderLoggerImpl;
import org.jetbrains.jps.model.artifact.DirectoryArtifactType;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.JpsArtifactService;
import org.jetbrains.jps.model.java.*;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsOrderRootType;
@@ -58,8 +60,11 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
@Override
protected void tearDown() throws Exception {
for (Artifact artifact : myProject.getArtifacts().values()) {
FileUtil.delete(new File(FileUtil.toSystemDependentName(artifact.getOutputPath())));
for (JpsArtifact artifact : JpsArtifactService.getInstance().getArtifacts(myJpsProject)) {
String outputPath = artifact.getOutputPath();
if (outputPath != null) {
FileUtil.delete(new File(FileUtil.toSystemDependentName(outputPath)));
}
}
myDescriptor.release();
myProjectDir = null;
@@ -81,11 +86,20 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
}
}
protected Artifact addArtifact(LayoutElementTestUtil.LayoutElementCreator root) {
final String name = UniqueNameGenerator.generateUniqueName("a", myProject.getArtifacts().keySet());
protected JpsArtifact addArtifact(LayoutElementTestUtil.LayoutElementCreator root) {
Set<String> usedNames = getArtifactNames();
final String name = UniqueNameGenerator.generateUniqueName("a", usedNames);
return addArtifact(name, root);
}
private Set<String> getArtifactNames() {
Set<String> usedNames = new HashSet<String>();
for (JpsArtifact artifact : JpsArtifactService.getInstance().getArtifacts(myJpsProject)) {
usedNames.add(artifact.getName());
}
return usedNames;
}
private File getOrCreateProjectDir() {
if (myProjectDir == null) {
try {
@@ -98,14 +112,10 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
return myProjectDir;
}
protected Artifact addArtifact(String name, LayoutElementTestUtil.LayoutElementCreator root) {
assertFalse("Artifact " + name + " already exists", myProject.getArtifacts().containsKey(name));
Artifact artifact = new Artifact();
artifact.setName(name);
artifact.setRootElement(root.buildElement());
protected JpsArtifact addArtifact(String name, LayoutElementTestUtil.LayoutElementCreator root) {
assertFalse("JpsArtifact " + name + " already exists", getArtifactNames().contains(name));
JpsArtifact artifact = JpsArtifactService.getInstance().addArtifact(myJpsProject, name, root.buildElement(), DirectoryArtifactType.INSTANCE);
artifact.setOutputPath(getAbsolutePath("out/artifacts/" + name));
myProject.getArtifacts().put(name, artifact);
return artifact;
}
@@ -138,15 +148,15 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
}
protected void buildAll() {
Collection<Artifact> artifacts = myProject.getArtifacts().values();
buildArtifacts(artifacts.toArray(new Artifact[artifacts.size()]));
Collection<JpsArtifact> artifacts = JpsArtifactService.getInstance().getArtifacts(myJpsProject);
buildArtifacts(artifacts.toArray(new JpsArtifact[artifacts.size()]));
}
protected void buildArtifacts(Artifact... artifact) {
protected void buildArtifacts(JpsArtifact... artifact) {
doBuild(false, false, artifact);
}
private void doBuild(boolean force, final boolean shouldFail, Artifact... artifacts) {
private void doBuild(boolean force, final boolean shouldFail, JpsArtifact... artifacts) {
if (myDescriptor == null) {
myDescriptor = createProjectDescriptor(new BuildLoggingManager(myArtifactBuilderLogger, new JavaBuilderLoggerImpl()));
myDescriptor.incUsageCounter();
@@ -154,7 +164,7 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
myArtifactBuilderLogger.clear();
IncProjectBuilder builder = createBuilder(myDescriptor);
final CompileScope scope = new AllProjectScope(myDescriptor.project, myDescriptor.jpsProject,
new HashSet<Artifact>(Arrays.asList(artifacts)), force);
new HashSet<JpsArtifact>(Arrays.asList(artifacts)), force);
doBuild(builder, scope, shouldFail, !force, false);
}
@@ -164,11 +174,11 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
return FileUtil.toSystemIndependentName(file.getAbsolutePath());
}
protected static void assertEmptyOutput(Artifact a1) {
protected static void assertEmptyOutput(JpsArtifact a1) {
assertOutput(a1, fs());
}
protected void assertBuildFailed(Artifact a) {
protected void assertBuildFailed(JpsArtifact a) {
doBuild(false, true, a);
}
@@ -208,7 +218,7 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
assertSameElements(myArtifactBuilderLogger.myCopiedFilePaths, copiedPaths);
}
protected static void assertOutput(Artifact a, TestFileSystemBuilder expected) {
protected static void assertOutput(JpsArtifact a, TestFileSystemBuilder expected) {
expected.build().assertDirectoryEqual(new File(FileUtil.toSystemDependentName(a.getOutputPath())));
}
@@ -16,7 +16,7 @@
package org.jetbrains.jps.incremental.artifacts;
import com.intellij.util.PathUtil;
import org.jetbrains.jps.artifacts.Artifact;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import static com.intellij.util.io.TestFileSystemItem.fs;
import static org.jetbrains.jps.incremental.artifacts.LayoutElementTestUtil.archive;
@@ -29,7 +29,7 @@ public class IncrementalArtifactBuildingTest extends ArtifactBuilderTestCase {
public void testCopyChangedFile() {
String file1 = createFile("a.txt", "aaa");
String file2 = createFile("b.txt", "bbb");
final Artifact a = addArtifact(root().fileCopy(file1).fileCopy(file2));
final JpsArtifact a = addArtifact(root().fileCopy(file1).fileCopy(file2));
buildAll();
assertOutput(a, fs().file("a.txt", "aaa").file("b.txt", "bbb"));
@@ -45,7 +45,7 @@ public class IncrementalArtifactBuildingTest extends ArtifactBuilderTestCase {
public void testRemoveDeletedFile() {
String file1 = createFile("a.txt");
String file2 = createFile("b.txt");
final Artifact a = addArtifact("a", root().fileCopy(file1).fileCopy(file2));
final JpsArtifact a = addArtifact("a", root().fileCopy(file1).fileCopy(file2));
buildAll();
assertOutput(a, fs().file("a.txt").file("b.txt"));
@@ -59,7 +59,7 @@ public class IncrementalArtifactBuildingTest extends ArtifactBuilderTestCase {
public void testPackChangedFile() {
String file1 = createFile("a.txt", "aaa");
String file2 = createFile("b.txt", "bbb");
final Artifact a = addArtifact(archive("a.jar").fileCopy(file1).fileCopy(file2));
final JpsArtifact a = addArtifact(archive("a.jar").fileCopy(file1).fileCopy(file2));
buildAll();
assertOutput(a, fs().archive("a.jar").file("a.txt", "aaa").file("b.txt", "bbb"));
buildAllAndAssertUpToDate();
@@ -74,7 +74,7 @@ public class IncrementalArtifactBuildingTest extends ArtifactBuilderTestCase {
public void testRemoveDeletedFileFromArchive() {
String file1 = createFile("a.txt");
String file2 = createFile("b.txt");
final Artifact a = addArtifact("a", archive("a.jar").fileCopy(file1).fileCopy(file2));
final JpsArtifact a = addArtifact("a", archive("a.jar").fileCopy(file1).fileCopy(file2));
buildAll();
assertOutput(a, fs().archive("a.jar").file("a.txt").file("b.txt"));
@@ -87,8 +87,8 @@ public class IncrementalArtifactBuildingTest extends ArtifactBuilderTestCase {
public void testOneFileInTwoArtifacts() {
final String file = createFile("file.txt");
final Artifact a1 = addArtifact("a1", root().dir("dir").fileCopy(file));
final Artifact a2 = addArtifact("a2", root().dir("dir2").fileCopy(file));
final JpsArtifact a1 = addArtifact("a1", root().dir("dir").fileCopy(file));
final JpsArtifact a2 = addArtifact("a2", root().dir("dir2").fileCopy(file));
buildAll();
buildArtifacts(a1); assertUpToDate();
@@ -120,7 +120,7 @@ public class IncrementalArtifactBuildingTest extends ArtifactBuilderTestCase {
public void testRenameFile() throws Exception {
final String file = createFile("a/a.txt");
final Artifact a = addArtifact(root().dirCopy(PathUtil.getParentPath(file)));
final JpsArtifact a = addArtifact(root().dirCopy(PathUtil.getParentPath(file)));
buildAll();
assertOutput(a, fs().file("a.txt"));
@@ -132,7 +132,7 @@ public class IncrementalArtifactBuildingTest extends ArtifactBuilderTestCase {
//IDEADEV-25840
public void testUpdateFileIfCaseOfLetterInNameChanged() throws Exception {
final String file = createFile("a/a.txt");
final Artifact a = addArtifact("a", root().dirCopy(PathUtil.getParentPath(file)));
final JpsArtifact a = addArtifact("a", root().dirCopy(PathUtil.getParentPath(file)));
buildAll();
assertOutput(a, fs().file("a.txt"));
@@ -144,8 +144,8 @@ public class IncrementalArtifactBuildingTest extends ArtifactBuilderTestCase {
//IDEADEV-41556
public void testDeleteFilesFromSelectedArtifactsOnly() throws Exception {
final String file = createFile("a/a.txt");
final Artifact a1 = addArtifact("a1", root().dirCopy(PathUtil.getParentPath(file)));
final Artifact a2 = addArtifact("a2", root().dirCopy(PathUtil.getParentPath(file)));
final JpsArtifact a1 = addArtifact("a1", root().dirCopy(PathUtil.getParentPath(file)));
final JpsArtifact a2 = addArtifact("a2", root().dirCopy(PathUtil.getParentPath(file)));
buildAll();
assertOutput(a1, fs().file("a.txt"));
@@ -165,8 +165,8 @@ public class IncrementalArtifactBuildingTest extends ArtifactBuilderTestCase {
public void testTwoArtifactsWithSameOutput() throws Exception {
final String res1 = PathUtil.getParentPath(createFile("res1/a.txt", "1"));
final String res2 = PathUtil.getParentPath(createFile("res2/a.txt", "2"));
final Artifact a1 = addArtifact("a1", root().dirCopy(res1));
final Artifact a2 = addArtifact("a2", root().dirCopy(res2));
final JpsArtifact a1 = addArtifact("a1", root().dirCopy(res1));
final JpsArtifact a2 = addArtifact("a2", root().dirCopy(res2));
a2.setOutputPath(a1.getOutputPath());
assertEquals(a1.getOutputPath(), a2.getOutputPath());
@@ -16,48 +16,48 @@
package org.jetbrains.jps.incremental.artifacts;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.artifacts.*;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.elements.*;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.module.JpsModule;
import java.util.Collections;
/**
* @author nik
*/
public class LayoutElementTestUtil {
public static LayoutElementCreator root() {
return new LayoutElementCreator(new RootElement(Collections.<LayoutElement>emptyList()), null);
return new LayoutElementCreator(JpsPackagingElementFactory.getInstance().createArtifactRoot(), null);
}
public static LayoutElementCreator archive(String name) {
return new LayoutElementCreator(new ArchiveElement(name, Collections.<LayoutElement>emptyList()), null);
return new LayoutElementCreator(JpsPackagingElementFactory.getInstance().createArchive(name), null);
}
public static void addArtifactToLayout(Artifact main, Artifact included) {
final ArtifactLayoutElement element = new ArtifactLayoutElement();
element.setArtifactName(included.getName());
((CompositeLayoutElement)main.getRootElement()).getChildren().add(element);
public static void addArtifactToLayout(JpsArtifact main, JpsArtifact included) {
main.getRootElement().addChild(JpsPackagingElementFactory.getInstance().createArtifactOutput(included.createReference()));
}
public static class LayoutElementCreator {
private CompositeLayoutElement myElement;
private JpsPackagingElementFactory myFactory;
private JpsCompositePackagingElement myElement;
private LayoutElementCreator myParent;
public LayoutElementCreator(CompositeLayoutElement element, LayoutElementCreator parent) {
public LayoutElementCreator(JpsCompositePackagingElement element, LayoutElementCreator parent) {
myElement = element;
myParent = parent;
myFactory = JpsPackagingElementFactory.getInstance();
}
public LayoutElementCreator dir(String name) {
DirectoryElement dir = new DirectoryElement(name, Collections.<LayoutElement>emptyList());
myElement.getChildren().add(dir);
JpsDirectoryPackagingElement dir = myFactory.createDirectory(name);
myElement.addChild(dir);
return new LayoutElementCreator(dir, this);
}
public LayoutElementCreator archive(String name) {
ArchiveElement archive = new ArchiveElement(name, Collections.<LayoutElement>emptyList());
myElement.getChildren().add(archive);
JpsArchivePackagingElement archive = myFactory.createArchive(name);
myElement.addChild(archive);
return new LayoutElementCreator(archive, this);
}
@@ -66,49 +66,39 @@ public class LayoutElementTestUtil {
}
public LayoutElementCreator fileCopy(String filePath, @Nullable String outputFileName) {
return element(new FileCopyElement(filePath, outputFileName));
return element(myFactory.createFileCopy(filePath, outputFileName));
}
public LayoutElementCreator dirCopy(String dirPath) {
return element(new DirectoryCopyElement(dirPath));
return element(myFactory.createDirectoryCopy(dirPath));
}
public LayoutElementCreator module(JpsModule module) {
final ModuleOutputElement element = new ModuleOutputElement();
element.setModuleName(module.getName());
return element(element);
return element(JpsJavaExtensionService.getInstance().createProductionModuleOutput(module.createReference()));
}
public LayoutElementCreator element(LayoutElement element) {
myElement.getChildren().add(element);
public LayoutElementCreator element(JpsPackagingElement element) {
myElement.addChild(element);
return this;
}
public LayoutElementCreator lib(JpsLibrary library) {
final LibraryFilesElement element = new LibraryFilesElement();
element.setLibraryName(library.getName());
element.setLibraryLevel(LibraryFilesElement.PROJECT_LEVEL);
return element(element);
return element(myFactory.createLibraryElement(library.createReference()));
}
public LayoutElementCreator extractedDir(String jarPath, String pathInJar) {
ExtractedDirectoryElement dir = new ExtractedDirectoryElement();
dir.setJarPath(jarPath);
dir.setPathInJar(pathInJar);
return element(dir);
return element(myFactory.createExtractedDirectory(jarPath, pathInJar));
}
public LayoutElementCreator artifact(Artifact included) {
final ArtifactLayoutElement element = new ArtifactLayoutElement();
element.setArtifactName(included.getName());
return element(element);
public LayoutElementCreator artifact(JpsArtifact included) {
return element(myFactory.createArtifactOutput(included.createReference()));
}
public LayoutElementCreator end() {
return myParent;
}
public CompositeLayoutElement buildElement() {
public JpsCompositePackagingElement buildElement() {
if (myParent != null) {
return myParent.buildElement();
}
@@ -0,0 +1,8 @@
package org.jetbrains.jps.model.artifact;
/**
* @author nik
*/
public class DirectoryArtifactType extends JpsArtifactType {
public static final DirectoryArtifactType INSTANCE = new DirectoryArtifactType();
}
@@ -0,0 +1,8 @@
package org.jetbrains.jps.model.artifact;
/**
* @author nik
*/
public class JarArtifactType extends JpsArtifactType {
public static final JarArtifactType INSTANCE = new JarArtifactType();
}
@@ -0,0 +1,30 @@
package org.jetbrains.jps.model.artifact;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsCompositeElement;
import org.jetbrains.jps.model.JpsNamedElement;
import org.jetbrains.jps.model.JpsReferenceableElement;
import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
/**
* @author nik
*/
public interface JpsArtifact extends JpsNamedElement, JpsReferenceableElement<JpsArtifact>, JpsCompositeElement {
@NotNull
JpsArtifactType getArtifactType();
@Nullable
String getOutputPath();
void setOutputPath(@Nullable String outputPath);
@NotNull
JpsCompositePackagingElement getRootElement();
void setRootElement(@NotNull JpsCompositePackagingElement rootElement);
@NotNull
@Override
JpsArtifactReference createReference();
}
@@ -0,0 +1,16 @@
package org.jetbrains.jps.model.artifact;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsElementReference;
import org.jetbrains.jps.model.JpsModel;
/**
* @author nik
*/
public interface JpsArtifactReference extends JpsElementReference<JpsArtifact> {
@NotNull
String getArtifactName();
@Override
JpsArtifactReference asExternal(@NotNull JpsModel model);
}
@@ -0,0 +1,27 @@
package org.jetbrains.jps.model.artifact;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
import org.jetbrains.jps.service.JpsServiceManager;
import java.util.List;
/**
* @author nik
*/
public abstract class JpsArtifactService {
public static JpsArtifactService getInstance() {
return JpsServiceManager.getInstance().getService(JpsArtifactService.class);
}
public abstract List<JpsArtifact> getArtifacts(@NotNull JpsProject project);
public abstract JpsArtifact addArtifact(@NotNull JpsProject project,
@NotNull String name,
@NotNull JpsCompositePackagingElement rootElement,
@NotNull JpsArtifactType type);
public abstract JpsArtifactReference createReference(@NotNull String artifactName);
}
@@ -0,0 +1,14 @@
package org.jetbrains.jps.model.artifact;
import org.jetbrains.jps.model.DummyJpsElementProperties;
import org.jetbrains.jps.model.JpsElementType;
/**
* @author nik
*/
public abstract class JpsArtifactType extends JpsElementType<DummyJpsElementProperties> {
@Override
public DummyJpsElementProperties createCopy(DummyJpsElementProperties properties) {
return DummyJpsElementProperties.INSTANCE;
}
}
@@ -0,0 +1,10 @@
package org.jetbrains.jps.model.artifact.elements;
/**
* @author nik
*/
public interface JpsArchivePackagingElement extends JpsCompositePackagingElement {
String getArchiveName();
void setArchiveName(String directoryName);
}
@@ -0,0 +1,12 @@
package org.jetbrains.jps.model.artifact.elements;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.artifact.JpsArtifactReference;
/**
* @author nik
*/
public interface JpsArtifactOutputPackagingElement extends JpsComplexPackagingElement {
@NotNull
JpsArtifactReference getArtifactReference();
}
@@ -0,0 +1,7 @@
package org.jetbrains.jps.model.artifact.elements;
/**
* @author nik
*/
public interface JpsArtifactRootElement extends JpsCompositePackagingElement {
}
@@ -0,0 +1,10 @@
package org.jetbrains.jps.model.artifact.elements;
import java.util.List;
/**
* @author nik
*/
public interface JpsComplexPackagingElement extends JpsPackagingElement {
List<JpsPackagingElement> getSubstitution();
}
@@ -0,0 +1,15 @@
package org.jetbrains.jps.model.artifact.elements;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author nik
*/
public interface JpsCompositePackagingElement extends JpsPackagingElement {
@NotNull
List<JpsPackagingElement> getChildren();
<E extends JpsPackagingElement> E addChild(@NotNull E child);
}
@@ -0,0 +1,10 @@
package org.jetbrains.jps.model.artifact.elements;
/**
* @author nik
*/
public interface JpsDirectoryCopyPackagingElement extends JpsPackagingElement {
String getDirectoryPath();
void setDirectoryPath(String path);
}
@@ -0,0 +1,11 @@
package org.jetbrains.jps.model.artifact.elements;
/**
* @author nik
*/
public interface JpsDirectoryPackagingElement extends JpsCompositePackagingElement {
String getDirectoryName();
void setDirectoryName(String directoryName);
}
@@ -0,0 +1,14 @@
package org.jetbrains.jps.model.artifact.elements;
/**
* @author nik
*/
public interface JpsExtractedDirectoryPackagingElement extends JpsPackagingElement {
String getFilePath();
void setFilePath(String path);
String getPathInJar();
void setPathInJar(String pathInJar);
}
@@ -0,0 +1,15 @@
package org.jetbrains.jps.model.artifact.elements;
/**
* @author nik
*/
public interface JpsFileCopyPackagingElement extends JpsPackagingElement {
String getFilePath();
void setFilePath(String filePath);
String getRenamedOutputFileName();
void setRenamedOutputFileName(String renamedOutputFileName);
}
@@ -0,0 +1,12 @@
package org.jetbrains.jps.model.artifact.elements;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.library.JpsLibraryReference;
/**
* @author nik
*/
public interface JpsLibraryFilesPackagingElement extends JpsPackagingElement {
@NotNull
JpsLibraryReference getLibraryReference();
}
@@ -0,0 +1,16 @@
package org.jetbrains.jps.model.artifact.elements;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.module.JpsModuleReference;
/**
* @author nik
*/
public interface JpsModuleOutputPackagingElement extends JpsPackagingElement {
@NotNull
JpsModuleReference getModuleReference();
@Nullable
String getOutputUrl();
}
@@ -0,0 +1,9 @@
package org.jetbrains.jps.model.artifact.elements;
import org.jetbrains.jps.model.JpsElement;
/**
* @author nik
*/
public interface JpsPackagingElement extends JpsElement {
}
@@ -0,0 +1,43 @@
package org.jetbrains.jps.model.artifact.elements;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.artifact.JpsArtifactReference;
import org.jetbrains.jps.model.library.JpsLibraryReference;
import org.jetbrains.jps.service.JpsServiceManager;
/**
* @author nik
*/
public abstract class JpsPackagingElementFactory {
public static JpsPackagingElementFactory getInstance() {
return JpsServiceManager.getInstance().getService(JpsPackagingElementFactory.class);
}
@NotNull
public abstract JpsDirectoryCopyPackagingElement createDirectoryCopy(@NotNull String directoryPath);
public abstract JpsPackagingElement createParentDirectories(String path, JpsPackagingElement element);
@NotNull
public abstract JpsFileCopyPackagingElement createFileCopy(@NotNull String filePath, @Nullable String outputFileName);
@NotNull
public abstract JpsExtractedDirectoryPackagingElement createExtractedDirectory(@NotNull String jarPath, @NotNull String pathInJar);
@NotNull
public abstract JpsDirectoryPackagingElement createDirectory(@NotNull String directoryName);
@NotNull
public abstract JpsArchivePackagingElement createArchive(@NotNull String archiveName);
@NotNull
public abstract JpsArtifactRootElement createArtifactRoot();
@NotNull
public abstract JpsLibraryFilesPackagingElement createLibraryElement(@NotNull JpsLibraryReference reference);
@NotNull
public abstract JpsArtifactOutputPackagingElement createArtifactOutput(@NotNull JpsArtifactReference reference);
}
@@ -6,6 +6,7 @@ import org.jetbrains.jps.model.JpsElementKind;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.module.JpsDependencyElement;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsModuleReference;
import org.jetbrains.jps.service.JpsServiceManager;
import java.util.List;
@@ -14,6 +15,12 @@ import java.util.List;
* @author nik
*/
public abstract class JpsJavaExtensionService {
@NotNull
public abstract JpsProductionModuleOutputPackagingElement createProductionModuleOutput(@NotNull JpsModuleReference moduleReference);
@NotNull
public abstract JpsTestModuleOutputPackagingElement createTestModuleOutput(@NotNull JpsModuleReference moduleReference);
public static JpsJavaExtensionService getInstance() {
return JpsServiceManager.getInstance().getService(JpsJavaExtensionService.class);
}
@@ -0,0 +1,9 @@
package org.jetbrains.jps.model.java;
import org.jetbrains.jps.model.artifact.elements.JpsModuleOutputPackagingElement;
/**
* @author nik
*/
public interface JpsProductionModuleOutputPackagingElement extends JpsModuleOutputPackagingElement {
}
@@ -0,0 +1,9 @@
package org.jetbrains.jps.model.java;
import org.jetbrains.jps.model.artifact.elements.JpsModuleOutputPackagingElement;
/**
* @author nik
*/
public interface JpsTestModuleOutputPackagingElement extends JpsModuleOutputPackagingElement {
}
@@ -5,6 +5,7 @@ import org.jetbrains.jps.model.JpsElementProperties;
import org.jetbrains.jps.model.JpsNamedElement;
import org.jetbrains.jps.model.JpsReferenceableElement;
import java.io.File;
import java.util.List;
/**
@@ -31,4 +32,6 @@ public interface JpsLibrary extends JpsNamedElement, JpsReferenceableElement<Jps
@NotNull
JpsElementProperties getProperties();
List<File> getFiles(final JpsOrderRootType rootType);
}
@@ -0,0 +1 @@
org.jetbrains.jps.model.artifact.impl.JpsArtifactServiceImpl
@@ -0,0 +1 @@
org.jetbrains.jps.model.artifact.impl.elements.JpsPackagingElementFactoryImpl
@@ -1,6 +1,7 @@
package org.jetbrains.jps;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
@@ -59,7 +60,7 @@ public class JpsPathUtil {
}
public static File urlToFile(String url) {
return new File(FileUtil.toSystemDependentName(urlToPath(url)));
return new File(FileUtilRt.toSystemDependentName(urlToPath(url)));
}
public static String urlToPath(String url) {
@@ -0,0 +1,74 @@
package org.jetbrains.jps.model.artifact.impl;
import com.intellij.openapi.util.Comparing;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.DummyJpsElementProperties;
import org.jetbrains.jps.model.JpsElementKind;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.JpsArtifactType;
import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
import org.jetbrains.jps.model.impl.JpsElementKindBase;
import org.jetbrains.jps.model.impl.JpsNamedCompositeElementBase;
import org.jetbrains.jps.model.impl.JpsTypedDataImpl;
import org.jetbrains.jps.model.impl.JpsTypedDataKind;
/**
* @author nik
*/
public class JpsArtifactImpl extends JpsNamedCompositeElementBase<JpsArtifactImpl> implements JpsArtifact {
private static final JpsElementKind<JpsCompositePackagingElement> ROOT_ELEMENT_KIND = new JpsElementKindBase<JpsCompositePackagingElement>("root element");
private static final JpsTypedDataKind<JpsArtifactType> TYPED_DATA_KIND = new JpsTypedDataKind<JpsArtifactType>();
private String myOutputPath;
public JpsArtifactImpl(@NotNull String name, @NotNull JpsCompositePackagingElement rootElement, @NotNull JpsArtifactType type) {
super(name);
myContainer.setChild(ROOT_ELEMENT_KIND, rootElement);
myContainer.setChild(TYPED_DATA_KIND, new JpsTypedDataImpl<JpsArtifactType>(type, DummyJpsElementProperties.INSTANCE));
}
private JpsArtifactImpl(JpsArtifactImpl original) {
super(original);
myOutputPath = original.myOutputPath;
}
@NotNull
@Override
public JpsArtifactImpl createCopy() {
return new JpsArtifactImpl(this);
}
public String getOutputPath() {
return myOutputPath;
}
public void setOutputPath(@Nullable String outputPath) {
if (!Comparing.equal(myOutputPath, outputPath)) {
myOutputPath = outputPath;
fireElementChanged();
}
}
@NotNull
@Override
public JpsArtifactType getArtifactType() {
return myContainer.getChild(TYPED_DATA_KIND).getType();
}
@NotNull
@Override
public JpsArtifactReferenceImpl createReference() {
return new JpsArtifactReferenceImpl(getName());
}
@NotNull
@Override
public JpsCompositePackagingElement getRootElement() {
return myContainer.getChild(ROOT_ELEMENT_KIND);
}
@Override
public void setRootElement(@NotNull JpsCompositePackagingElement rootElement) {
myContainer.setChild(ROOT_ELEMENT_KIND, rootElement);
}
}
@@ -0,0 +1,17 @@
package org.jetbrains.jps.model.artifact.impl;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.impl.JpsElementCollectionKind;
import org.jetbrains.jps.model.impl.JpsElementKindBase;
/**
* @author nik
*/
public class JpsArtifactKind extends JpsElementKindBase<JpsArtifact> {
public static final JpsArtifactKind INSTANCE = new JpsArtifactKind();
public static final JpsElementCollectionKind<JpsArtifact> ARTIFACT_COLLECTION_KIND = new JpsElementCollectionKind<JpsArtifact>(INSTANCE);
public JpsArtifactKind() {
super("artifact");
}
}
@@ -0,0 +1,39 @@
package org.jetbrains.jps.model.artifact.impl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsElementFactory;
import org.jetbrains.jps.model.JpsModel;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.JpsArtifactReference;
import org.jetbrains.jps.model.impl.JpsNamedElementReferenceBase;
/**
* @author nik
*/
public class JpsArtifactReferenceImpl extends JpsNamedElementReferenceBase<JpsArtifact,JpsArtifactReferenceImpl> implements JpsArtifactReference {
public JpsArtifactReferenceImpl(@NotNull String artifactName) {
super(JpsArtifactKind.ARTIFACT_COLLECTION_KIND, artifactName, JpsElementFactory.getInstance().createProjectReference());
}
private JpsArtifactReferenceImpl(JpsArtifactReferenceImpl original) {
super(original);
}
@NotNull
@Override
public JpsArtifactReferenceImpl createCopy() {
return new JpsArtifactReferenceImpl(this);
}
@NotNull
@Override
public String getArtifactName() {
return myElementName;
}
@Override
public JpsArtifactReferenceImpl asExternal(@NotNull JpsModel model) {
model.registerExternalReference(this);
return this;
}
}
@@ -0,0 +1,36 @@
package org.jetbrains.jps.model.artifact.impl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.JpsArtifactReference;
import org.jetbrains.jps.model.artifact.JpsArtifactService;
import org.jetbrains.jps.model.artifact.JpsArtifactType;
import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
import org.jetbrains.jps.model.impl.JpsElementCollectionImpl;
import java.util.Collections;
import java.util.List;
/**
* @author nik
*/
public class JpsArtifactServiceImpl extends JpsArtifactService {
@Override
public List<JpsArtifact> getArtifacts(@NotNull JpsProject project) {
JpsElementCollectionImpl<JpsArtifact> collection = project.getContainer().getChild(JpsArtifactKind.ARTIFACT_COLLECTION_KIND);
return collection != null ? collection.getElements() : Collections.<JpsArtifact>emptyList();
}
@Override
public JpsArtifact addArtifact(@NotNull JpsProject project, @NotNull String name, @NotNull JpsCompositePackagingElement rootElement,
@NotNull JpsArtifactType type) {
JpsArtifact artifact = new JpsArtifactImpl(name, rootElement, type);
return project.getContainer().getOrSetChild(JpsArtifactKind.ARTIFACT_COLLECTION_KIND).addChild(artifact);
}
@Override
public JpsArtifactReference createReference(@NotNull String artifactName) {
return new JpsArtifactReferenceImpl(artifactName);
}
}
@@ -0,0 +1,40 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.artifact.elements.JpsArchivePackagingElement;
/**
* @author nik
*/
public class JpsArchivePackagingElementImpl extends JpsCompositePackagingElementBase<JpsArchivePackagingElementImpl>
implements JpsArchivePackagingElement {
private String myArchiveName;
public JpsArchivePackagingElementImpl(String archiveName) {
myArchiveName = archiveName;
}
private JpsArchivePackagingElementImpl(JpsArchivePackagingElementImpl original) {
super(original);
myArchiveName = original.myArchiveName;
}
@NotNull
@Override
public JpsArchivePackagingElementImpl createCopy() {
return new JpsArchivePackagingElementImpl(this);
}
@Override
public String getArchiveName() {
return myArchiveName;
}
@Override
public void setArchiveName(String directoryName) {
if (!myArchiveName.equals(directoryName)) {
myArchiveName = directoryName;
fireElementChanged();
}
}
}
@@ -0,0 +1,56 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsElementKind;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.JpsArtifactReference;
import org.jetbrains.jps.model.artifact.elements.JpsArtifactOutputPackagingElement;
import org.jetbrains.jps.model.artifact.elements.JpsArtifactRootElement;
import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
import org.jetbrains.jps.model.artifact.elements.JpsPackagingElement;
import org.jetbrains.jps.model.impl.JpsElementKindBase;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author nik
*/
public class JpsArtifactOutputPackagingElementImpl extends JpsComplexPackagingElementBase<JpsArtifactOutputPackagingElementImpl>
implements JpsArtifactOutputPackagingElement {
private static final JpsElementKind<JpsArtifactReference> ARTIFACT_REFERENCE_KIND = new JpsElementKindBase<JpsArtifactReference>("artifact reference");
public JpsArtifactOutputPackagingElementImpl(@NotNull JpsArtifactReference reference) {
myContainer.setChild(ARTIFACT_REFERENCE_KIND, reference);
}
private JpsArtifactOutputPackagingElementImpl(JpsArtifactOutputPackagingElementImpl original) {
super(original);
}
@NotNull
@Override
public JpsArtifactOutputPackagingElementImpl createCopy() {
return new JpsArtifactOutputPackagingElementImpl(this);
}
@Override
@NotNull
public JpsArtifactReference getArtifactReference() {
return myContainer.getChild(ARTIFACT_REFERENCE_KIND);
}
@Override
public List<JpsPackagingElement> getSubstitution() {
JpsArtifact artifact = getArtifactReference().resolve();
if (artifact == null) return Collections.emptyList();
JpsCompositePackagingElement rootElement = artifact.getRootElement();
if (rootElement instanceof JpsArtifactRootElement) {
return new ArrayList<JpsPackagingElement>(rootElement.getChildren());
}
else {
return Collections.<JpsPackagingElement>singletonList(rootElement);
}
}
}
@@ -0,0 +1,22 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.artifact.elements.JpsArtifactRootElement;
/**
* @author nik
*/
public class JpsArtifactRootElementImpl extends JpsCompositePackagingElementBase<JpsArtifactRootElementImpl> implements JpsArtifactRootElement {
public JpsArtifactRootElementImpl() {
}
private JpsArtifactRootElementImpl(JpsArtifactRootElementImpl original) {
super(original);
}
@NotNull
@Override
public JpsArtifactRootElementImpl createCopy() {
return new JpsArtifactRootElementImpl();
}
}
@@ -0,0 +1,17 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import org.jetbrains.jps.model.artifact.elements.JpsComplexPackagingElement;
import org.jetbrains.jps.model.impl.JpsCompositeElementBase;
/**
* @author nik
*/
public abstract class JpsComplexPackagingElementBase<Self extends JpsComplexPackagingElementBase<Self>> extends JpsCompositeElementBase<Self> implements
JpsComplexPackagingElement {
protected JpsComplexPackagingElementBase() {
}
protected JpsComplexPackagingElementBase(JpsComplexPackagingElementBase<Self> original) {
super(original);
}
}
@@ -0,0 +1,38 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
import org.jetbrains.jps.model.artifact.elements.JpsPackagingElement;
import org.jetbrains.jps.model.impl.JpsCompositeElementBase;
import org.jetbrains.jps.model.impl.JpsElementCollectionKind;
import org.jetbrains.jps.model.impl.JpsElementKindBase;
import java.util.List;
/**
* @author nik
*/
public abstract class JpsCompositePackagingElementBase<Self extends JpsCompositePackagingElementBase<Self>> extends JpsCompositeElementBase<Self>
implements JpsCompositePackagingElement {
private static final JpsElementCollectionKind<JpsPackagingElement> CHILDREN_KIND = new JpsElementCollectionKind<JpsPackagingElement>(new JpsElementKindBase<JpsPackagingElement>("child"));
protected JpsCompositePackagingElementBase() {
myContainer.setChild(CHILDREN_KIND);
}
protected JpsCompositePackagingElementBase(JpsCompositePackagingElementBase<Self> original) {
super(original);
}
@NotNull
@Override
public List<JpsPackagingElement> getChildren() {
return myContainer.getChild(CHILDREN_KIND).getElements();
}
@Override
public <E extends JpsPackagingElement> E addChild(@NotNull E child) {
return myContainer.getChild(CHILDREN_KIND).addChild(child);
}
}
@@ -0,0 +1,30 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.artifact.elements.JpsDirectoryCopyPackagingElement;
/**
* @author nik
*/
public class JpsDirectoryCopyPackagingElementImpl extends JpsFileCopyPackagingElementBase<JpsDirectoryCopyPackagingElementImpl>
implements JpsDirectoryCopyPackagingElement {
public JpsDirectoryCopyPackagingElementImpl(String directoryPath) {
super(directoryPath);
}
@NotNull
@Override
public JpsDirectoryCopyPackagingElementImpl createCopy() {
return new JpsDirectoryCopyPackagingElementImpl(myFilePath);
}
@Override
public String getDirectoryPath() {
return getFilePath();
}
@Override
public void setDirectoryPath(String path) {
setFilePath(path);
}
}
@@ -0,0 +1,39 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.artifact.elements.JpsDirectoryPackagingElement;
/**
* @author nik
*/
public class JpsDirectoryPackagingElementImpl extends JpsCompositePackagingElementBase<JpsDirectoryPackagingElementImpl> implements JpsDirectoryPackagingElement {
private String myDirectoryName;
public JpsDirectoryPackagingElementImpl(String directoryName) {
myDirectoryName = directoryName;
}
private JpsDirectoryPackagingElementImpl(JpsDirectoryPackagingElementImpl original) {
super(original);
myDirectoryName = original.myDirectoryName;
}
@NotNull
@Override
public JpsDirectoryPackagingElementImpl createCopy() {
return new JpsDirectoryPackagingElementImpl(this);
}
@Override
public String getDirectoryName() {
return myDirectoryName;
}
@Override
public void setDirectoryName(String directoryName) {
if (!myDirectoryName.equals(directoryName)) {
myDirectoryName = directoryName;
fireElementChanged();
}
}
}
@@ -0,0 +1,43 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import com.intellij.openapi.util.Comparing;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.artifact.elements.JpsExtractedDirectoryPackagingElement;
/**
* @author nik
*/
public class JpsExtractedDirectoryPackagingElementImpl extends JpsFileCopyPackagingElementBase<JpsExtractedDirectoryPackagingElementImpl>
implements JpsExtractedDirectoryPackagingElement {
private String myPathInJar;
public JpsExtractedDirectoryPackagingElementImpl(String filePath, String pathInJar) {
super(filePath);
myPathInJar = pathInJar;
}
@NotNull
@Override
public JpsExtractedDirectoryPackagingElementImpl createCopy() {
return new JpsExtractedDirectoryPackagingElementImpl(myFilePath, myPathInJar);
}
@Override
public void applyChanges(@NotNull JpsExtractedDirectoryPackagingElementImpl modified) {
super.applyChanges(modified);
setPathInJar(modified.myPathInJar);
}
@Override
public String getPathInJar() {
return myPathInJar;
}
@Override
public void setPathInJar(String pathInJar) {
if (!Comparing.equal(myPathInJar, pathInJar)) {
myPathInJar = pathInJar;
fireElementChanged();
}
}
}
@@ -0,0 +1,34 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import com.intellij.openapi.util.Comparing;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.artifact.elements.JpsPackagingElement;
import org.jetbrains.jps.model.impl.JpsElementBase;
/**
* @author nik
*/
public abstract class JpsFileCopyPackagingElementBase<Self extends JpsFileCopyPackagingElementBase<Self>> extends JpsElementBase<Self> implements
JpsPackagingElement {
protected String myFilePath;
public JpsFileCopyPackagingElementBase(String filePath) {
myFilePath = filePath;
}
@Override
public void applyChanges(@NotNull Self modified) {
setFilePath(modified.myFilePath);
}
public String getFilePath() {
return myFilePath;
}
public void setFilePath(String filePath) {
if (!Comparing.equal(myFilePath, filePath)) {
myFilePath = filePath;
fireElementChanged();
}
}
}
@@ -0,0 +1,42 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import com.intellij.openapi.util.Comparing;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.artifact.elements.JpsFileCopyPackagingElement;
/**
* @author nik
*/
public class JpsFileCopyPackagingElementImpl extends JpsFileCopyPackagingElementBase<JpsFileCopyPackagingElementImpl> implements JpsFileCopyPackagingElement {
private String myRenamedOutputFileName;
public JpsFileCopyPackagingElementImpl(String filePath, String renamedOutputFileName) {
super(filePath);
myRenamedOutputFileName = renamedOutputFileName;
}
@NotNull
@Override
public JpsFileCopyPackagingElementImpl createCopy() {
return new JpsFileCopyPackagingElementImpl(myFilePath, myRenamedOutputFileName);
}
@Override
public void applyChanges(@NotNull JpsFileCopyPackagingElementImpl modified) {
super.applyChanges(modified);
setRenamedOutputFileName(modified.myRenamedOutputFileName);
}
@Override
public String getRenamedOutputFileName() {
return myRenamedOutputFileName;
}
@Override
public void setRenamedOutputFileName(String renamedOutputFileName) {
if (!Comparing.equal(myRenamedOutputFileName, renamedOutputFileName)) {
myRenamedOutputFileName = renamedOutputFileName;
fireElementChanged();
}
}
}
@@ -0,0 +1,61 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsElementKind;
import org.jetbrains.jps.model.artifact.elements.JpsLibraryFilesPackagingElement;
import org.jetbrains.jps.model.artifact.elements.JpsPackagingElement;
import org.jetbrains.jps.model.artifact.elements.JpsPackagingElementFactory;
import org.jetbrains.jps.model.impl.JpsElementKindBase;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsLibraryReference;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author nik
*/
public class JpsLibraryFilesPackagingElementImpl extends JpsComplexPackagingElementBase<JpsLibraryFilesPackagingElementImpl> implements JpsLibraryFilesPackagingElement {
private static final JpsElementKind<JpsLibraryReference> LIBRARY_REFERENCE_KIND = new JpsElementKindBase<JpsLibraryReference>("library reference");
public JpsLibraryFilesPackagingElementImpl(@NotNull JpsLibraryReference reference) {
myContainer.setChild(LIBRARY_REFERENCE_KIND, reference);
}
private JpsLibraryFilesPackagingElementImpl(JpsLibraryFilesPackagingElementImpl original) {
super(original);
}
@NotNull
@Override
public JpsLibraryFilesPackagingElementImpl createCopy() {
return new JpsLibraryFilesPackagingElementImpl(this);
}
@Override
@NotNull
public JpsLibraryReference getLibraryReference() {
return myContainer.getChild(LIBRARY_REFERENCE_KIND);
}
@Override
public List<JpsPackagingElement> getSubstitution() {
JpsLibrary library = getLibraryReference().resolve();
if (library == null) return Collections.emptyList();
List<JpsPackagingElement> result = new ArrayList<JpsPackagingElement>();
for (File file : library.getFiles(JpsOrderRootType.COMPILED)) {
String path = FileUtil.toSystemIndependentName(file.getAbsolutePath());
if (file.isDirectory()) {
result.add(JpsPackagingElementFactory.getInstance().createDirectoryCopy(path));
}
else {
result.add(JpsPackagingElementFactory.getInstance().createFileCopy(path, null));
}
}
return result;
}
}
@@ -0,0 +1,43 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsElementKind;
import org.jetbrains.jps.model.artifact.elements.JpsModuleOutputPackagingElement;
import org.jetbrains.jps.model.impl.JpsCompositeElementBase;
import org.jetbrains.jps.model.impl.JpsElementKindBase;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsModuleReference;
/**
* @author nik
*/
public abstract class JpsModuleOutputPackagingElementBase<Self extends JpsModuleOutputPackagingElementBase<Self>> extends JpsCompositeElementBase<Self> implements
JpsModuleOutputPackagingElement {
private static final JpsElementKind<JpsModuleReference> MODULE_REFERENCE_KIND = new JpsElementKindBase<JpsModuleReference>("module reference");
public JpsModuleOutputPackagingElementBase(JpsModuleReference moduleReference) {
myContainer.setChild(MODULE_REFERENCE_KIND, moduleReference);
}
public JpsModuleOutputPackagingElementBase(JpsModuleOutputPackagingElementBase<Self> original) {
super(original);
}
@Override
@NotNull
public JpsModuleReference getModuleReference() {
return myContainer.getChild(MODULE_REFERENCE_KIND);
}
@Override
@Nullable
public String getOutputUrl() {
JpsModule module = getModuleReference().resolve();
if (module == null) return null;
return getOutputUrl(module);
}
@Nullable
protected abstract String getOutputUrl(@NotNull JpsModule module);
}
@@ -0,0 +1,95 @@
package org.jetbrains.jps.model.artifact.impl.elements;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.artifact.JpsArtifactReference;
import org.jetbrains.jps.model.artifact.elements.*;
import org.jetbrains.jps.model.library.JpsLibraryReference;
/**
* @author nik
*/
public class JpsPackagingElementFactoryImpl extends JpsPackagingElementFactory {
@Override
@NotNull
public JpsDirectoryCopyPackagingElement createDirectoryCopy(@NotNull String directoryPath) {
return new JpsDirectoryCopyPackagingElementImpl(directoryPath);
}
@Override
public JpsPackagingElement createParentDirectories(String relativeOutputPath, JpsPackagingElement element) {
relativeOutputPath = StringUtil.trimStart(relativeOutputPath, "/");
if (relativeOutputPath.length() == 0) {
return element;
}
int slash = relativeOutputPath.indexOf('/');
if (slash == -1) slash = relativeOutputPath.length();
String rootName = relativeOutputPath.substring(0, slash);
String pathTail = relativeOutputPath.substring(slash);
final JpsDirectoryPackagingElement root = createDirectory(rootName);
final JpsCompositePackagingElement last = getOrCreateDirectoryOrArchive(root, pathTail, true);
last.addChild(element);
return root;
}
@NotNull
private JpsCompositePackagingElement getOrCreateDirectoryOrArchive(@NotNull JpsCompositePackagingElement root,
@NotNull @NonNls String path, final boolean directory) {
path = StringUtil.trimStart(StringUtil.trimEnd(path, "/"), "/");
if (path.length() == 0) {
return root;
}
int index = path.lastIndexOf('/');
String lastName = path.substring(index + 1);
String parentPath = index != -1 ? path.substring(0, index) : "";
final JpsCompositePackagingElement parent = getOrCreateDirectoryOrArchive(root, parentPath, true);
final JpsCompositePackagingElement last = directory ? createDirectory(lastName) : createArchive(lastName);
return parent.addChild(last);
}
@Override
@NotNull
public JpsFileCopyPackagingElement createFileCopy(@NotNull String filePath, @Nullable String outputFileName) {
return new JpsFileCopyPackagingElementImpl(filePath, outputFileName);
}
@Override
@NotNull
public JpsExtractedDirectoryPackagingElement createExtractedDirectory(@NotNull String jarPath, @NotNull String pathInJar) {
return new JpsExtractedDirectoryPackagingElementImpl(jarPath, pathInJar);
}
@Override
@NotNull
public JpsDirectoryPackagingElement createDirectory(@NotNull String directoryName) {
return new JpsDirectoryPackagingElementImpl(directoryName);
}
@Override
@NotNull
public JpsArchivePackagingElement createArchive(@NotNull String archiveName) {
return new JpsArchivePackagingElementImpl(archiveName);
}
@Override
@NotNull
public JpsArtifactRootElement createArtifactRoot() {
return new JpsArtifactRootElementImpl();
}
@Override
@NotNull
public JpsLibraryFilesPackagingElement createLibraryElement(@NotNull JpsLibraryReference reference) {
return new JpsLibraryFilesPackagingElementImpl(reference);
}
@Override
@NotNull
public JpsArtifactOutputPackagingElement createArtifactOutput(@NotNull JpsArtifactReference reference) {
return new JpsArtifactOutputPackagingElementImpl(reference);
}
}
@@ -8,6 +8,7 @@ import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.java.*;
import org.jetbrains.jps.model.module.JpsDependencyElement;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsModuleReference;
import org.jetbrains.jps.model.module.JpsModuleSourceRoot;
import java.util.ArrayList;
@@ -123,4 +124,16 @@ public class JpsJavaExtensionServiceImpl extends JpsJavaExtensionService {
}
return null;
}
@Override
@NotNull
public JpsProductionModuleOutputPackagingElement createProductionModuleOutput(@NotNull JpsModuleReference moduleReference) {
return new JpsProductionModuleOutputPackagingElementImpl(moduleReference);
}
@Override
@NotNull
public JpsTestModuleOutputPackagingElement createTestModuleOutput(@NotNull JpsModuleReference moduleReference) {
return new JpsTestModuleOutputPackagingElementImpl(moduleReference);
}
}
@@ -0,0 +1,33 @@
package org.jetbrains.jps.model.java.impl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.artifact.impl.elements.JpsModuleOutputPackagingElementBase;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.java.JpsProductionModuleOutputPackagingElement;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsModuleReference;
/**
* @author nik
*/
public class JpsProductionModuleOutputPackagingElementImpl extends JpsModuleOutputPackagingElementBase<JpsProductionModuleOutputPackagingElementImpl>
implements JpsProductionModuleOutputPackagingElement {
public JpsProductionModuleOutputPackagingElementImpl(JpsModuleReference moduleReference) {
super(moduleReference);
}
private JpsProductionModuleOutputPackagingElementImpl(JpsProductionModuleOutputPackagingElementImpl original) {
super(original);
}
@NotNull
@Override
public JpsProductionModuleOutputPackagingElementImpl createCopy() {
return new JpsProductionModuleOutputPackagingElementImpl(this);
}
@Override
protected String getOutputUrl(@NotNull JpsModule module) {
return JpsJavaExtensionService.getInstance().getOutputUrl(module, false);
}
}
@@ -0,0 +1,33 @@
package org.jetbrains.jps.model.java.impl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.artifact.impl.elements.JpsModuleOutputPackagingElementBase;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.java.JpsTestModuleOutputPackagingElement;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsModuleReference;
/**
* @author nik
*/
public class JpsTestModuleOutputPackagingElementImpl extends JpsModuleOutputPackagingElementBase<JpsTestModuleOutputPackagingElementImpl>
implements JpsTestModuleOutputPackagingElement {
public JpsTestModuleOutputPackagingElementImpl(JpsModuleReference moduleReference) {
super(moduleReference);
}
private JpsTestModuleOutputPackagingElementImpl(JpsTestModuleOutputPackagingElementImpl original) {
super(original);
}
@NotNull
@Override
public JpsTestModuleOutputPackagingElementImpl createCopy() {
return new JpsTestModuleOutputPackagingElementImpl(this);
}
@Override
protected String getOutputUrl(@NotNull JpsModule module) {
return JpsJavaExtensionService.getInstance().getOutputUrl(module, true);
}
}
@@ -1,10 +1,15 @@
package org.jetbrains.jps.model.library.impl;
import com.intellij.openapi.util.io.FileUtilRt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.JpsPathUtil;
import org.jetbrains.jps.model.*;
import org.jetbrains.jps.model.impl.*;
import org.jetbrains.jps.model.library.*;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -94,4 +99,41 @@ public class JpsLibraryImpl<P extends JpsElementProperties> extends JpsNamedComp
((JpsReferenceableElement<JpsCompositeElement>)getParent().getParent()).createReference();
return new JpsLibraryReferenceImpl(getName(), parentReference);
}
@Override
public List<File> getFiles(final JpsOrderRootType rootType) {
List<File> files = new ArrayList<File>();
for (JpsLibraryRoot root : getRoots(rootType)) {
final File file = JpsPathUtil.urlToFile(root.getUrl());
switch (root.getInclusionOptions()) {
case ROOT_ITSELF:
files.add(file);
break;
case ARCHIVES_UNDER_ROOT:
collectArchives(file, false, files);
break;
case ARCHIVES_UNDER_ROOT_RECURSIVELY:
collectArchives(file, true, files);
break;
}
}
return files;
}
private static void collectArchives(File file, boolean recursively, Collection<File> result) {
final File[] children = file.listFiles();
if (children != null) {
for (File child : children) {
final String extension = FileUtilRt.getExtension(child.getName());
if (child.isDirectory()) {
if (recursively) {
collectArchives(child, recursively, result);
}
}
else if (extension.equals("jar") || extension.equals("zip")) {
result.add(child);
}
}
}
}
}
@@ -6,9 +6,11 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsCompositeElement;
import org.jetbrains.jps.model.JpsElementReference;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.artifact.JpsArtifactType;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.module.JpsDependencyElement;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.serialization.artifact.JpsPackagingElementLoader;
import org.jetbrains.jps.model.serialization.facet.JpsModuleExtensionLoader;
import java.util.Collections;
@@ -57,8 +59,17 @@ public abstract class JpsModelLoaderExtension {
return Collections.emptyList();
}
public List<? extends JpsPackagingElementLoader<?>> getPackagingElementLoaders() {
return Collections.emptyList();
}
@Nullable
public JpsOrderRootType getSdkRootType(@NotNull String typeId) {
return null;
}
@Nullable
public JpsArtifactType getArtifactType(@NotNull String typeId) {
return null;
}
}
@@ -93,7 +93,7 @@ public class JpsModuleLoader {
}
}
private static JpsElementReference<? extends JpsCompositeElement> createLibraryTableReference(String level) {
public static JpsElementReference<? extends JpsCompositeElement> createLibraryTableReference(String level) {
JpsElementFactory elementFactory = JpsElementFactory.getInstance();
if (level.equals("project")) {
return elementFactory.createProjectReference();
@@ -2,6 +2,7 @@ package org.jetbrains.jps.model.serialization;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.ArrayUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -12,10 +13,12 @@ import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.java.JpsJavaModuleType;
import org.jetbrains.jps.model.library.JpsSdkType;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.serialization.artifact.JpsArtifactLoader;
import org.jetbrains.jps.model.serialization.facet.JpsFacetLoader;
import org.jetbrains.jps.service.JpsServiceManager;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -68,14 +71,23 @@ public class JpsProjectLoader extends JpsLoaderBase {
private void loadFromDirectory(File dir) {
JpsSdkType<?> projectSdkType = loadProjectRoot(loadRootElement(new File(dir, "misc.xml")));
loadModules(loadRootElement(new File(dir, "modules.xml")), projectSdkType);
final File[] libraryFiles = new File(dir, "libraries").listFiles();
if (libraryFiles != null) {
for (File libraryFile : libraryFiles) {
if (isXmlFile(libraryFile)) {
loadProjectLibraries(loadRootElement(libraryFile));
}
}
for (File libraryFile : listXmlFiles(new File(dir, "libraries"))) {
loadProjectLibraries(loadRootElement(libraryFile));
}
for (File artifactFile : listXmlFiles(new File(dir, "artifacts"))) {
loadArtifacts(loadRootElement(artifactFile));
}
}
@NotNull
private static File[] listXmlFiles(final File dir) {
File[] files = dir.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return isXmlFile(file);
}
});
return files != null ? files : ArrayUtil.EMPTY_FILE_ARRAY;
}
private void loadFromIpr(File iprFile) {
@@ -83,6 +95,11 @@ public class JpsProjectLoader extends JpsLoaderBase {
JpsSdkType<?> projectSdkType = loadProjectRoot(root);
loadModules(root, projectSdkType);
loadProjectLibraries(findComponent(root, "libraryTable"));
loadArtifacts(findComponent(root, "ArtifactManager"));
}
private void loadArtifacts(Element artifactManagerComponent) {
JpsArtifactLoader.loadArtifacts(myProject, artifactManagerComponent);
}
@Nullable
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.packaging.impl.artifacts;
package org.jetbrains.jps.model.serialization.artifact;
import com.intellij.util.xmlb.annotations.AbstractCollection;
import com.intellij.util.xmlb.annotations.Property;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.packaging.impl.artifacts;
package org.jetbrains.jps.model.serialization.artifact;
import com.intellij.util.xmlb.annotations.Attribute;
import com.intellij.util.xmlb.annotations.Tag;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.packaging.impl.artifacts;
package org.jetbrains.jps.model.serialization.artifact;
import com.intellij.util.xmlb.annotations.Attribute;
import com.intellij.util.xmlb.annotations.Tag;
@@ -33,7 +33,7 @@ public class ArtifactState {
@NonNls public static final String NAME_ATTRIBUTE = "name";
private String myName;
private String myOutputPath;
private String myArtifactType = PlainArtifactType.ID;
private String myArtifactType;
private boolean myBuildOnMake;
private Element myRootElement;
private List<ArtifactPropertiesState> myPropertiesList = new ArrayList<ArtifactPropertiesState>();
@@ -0,0 +1,136 @@
package org.jetbrains.jps.model.serialization.artifact;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.util.xmlb.XmlSerializer;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsCompositeElement;
import org.jetbrains.jps.model.JpsElementFactory;
import org.jetbrains.jps.model.JpsElementReference;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.artifact.*;
import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
import org.jetbrains.jps.model.artifact.elements.JpsPackagingElement;
import org.jetbrains.jps.model.artifact.elements.JpsPackagingElementFactory;
import org.jetbrains.jps.model.serialization.JpsModelLoaderExtension;
import org.jetbrains.jps.model.serialization.JpsModuleLoader;
import org.jetbrains.jps.service.JpsServiceManager;
import java.util.Arrays;
import java.util.List;
/**
* @author nik
*/
public class JpsArtifactLoader {
private static List<? extends JpsPackagingElementLoader<?>> STANDARD_LOADERS = Arrays.asList();
public static void loadArtifacts(@NotNull JpsProject project, @Nullable Element componentElement) {
JpsArtifactService service = JpsArtifactService.getInstance();
for (Element artifactElement : JDOMUtil.getChildren(componentElement, "artifact")) {
ArtifactState state = XmlSerializer.deserialize(artifactElement, ArtifactState.class);
if (state == null) continue;
JpsArtifactType artifactType = getArtifactType(state.getArtifactType());
JpsPackagingElement rootElement = loadPackagingElement(state.getRootElement());
if (rootElement != null) {
JpsArtifact artifact = service.addArtifact(project, state.getName(), (JpsCompositePackagingElement)rootElement, artifactType);
artifact.setOutputPath(state.getOutputPath());
}
}
}
@Nullable
private static JpsPackagingElement loadPackagingElement(Element element) {
JpsPackagingElement packagingElement = createPackagingElement(element);
if (packagingElement instanceof JpsCompositePackagingElement) {
for (Element childElement : JDOMUtil.getChildren(element, "element")) {
JpsPackagingElement child = loadPackagingElement(childElement);
if (child != null) {
((JpsCompositePackagingElement)packagingElement).addChild(child);
}
}
}
return packagingElement;
}
@Nullable
private static JpsPackagingElement createPackagingElement(Element element) {
String typeId = element.getAttributeValue("id");
JpsPackagingElementFactory factory = JpsPackagingElementFactory.getInstance();
if (typeId.equals("root")) {
return factory.createArtifactRoot();
}
if (typeId.equals("directory")) {
return factory.createDirectory(element.getAttributeValue("name"));
}
if (typeId.equals("archive")) {
return factory.createArchive(element.getAttributeValue("name"));
}
if (typeId.equals("file-copy")) {
return factory.createFileCopy(element.getAttributeValue("path"),
element.getAttributeValue("output-file-name"));
}
if (typeId.equals("dir-copy")) {
return factory.createDirectoryCopy(element.getAttributeValue("path"));
}
if (typeId.equals("extracted-dir")) {
return factory.createExtractedDirectory(element.getAttributeValue("path"),
element.getAttributeValue("path-in-jar"));
}
if (typeId.equals("library")) {
String level = element.getAttributeValue("level");
String libraryName = element.getAttributeValue("name");
String moduleName = element.getAttributeValue("module-name");
JpsElementReference<? extends JpsCompositeElement> parentReference;
if (moduleName != null) {
parentReference = JpsElementFactory.getInstance().createModuleReference(moduleName);
}
else {
parentReference = JpsModuleLoader.createLibraryTableReference(level);
}
return factory.createLibraryElement(JpsElementFactory.getInstance().createLibraryReference(libraryName, parentReference));
}
if (typeId.equals("artifact")) {
return factory.createArtifactOutput(JpsArtifactService.getInstance().createReference(element.getAttributeValue("artifact-name")));
}
JpsPackagingElementLoader<?> loader = findElementLoader(typeId);
if (loader != null) {
return loader.load(element);
}
return null;
}
private static JpsArtifactType getArtifactType(@Nullable String typeId) {
if (typeId == null || "plain".equals(typeId)) {
return DirectoryArtifactType.INSTANCE;
}
if (typeId.equals("jar")) {
return JarArtifactType.INSTANCE;
}
for (JpsModelLoaderExtension extension : JpsServiceManager.getInstance().getExtensions(JpsModelLoaderExtension.class)) {
JpsArtifactType type = extension.getArtifactType(typeId);
if (type != null) {
return type;
}
}
return DirectoryArtifactType.INSTANCE;
}
@Nullable
private static JpsPackagingElementLoader<?> findElementLoader(@NotNull String typeId) {
for (JpsPackagingElementLoader<?> loader : STANDARD_LOADERS) {
if (loader.getTypeId().equals(typeId)) {
return loader;
}
}
for (JpsModelLoaderExtension extension : JpsServiceManager.getInstance().getExtensions(JpsModelLoaderExtension.class)) {
for (JpsPackagingElementLoader<?> loader : extension.getPackagingElementLoaders()) {
if (loader.getTypeId().equals(typeId)) {
return loader;
}
}
}
return null;
}
}
@@ -0,0 +1,21 @@
package org.jetbrains.jps.model.serialization.artifact;
import org.jdom.Element;
import org.jetbrains.jps.model.artifact.elements.JpsPackagingElement;
/**
* @author nik
*/
public abstract class JpsPackagingElementLoader<E extends JpsPackagingElement> {
private final String myTypeId;
protected JpsPackagingElementLoader(String typeId) {
myTypeId = typeId;
}
public String getTypeId() {
return myTypeId;
}
public abstract E load(Element element);
}
@@ -3,6 +3,7 @@ package org.jetbrains.jps.model.serialization.java;
import com.intellij.openapi.util.JDOMUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsElementFactory;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.JpsUrlList;
import org.jetbrains.jps.model.java.*;
@@ -10,6 +11,10 @@ import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.module.JpsDependencyElement;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.serialization.JpsModelLoaderExtension;
import org.jetbrains.jps.model.serialization.artifact.JpsPackagingElementLoader;
import java.util.Arrays;
import java.util.List;
/**
* @author nik
@@ -74,6 +79,11 @@ public class JpsJavaModelLoaderExtension extends JpsModelLoaderExtension {
return null;
}
@Override
public List<? extends JpsPackagingElementLoader<?>> getPackagingElementLoaders() {
return Arrays.asList(new JpsModuleOutputPackagingElementLoader(), new JpsTestModuleOutputPackagingElementLoader());
}
private static void loadExplodedDirectoryExtension(JpsModule module, Element rootModelComponent) {
final Element exploded = rootModelComponent.getChild("exploded");
if (exploded != null) {
@@ -112,4 +122,27 @@ public class JpsJavaModelLoaderExtension extends JpsModelLoaderExtension {
result.addUrl(root.getAttributeValue("url"));
}
}
private static class JpsModuleOutputPackagingElementLoader extends JpsPackagingElementLoader<JpsProductionModuleOutputPackagingElement> {
private JpsModuleOutputPackagingElementLoader() {
super("module-output");
}
@Override
public JpsProductionModuleOutputPackagingElement load(Element element) {
return JpsJavaExtensionService.getInstance().createProductionModuleOutput(JpsElementFactory.getInstance().createModuleReference(element.getAttributeValue("name")));
}
}
private static class JpsTestModuleOutputPackagingElementLoader extends JpsPackagingElementLoader<JpsTestModuleOutputPackagingElement> {
private JpsTestModuleOutputPackagingElementLoader() {
super("module-test-output");
}
@Override
public JpsTestModuleOutputPackagingElement load(Element element) {
return JpsJavaExtensionService.getInstance().createTestModuleOutput(
JpsElementFactory.getInstance().createModuleReference(element.getAttributeValue("name")));
}
}
}
+1
View File
@@ -11,6 +11,7 @@
<orderEntry type="module" module-name="util" />
<orderEntry type="library" name="asm4" level="project" />
<orderEntry type="module" module-name="jps-model-api" />
<orderEntry type="module" module-name="jps-model-impl" />
</component>
</module>
@@ -1,5 +1,4 @@
package org.jetbrains.jps
import org.jetbrains.jps.artifacts.Artifact
/**
* @author max
*/
@@ -7,7 +6,6 @@ class Project {
String projectName
int locationHash
final Map<String, Artifact> artifacts = [:]
final Map<String, RunConfiguration> runConfigurations = [:]
final CompilerConfiguration compilerConfiguration = new CompilerConfiguration()
final UiDesignerConfiguration uiDesignerConfiguration = new UiDesignerConfiguration()
@@ -10,7 +10,6 @@ import org.jetbrains.jps.model.java.JavaSourceRootType;
import org.jetbrains.jps.model.java.JpsJavaClasspathKind;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsLibraryRoot;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.module.*;
@@ -25,17 +24,10 @@ public class ProjectPaths {
private static final String DEFAULT_GENERATED_DIR_NAME = "generated";
@NotNull
private final JpsProject myProject;
@Nullable
private final File myProjectTargetDir;
//private final Map<JpsJavaClasspathKind, Map<ModuleChunk, List<String>>> myCachedClasspath = new HashMap<JpsJavaClasspathKind, Map<ModuleChunk, List<String>>>();
public ProjectPaths(JpsProject project) {
this(project, null);
}
public ProjectPaths(JpsProject project, @Nullable File projectTargetDir) {
myProject = project;
myProjectTargetDir = projectTargetDir;
}
public Collection<File> getClasspathFiles(JpsModule module, JpsJavaClasspathKind kind) {
@@ -114,39 +106,9 @@ public class ProjectPaths {
}
}
public static void addLibraryFiles(Collection<File> classpath, @Nullable JpsLibrary library) {
private static void addLibraryFiles(Set<File> classpath, @Nullable JpsLibrary library) {
if (library != null) {
for (JpsLibraryRoot root : library.getRoots(JpsOrderRootType.COMPILED)) {
final File file = JpsPathUtil.urlToFile(root.getUrl());
switch (root.getInclusionOptions()) {
case ROOT_ITSELF:
classpath.add(file);
break;
case ARCHIVES_UNDER_ROOT:
collectArchives(file, false, classpath);
break;
case ARCHIVES_UNDER_ROOT_RECURSIVELY:
collectArchives(file, true, classpath);
break;
}
}
}
}
private static void collectArchives(File file, boolean recursively, Collection<File> result) {
final File[] children = file.listFiles();
if (children != null) {
for (File child : children) {
final String extension = FileUtil.getExtension(child.getName());
if (child.isDirectory()) {
if (recursively) {
collectArchives(child, recursively, result);
}
}
else if (extension.equals("jar") || extension.equals("zip")) {
result.add(child);
}
}
classpath.addAll(library.getFiles(JpsOrderRootType.COMPILED));
}
}
@@ -259,11 +221,6 @@ public class ProjectPaths {
@Nullable
public File getModuleOutputDir(JpsModule module, boolean forTests) {
if (myProjectTargetDir != null) {
final File basePath = new File(myProjectTargetDir, forTests ? "test" : "production");
return new File(basePath, module.getName());
}
final String url = JpsJavaExtensionService.getInstance().getOutputUrl(module, forTests);
return url != null ? JpsPathUtil.urlToFile(url) : null;
}
@@ -1,15 +0,0 @@
package org.jetbrains.jps.artifacts
/**
* @author nik
*/
class Artifact {
String name
LayoutElement rootElement
String outputPath
Map<String, ArtifactProperties> properties;
def String toString() {
return "artifact '$name'"
}
}
@@ -1,7 +0,0 @@
package org.jetbrains.jps.artifacts
/**
* @author nik
*/
interface ArtifactProperties {
}
@@ -1,16 +0,0 @@
package org.jetbrains.jps.artifacts
import org.jetbrains.jps.MacroExpander
/**
* @author nik
*/
abstract class ArtifactPropertiesProviderService<P extends ArtifactProperties> {
final String id
ArtifactPropertiesProviderService(String id) {
this.id = id
}
abstract P loadProperties(Node node, MacroExpander macroExpander)
}
@@ -1,79 +0,0 @@
package org.jetbrains.jps.artifacts
import org.jetbrains.jps.Project
import org.jetbrains.jps.ProjectPaths
import org.jetbrains.jps.idea.ProjectLoadingErrorReporter
import org.jetbrains.jps.model.JpsModel
import org.jetbrains.jps.model.library.JpsLibrary
import org.jetbrains.jps.model.library.JpsLibraryCollection
/**
* @author nik
*/
abstract class ComplexLayoutElement extends LayoutElement {
abstract List<LayoutElement> getSubstitution(Project project, JpsModel model)
boolean process(Project project, JpsModel model, Closure processor) {
if (processor(this)) {
getSubstitution(project, model)*.process(project, model, processor)
}
}
}
class LibraryFilesElement extends ComplexLayoutElement {
public static final String PROJECT_LEVEL = "project"
String moduleName
String libraryName
String libraryLevel
List<LayoutElement> getSubstitution(Project project, JpsModel model) {
JpsLibraryCollection libraries = null
switch (libraryLevel) {
case PROJECT_LEVEL:
libraries = model.project.libraryCollection
break
case "module":
libraries = model.project.modules.find {it.name.equals(moduleName)}?.libraryCollection
break
case "application":
libraries = model.global.libraryCollection
break
}
JpsLibrary library = libraries?.findLibrary(libraryName)
if (library == null) {
return []
}
List<File> files = new ArrayList<File>()
ProjectPaths.addLibraryFiles(files, library)
return files.collect {File file ->
if (file.isDirectory()) {
return new DirectoryCopyElement(dirPath: file.absolutePath)
}
else {
return new FileCopyElement(filePath: file.absolutePath)
}
}
}
}
class ArtifactLayoutElement extends ComplexLayoutElement {
String artifactName
ProjectLoadingErrorReporter errorReporter
List<LayoutElement> getSubstitution(Project project, JpsModel model) {
Artifact artifact = project.artifacts[artifactName]
if (artifact == null) {
errorReporter.error("unknown artifact: $artifactName")
return []
}
def root = artifact.rootElement
if (root instanceof RootElement) {
return ((RootElement)root).children
}
return [root]
}
Artifact findArtifact(Project project) {
return project.artifacts[artifactName]
}
}
@@ -1,46 +0,0 @@
package org.jetbrains.jps.artifacts
import org.jetbrains.jps.Project
import org.jetbrains.jps.model.JpsModel
/**
* @author nik
*/
abstract class CompositeLayoutElement extends LayoutElement {
String name
protected final List<LayoutElement> children = []
List<LayoutElement> getChildren() {
return children
}
LayoutElement leftShift(LayoutElement child) {
children << child
return child
}
boolean process(Project project, JpsModel model, Closure processor) {
if (processor(this)) {
children*.process(project, model, processor)
}
}
}
class RootElement extends CompositeLayoutElement {
def RootElement(List<LayoutElement> children) {
this.children.addAll(children)
}
}
class DirectoryElement extends CompositeLayoutElement {
def DirectoryElement(String name, List<LayoutElement> children) {
this.name = name
this.children.addAll(children)
}
}
class ArchiveElement extends CompositeLayoutElement {
def ArchiveElement(String name, List<LayoutElement> children) {
this.name = name
this.children.addAll(children)
}
}
@@ -1,49 +0,0 @@
package org.jetbrains.jps.artifacts
import org.jetbrains.jps.Project
import org.jetbrains.jps.model.JpsModel
/**
* @author nik
*/
abstract class LayoutElement {
boolean process(Project project, JpsModel model, Closure processor) {
return processor(this)
}
}
class FileCopyElement extends LayoutElement {
String filePath
String outputFileName
FileCopyElement() {
}
FileCopyElement(String filePath, String outputFileName) {
this.filePath = filePath
this.outputFileName = outputFileName
}
}
class DirectoryCopyElement extends LayoutElement {
DirectoryCopyElement() {
}
DirectoryCopyElement(String dirPath) {
this.dirPath = dirPath
}
String dirPath
}
class ExtractedDirectoryElement extends LayoutElement {
String jarPath
String pathInJar
}
class ModuleOutputElement extends LayoutElement {
String moduleName
}
class ModuleTestOutputElement extends LayoutElement {
String moduleName
}
@@ -1,18 +0,0 @@
package org.jetbrains.jps.artifacts
/**
* @author nik
*/
class LayoutElementFactory {
static LayoutElement createParentDirectories(String path, LayoutElement element) {
def result = element
path.split("/").reverseEach {
if (it != "") {
result = new DirectoryElement(it, [result])
}
}
return result
}
}
@@ -1,23 +0,0 @@
package org.jetbrains.jps.artifacts;
import groovy.util.Node;
import org.jetbrains.jps.MacroExpander;
import org.jetbrains.jps.Project;
import org.jetbrains.jps.idea.ProjectLoadingErrorReporter;
/**
* @author nik
*/
public abstract class LayoutElementTypeService {
private final String typeId;
protected LayoutElementTypeService(String typeId) {
this.typeId = typeId;
}
public String getTypeId() {
return typeId;
}
public abstract LayoutElement createElement(Project project, Node tag, MacroExpander macroExpander, ProjectLoadingErrorReporter errorReporter);
}
@@ -1,125 +0,0 @@
package org.jetbrains.jps.idea
import org.jetbrains.jps.MacroExpander
import org.jetbrains.jps.Project
import org.jetbrains.jps.artifacts.*
/**
* @author nik
*/
class ArtifactLoader {
private final Project project
private final MacroExpander macroExpander
private static OwnServiceLoader<LayoutElementTypeService> elementTypeLoader = OwnServiceLoader.load(LayoutElementTypeService.class)
private static OwnServiceLoader<ArtifactPropertiesProviderService> propertiesProvidersLoader = OwnServiceLoader.load(ArtifactPropertiesProviderService.class)
private static Map<String, LayoutElementTypeService> elementTypes = null
private static Map<String, ArtifactPropertiesProviderService> propertiesProviders = null
private final ProjectLoadingErrorReporter errorReporter
def ArtifactLoader(Project project, MacroExpander macroExpander, ProjectLoadingErrorReporter errorReporter) {
this.macroExpander = macroExpander
this.project = project
this.errorReporter = errorReporter
}
LayoutElement loadLayoutElement(Node tag, String artifactName) {
String id = tag."@id";
switch (id) {
case "root":
return new RootElement(loadChildren(tag, artifactName));
case "directory":
return new DirectoryElement(tag."@name", loadChildren(tag, artifactName));
case "archive":
return new ArchiveElement(tag."@name", loadChildren(tag, artifactName));
case "artifact":
return new ArtifactLayoutElement(artifactName: tag."@artifact-name", errorReporter: errorReporter)
case "file-copy":
def path = macroExpander.expandMacros(tag."@path")
if (!new File(path).exists()) {
errorReporter.warning("Error in '$artifactName' artifact: file '$path' doesn't exist")
}
return new FileCopyElement(filePath: path,
outputFileName: tag."@output-file-name");
case "dir-copy":
def path = macroExpander.expandMacros(tag."@path")
if (!new File(path).exists()) {
errorReporter.warning("Error in '$artifactName' artifact: directory '$path' doesn't exist")
}
return new DirectoryCopyElement(dirPath: path);
case "extracted-dir":
def jarPath = macroExpander.expandMacros(tag."@path")
String pathInJar = tag."@path-in-jar"
if (pathInJar == null) pathInJar = "/"
if (!new File(jarPath).exists()) {
errorReporter.warning("Error in '$artifactName' artifact: file '$jarPath' doesn't exist")
}
return new ExtractedDirectoryElement(jarPath: jarPath, pathInJar: pathInJar)
case "module-output":
def name = tag."@name"
return new ModuleOutputElement(moduleName: name);
case "module-test-output":
def name = tag."@name"
return new ModuleTestOutputElement(moduleName: name);
case "library":
return new LibraryFilesElement(libraryLevel: tag."@level", libraryName: tag."@name", moduleName: tag."@module-name");
}
LayoutElementTypeService type = findType(id)
if (type != null) {
return type.createElement(project, tag, macroExpander, errorReporter)
}
errorReporter.error("unknown element in '$artifactName' artifact: $id");
return null
}
private LayoutElementTypeService findType(String typeId) {
if (elementTypes == null) {
elementTypes = [:]
elementTypeLoader.each {LayoutElementTypeService type ->
elementTypes[type.typeId] = type
}
}
return elementTypes[typeId]
}
private ArtifactPropertiesProviderService findPropertiesProvider(String id) {
if (propertiesProviders == null) {
propertiesProviders = [:]
propertiesProvidersLoader.each {ArtifactPropertiesProviderService provider ->
propertiesProviders[provider.id] = provider
}
}
return propertiesProviders[id]
}
Map<String, ArtifactProperties> loadOptions(Node artifactTag, String artifactName) {
def Map<String, ArtifactProperties> res = [:];
artifactTag.properties.each {Node propertiesNode ->
def String id = propertiesNode."@id";
ArtifactPropertiesProviderService provider = findPropertiesProvider(id)
if (provider != null) {
try {
res[id] = provider.loadProperties(propertiesNode.options[0], macroExpander)
} catch (Exception e) {
errorReporter.warning("Failed to load properties of the artifact: $artifactName, error: " + e.getMessage());
}
}
else {
errorReporter.warning("Unknown properties '$id' in '$artifactName' artifact")
}
}
return res;
}
List<LayoutElement> loadChildren(Node node, String artifactName) {
List<LayoutElement> children = []
node.element.each {
def child = loadLayoutElement(it, artifactName)
if (child != null) {
children << child
}
}
return children
}
}
@@ -2,7 +2,6 @@ package org.jetbrains.jps.idea
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.jps.*
import org.jetbrains.jps.artifacts.Artifact
/**
* @author max
*/
@@ -84,7 +83,6 @@ public class IdeaProjectLoader {
loadProjectFileEncodings(root)
loadWorkspaceConfiguration(new File(iprFile.parentFile, iprFile.name[0..-4]+"iws"))
loadUiDesignerConfiguration(root)
loadArtifacts(getComponent(root, "ArtifactManager"))
loadRunConfigurations(getComponent(root, "ProjectRunConfigurationManager"))
}
@@ -109,16 +107,6 @@ public class IdeaProjectLoader {
loadUiDesignerConfiguration(xmlParser.parse(uiDesignerXml))
}
def artifactsFolder = new File(dir, "artifacts")
if (artifactsFolder.isDirectory()) {
artifactsFolder.eachFile {File file ->
if (isXmlFile(file)) {
def artifactsComponent = xmlParser.parse(file)
loadArtifacts(artifactsComponent)
}
}
}
def runConfFolder = new File(dir, "runConfigurations")
if (runConfFolder.isDirectory()) {
runConfFolder.eachFile {File file ->
@@ -296,19 +284,6 @@ public class IdeaProjectLoader {
}
}
def loadArtifacts(Node artifactsComponent) {
if (artifactsComponent == null) return;
ArtifactLoader artifactLoader = new ArtifactLoader(project, projectMacroExpander, errorReporter)
artifactsComponent.artifact.each {Node artifactTag ->
def artifactName = artifactTag."@name"
def outputPath = projectMacroExpander.expandMacros(artifactTag."output-path"[0]?.text())
def root = artifactLoader.loadLayoutElement(artifactTag.root[0], artifactName)
def options = artifactLoader.loadOptions(artifactTag, artifactName)
def artifact = new Artifact(name: artifactName, rootElement: root, outputPath: outputPath, properties: options);
project.artifacts[artifact.name] = artifact;
}
}
def loadRunConfigurations(Node runConfManager) {
if (runConfManager == null) return;