mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-133754 Maven: resources builder: support outputDirectory parameters of maven-resources-plugin testResources/resources goals
This commit is contained in:
+2
-1
@@ -98,7 +98,8 @@ public class MavenResourcesBuilder extends TargetBuilder<MavenResourceRootDescri
|
||||
if (relPath == null) {
|
||||
continue;
|
||||
}
|
||||
final File outputDir = MavenResourcesTarget.getOutputDir(target.getModuleOutputDir(), rd.getConfiguration(), config.outputDirectory);
|
||||
final String outputDirectory = target.isTests() ? config.testOutputDirectory : config.outputDirectory;
|
||||
final File outputDir = MavenResourcesTarget.getOutputDir(target.getModuleOutputDir(), rd.getConfiguration(), outputDirectory);
|
||||
if (outputDir == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
+4
@@ -69,6 +69,9 @@ public class MavenModuleResourceConfiguration {
|
||||
@OptionTag
|
||||
public String outputDirectory = null;
|
||||
|
||||
@OptionTag
|
||||
public String testOutputDirectory = null;
|
||||
|
||||
@Tag("resources")
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "resource")
|
||||
public List<ResourceRootConfiguration> resources = new ArrayList<ResourceRootConfiguration>();
|
||||
@@ -108,6 +111,7 @@ public class MavenModuleResourceConfiguration {
|
||||
result = 31 * result + filteringExclusions.hashCode();
|
||||
result = 31 * result + (escapeString != null ? escapeString.hashCode() : 0);
|
||||
result = 31 * result + (outputDirectory != null ? outputDirectory.hashCode() : 0);
|
||||
result = 31 * result + (testOutputDirectory != null ? testOutputDirectory.hashCode() : 0);
|
||||
result = 31 * result + (escapeWindowsPaths ? 1 : 0);
|
||||
result = 31 * result + (overwrite ? 1 : 0);
|
||||
return result;
|
||||
|
||||
+18
-1
@@ -23,6 +23,7 @@ import com.intellij.util.xmlb.XmlSerializer;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.dom.references.MavenFilteredPropertyPsiReferenceProvider;
|
||||
import org.jetbrains.idea.maven.model.MavenId;
|
||||
import org.jetbrains.idea.maven.model.MavenResource;
|
||||
@@ -124,7 +125,9 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
}
|
||||
|
||||
Element pluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-resources-plugin");
|
||||
resourceConfig.outputDirectory = MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "outputDirectory", null);
|
||||
|
||||
resourceConfig.outputDirectory = getResourcesPluginGoalOutputDirectory(mavenProject, pluginConfiguration, "resources");
|
||||
resourceConfig.testOutputDirectory = getResourcesPluginGoalOutputDirectory(mavenProject, pluginConfiguration, "testResources");
|
||||
|
||||
addResources(resourceConfig.resources, mavenProject.getResources());
|
||||
addResources(resourceConfig.testResources, mavenProject.getTestResources());
|
||||
@@ -182,6 +185,20 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getResourcesPluginGoalOutputDirectory(@NotNull MavenProject mavenProject,
|
||||
@Nullable Element pluginConfiguration,
|
||||
@NotNull String goal) {
|
||||
final Element goalConfiguration = mavenProject.getPluginGoalConfiguration("org.apache.maven.plugins", "maven-resources-plugin", goal);
|
||||
String outputDirectory = MavenJDOMUtil.findChildValueByPath(goalConfiguration, "outputDirectory", null);
|
||||
if (outputDirectory == null) {
|
||||
outputDirectory = MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "outputDirectory", null);
|
||||
}
|
||||
return outputDirectory == null || FileUtil.isAbsolute(outputDirectory)
|
||||
? outputDirectory
|
||||
: mavenProject.getDirectory() + '/' + outputDirectory;
|
||||
}
|
||||
|
||||
private static void generateManifest(@NotNull MavenProject mavenProject, @NotNull Module module) {
|
||||
try {
|
||||
String jdkVersion = null;
|
||||
|
||||
+64
@@ -122,6 +122,70 @@ public class ResourceCopyingTest extends MavenCompilingTestCase {
|
||||
assertCopied("target/resourceOutput/foo/dir/file.properties");
|
||||
}
|
||||
|
||||
public void testResourcesPluginGoalAbsoluteCustomTargetPath() throws Exception {
|
||||
createProjectSubFile("src/test/resources/dir/file.properties");
|
||||
|
||||
importProject("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
|
||||
"<build>" +
|
||||
" <plugins>" +
|
||||
" <plugin>" +
|
||||
" <artifactId>maven-resources-plugin</artifactId>" +
|
||||
" <version>2.6</version>" +
|
||||
" <executions>" +
|
||||
" <execution>" +
|
||||
" <id>default-testResources</id>" +
|
||||
" <phase>process-test-resources</phase>" +
|
||||
" <goals>" +
|
||||
" <goal>testResources</goal>" +
|
||||
" </goals>" +
|
||||
" <configuration>" +
|
||||
" <outputDirectory>${project.build.testOutputDirectory}/custom</outputDirectory>" +
|
||||
" </configuration>" +
|
||||
" </execution>" +
|
||||
" </executions>" +
|
||||
" </plugin>" +
|
||||
" </plugins>" +
|
||||
"</build>");
|
||||
|
||||
compileModules("project");
|
||||
assertCopied("target/test-classes/custom/dir/file.properties");
|
||||
}
|
||||
|
||||
public void testResourcesPluginGoalRelativeCustomTargetPath() throws Exception {
|
||||
createProjectSubFile("src/test/resources/dir/file.properties");
|
||||
|
||||
importProject("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
|
||||
"<build>" +
|
||||
" <plugins>" +
|
||||
" <plugin>" +
|
||||
" <artifactId>maven-resources-plugin</artifactId>" +
|
||||
" <version>2.6</version>" +
|
||||
" <executions>" +
|
||||
" <execution>" +
|
||||
" <id>default-testResources</id>" +
|
||||
" <phase>process-test-resources</phase>" +
|
||||
" <goals>" +
|
||||
" <goal>testResources</goal>" +
|
||||
" </goals>" +
|
||||
" <configuration>" +
|
||||
" <outputDirectory>target/test-classes/custom</outputDirectory>" +
|
||||
" </configuration>" +
|
||||
" </execution>" +
|
||||
" </executions>" +
|
||||
" </plugin>" +
|
||||
" </plugins>" +
|
||||
"</build>");
|
||||
|
||||
compileModules("project");
|
||||
assertCopied("target/test-classes/custom/dir/file.properties");
|
||||
}
|
||||
|
||||
public void testAbsoluteCustomTargetPath() throws Exception {
|
||||
createProjectSubFile("res/foo/file.properties");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user