mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
allow to include module test output in artifacts (IDEA-53226)
This commit is contained in:
@@ -7,4 +7,5 @@
|
||||
<typedef name="renamedFile" classname="jetbrains.antlayout.datatypes.RenamedFileContainer"/>
|
||||
<typedef name="extractedDir" classname="jetbrains.antlayout.datatypes.ExtractedDirContent"/>
|
||||
<typedef name="module" classname="jetbrains.antlayout.datatypes.IdeaModule"/>
|
||||
<typedef name="moduleTests" classname="jetbrains.antlayout.datatypes.IdeaModuleTests"/>
|
||||
</antlib>
|
||||
@@ -60,6 +60,10 @@ public abstract class Container extends Content {
|
||||
children.add(new FileSetContainer(module));
|
||||
}
|
||||
|
||||
public void addModuleTests(IdeaModuleTests module) {
|
||||
children.add(new FileSetContainer(module));
|
||||
}
|
||||
|
||||
public List<Content> getChildren() {
|
||||
return children;
|
||||
}
|
||||
@@ -100,6 +104,9 @@ public abstract class Container extends Content {
|
||||
if (set instanceof IdeaModule) {
|
||||
return new IdeaModule((IdeaModule) set);
|
||||
}
|
||||
if (set instanceof IdeaModuleTests) {
|
||||
return new IdeaModuleTests((IdeaModuleTests) set);
|
||||
}
|
||||
if (set instanceof ZipFileSet) {
|
||||
return new LayoutFileSet((ZipFileSet) set.clone());
|
||||
} else {
|
||||
|
||||
@@ -27,8 +27,8 @@ public class FileSetContainer extends Content {
|
||||
|
||||
@Override
|
||||
public void validateArguments() throws BuildException {
|
||||
if (fileSet instanceof IdeaModule) {
|
||||
((IdeaModule) fileSet).validateArguments();
|
||||
if (fileSet instanceof IdeaModuleBase) {
|
||||
((IdeaModuleBase) fileSet).validateArguments();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,65 +1,23 @@
|
||||
package jetbrains.antlayout.datatypes;
|
||||
|
||||
import jetbrains.antlayout.util.LayoutFileSet;
|
||||
import org.apache.tools.ant.BuildException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class IdeaModule extends LayoutFileSet {
|
||||
private String name;
|
||||
|
||||
public IdeaModule() {
|
||||
}
|
||||
|
||||
public IdeaModule(IdeaModule fileset) {
|
||||
super(fileset);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
setDir(getMainOutput());
|
||||
}
|
||||
|
||||
private File getMainOutput() {
|
||||
String common = getProject().getProperty("modules.output");
|
||||
if (common != null) {
|
||||
return new File(new File(common), "production/" + name);
|
||||
}
|
||||
|
||||
String adhoc = getProject().getProperty("module." + name +".output.main");
|
||||
return adhoc != null ? new File(adhoc) : null;
|
||||
}
|
||||
|
||||
public void validateArguments() throws BuildException {
|
||||
if (name == null) {
|
||||
throw new BuildException("name attribute must be specified for moduleentry");
|
||||
}
|
||||
|
||||
File main = getMainOutput();
|
||||
|
||||
if (main == null || !main.exists()) {
|
||||
throw new BuildException("No production output found for module " + name +
|
||||
". Either modules.output property references project output that doesn't contain this module or " +
|
||||
"module." + name +".output.main is not defined or references non-existing directory.");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
IdeaModule that = (IdeaModule) o;
|
||||
return getDir(getProject()).equals(that.getDir(getProject()));
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return getDir(getProject()).hashCode();
|
||||
}
|
||||
}
|
||||
package jetbrains.antlayout.datatypes;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class IdeaModule extends IdeaModuleBase {
|
||||
public IdeaModule() {
|
||||
}
|
||||
|
||||
public IdeaModule(IdeaModule fileset) {
|
||||
super(fileset);
|
||||
}
|
||||
|
||||
protected String getKind() {
|
||||
return "production";
|
||||
}
|
||||
|
||||
protected String getOutputDirProperty() {
|
||||
return "module." + getName() + ".output.main";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package jetbrains.antlayout.datatypes;
|
||||
|
||||
import jetbrains.antlayout.util.LayoutFileSet;
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.types.ZipFileSet;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class IdeaModuleBase extends LayoutFileSet {
|
||||
private String name;
|
||||
|
||||
protected IdeaModuleBase() {
|
||||
}
|
||||
|
||||
public IdeaModuleBase(ZipFileSet fileset) {
|
||||
super(fileset);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
setDir(getOutputDir());
|
||||
}
|
||||
|
||||
protected File getOutputDir() {
|
||||
String common = getProject().getProperty("modules.output");
|
||||
if (common != null) {
|
||||
return new File(new File(common), getKind() + "/" + getName());
|
||||
}
|
||||
|
||||
String adhoc = getProject().getProperty(getOutputDirProperty());
|
||||
return adhoc != null ? new File(adhoc) : null;
|
||||
}
|
||||
|
||||
public void validateArguments() throws BuildException {
|
||||
if (name == null) {
|
||||
throw new BuildException("name attribute must be specified for module entry");
|
||||
}
|
||||
|
||||
File outputDir = getOutputDir();
|
||||
|
||||
if (outputDir == null || !outputDir.exists()) {
|
||||
throw new BuildException("No " + getKind() + " output found for module " + name +
|
||||
". Either modules.output property references project output that doesn't contain this module or " +
|
||||
getOutputDirProperty() + " is not defined or references non-existing directory.");
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String getOutputDirProperty();
|
||||
|
||||
protected abstract String getKind();
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
IdeaModule that = (IdeaModule) o;
|
||||
return getDir(getProject()).equals(that.getDir(getProject()));
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return getDir(getProject()).hashCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package jetbrains.antlayout.datatypes;
|
||||
|
||||
import org.apache.tools.ant.types.ZipFileSet;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class IdeaModuleTests extends IdeaModuleBase {
|
||||
public IdeaModuleTests() {
|
||||
}
|
||||
|
||||
public IdeaModuleTests(ZipFileSet fileset) {
|
||||
super(fileset);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getOutputDirProperty() {
|
||||
return "module." + getName() + ".output.test";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getKind() {
|
||||
return "test";
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,10 @@ public class LayoutTask extends Task {
|
||||
containers.add(new FileSetContainer(module));
|
||||
}
|
||||
|
||||
public void addModuleTests(IdeaModuleTests module) {
|
||||
containers.add(new FileSetContainer(module));
|
||||
}
|
||||
|
||||
public void addFileset(FileSet fileSet) {
|
||||
containers.add(new FileSetContainer(fileSet));
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ final class Jps {
|
||||
def old = binding.getVariable("module")
|
||||
def layoutInfo = new LayoutInfo()
|
||||
|
||||
["module", "zip", "dir"].each {tag ->
|
||||
["module", "moduleTests", "zip", "dir"].each {tag ->
|
||||
binding.setVariable(tag, {Object[] args ->
|
||||
if (args.length == 1) {
|
||||
binding.ant."$tag"(name: args[0])
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package org.jetbrains.jps.artifacts
|
||||
|
||||
import org.jetbrains.jps.Project
|
||||
import org.jetbrains.jps.Library
|
||||
|
||||
/**
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
abstract class LayoutElement {
|
||||
@@ -58,3 +57,11 @@ class ModuleOutputElement extends LayoutElement {
|
||||
project.binding.module.call(moduleName)
|
||||
}
|
||||
}
|
||||
|
||||
class ModuleTestOutputElement extends LayoutElement {
|
||||
String moduleName
|
||||
|
||||
def build(Project project) {
|
||||
project.binding.moduleTests.call(moduleName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,12 @@ class ArtifactLoader {
|
||||
project.error("Unknown module '$name' in '$artifactName' artifact")
|
||||
}
|
||||
return new ModuleOutputElement(moduleName: name);
|
||||
case "module-test-output":
|
||||
def name = tag."@name"
|
||||
if (project.modules[name] == null) {
|
||||
project.error("Unknown module '$name' in '$artifactName' artifact")
|
||||
}
|
||||
return new ModuleTestOutputElement(moduleName: name);
|
||||
case "library":
|
||||
return new LibraryFilesElement(libraryLevel: tag."@level", libraryName: tag."@name", moduleName: tag."@module-name");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ArtifactManager">
|
||||
<artifact name="tests">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/tests</output-path>
|
||||
<root id="root">
|
||||
<element id="module-test-output" name="moduleTestOutput" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/moduleTestOutput.iml" filepath="$PROJECT_DIR$/moduleTestOutput.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: nik
|
||||
* Date: 4/5/11
|
||||
* Time: 4:39 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MyClass {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: nik
|
||||
* Date: 4/5/11
|
||||
* Time: 4:39 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MyTest {
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.jetbrains.jps
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class ModuleTestOutputElementTest extends JpsBuildTestCase {
|
||||
public void test() {
|
||||
doTest("testData/moduleTestOutput/moduleTestOutput.ipr", {}, {
|
||||
dir("artifacts") {
|
||||
dir("tests") {
|
||||
file("MyTest.class")
|
||||
}
|
||||
}
|
||||
dir("production") {
|
||||
dir("moduleTestOutput") {
|
||||
file("MyClass.class")
|
||||
}
|
||||
}
|
||||
dir("test") {
|
||||
dir("moduleTestOutput") {
|
||||
file("MyTest.class")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user