Maven: resourc ecompiler handles big files

This commit is contained in:
Anton.Makeev
2009-10-01 16:57:40 +04:00
parent 59f82471ec
commit 925643496f
2 changed files with 30 additions and 2 deletions
@@ -377,7 +377,15 @@ public class MavenResourceCompiler implements ClassPostProcessingCompiler {
try {
outputFile.getParentFile().mkdirs();
if (eachItem.isFiltered()) {
boolean shouldFilter = eachItem.isFiltered();
if (sourceFile.length() > 10 * 1024 * 1024) {
context.addMessage(CompilerMessageCategory.WARNING,
"Maven: File is too big to be filtered. Most likely it is a binary file and should be excluded from filtering.",
sourceVirtualFile.getUrl(), -1, -1);
shouldFilter = false;
}
if (shouldFilter) {
String charset = sourceVirtualFile.getCharset().name();
String text = new String(FileUtil.loadFileBytes(sourceFile), charset);
String escapedCharacters = "properties".equals(sourceVirtualFile.getExtension()) ? "\\" : null;
@@ -3,8 +3,8 @@ package org.jetbrains.idea.maven.compiler;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.idea.maven.MavenImportingTestCase;
import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
import org.jetbrains.idea.maven.importing.MavenDefaultModifiableModelsProvider;
import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
import java.io.IOException;
@@ -675,6 +675,26 @@ public class ResourceFilteringTest extends MavenImportingTestCase {
"value2=\\value\n");
}
public void testDoNotFilterButCopyBigFiles() throws Exception {
createProjectSubFile("resources/file.xyz").setBinaryContent(new byte[1024 * 1024 * 20]);
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>" +
"<build>" +
" <resources>" +
" <resource>" +
" <directory>resources</directory>" +
" <filtering>true</filtering>" +
" </resource>" +
" </resources>" +
"</build>");
compileModules("project");
assertNotNull(myProjectPom.getParent().findFileByRelativePath("target/classes/file.xyz"));
}
private void assertResult(String relativePath, String content) throws IOException {
assertResult(myProjectPom, relativePath, content);
}