IDEA-99237 Property precedence is not the same when filtering resources with Maven or with IntelliJ

This commit is contained in:
Sergey Evdokimov
2013-01-17 16:03:26 +04:00
parent 0db0e558b5
commit 0bec0fa361
3 changed files with 38 additions and 2 deletions

View File

@@ -217,7 +217,6 @@ public class MavenResourceCompiler implements ClassPostProcessingCompiler {
private static Properties loadPropertiesAndFilters(CompileContext context, MavenProject mavenProject) {
Properties properties = new Properties();
properties.putAll(mavenProject.getProperties());
for (String each : mavenProject.getFilters()) {
try {
@@ -234,6 +233,9 @@ public class MavenResourceCompiler implements ClassPostProcessingCompiler {
context.addMessage(CompilerMessageCategory.WARNING, "Maven: Cannot read the filter. " + e.getMessage(), url, -1, -1);
}
}
properties.putAll(mavenProject.getProperties());
return properties;
}

View File

@@ -1162,7 +1162,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
private static Properties getFilteringProperties(MavenProject mavenProject) {
final Properties properties = new Properties();
properties.putAll(mavenProject.getProperties());
for (String each : mavenProject.getFilters()) {
try {
FileInputStream in = new FileInputStream(each);
@@ -1176,6 +1176,8 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
catch (IOException ignored) {
}
}
properties.putAll(mavenProject.getProperties());
return properties;
}

View File

@@ -923,6 +923,38 @@ public abstract class ResourceFilteringTest extends MavenImportingTestCase {
"value2=value\n");
}
public void testPropertyPriority() throws Exception {
createProjectSubFile("filters/filter.properties", "xxx=fromFilterFile\n" +
"yyy=fromFilterFile");
createProjectSubFile("resources/file.properties","value1=${xxx}\n" +
"value2=${yyy}");
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>" +
"<properties>" +
" <xxx>fromProperties</xxx>" +
"</properties>" +
"<build>" +
" <filters>" +
" <filter>filters/filter.properties</filter>" +
" </filters>" +
" <resources>" +
" <resource>" +
" <directory>resources</directory>" +
" <filtering>true</filtering>" +
" </resource>" +
" </resources>" +
"</build>");
compileModules("project");
assertResult("target/classes/file.properties",
"value1=fromProperties\n" +
"value2=fromFilterFile");
}
public void testCustomEscapingFiltering() throws Exception {
createProjectSubFile("filters/filter.properties", "xxx=value");
createProjectSubFile("resources/file.properties",