You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2010/11/29 17:23:51 UTC
svn commit: r1040170 - in /ant/core/trunk: WHATSNEW contributors.xml
src/main/org/apache/tools/ant/taskdefs/Javac.java
src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
Author: bodewig
Date: Mon Nov 29 16:23:51 2010
New Revision: 1040170
URL: http://svn.apache.org/viewvc?rev=1040170&view=rev
Log:
support sources with extensions other than .java in javac. Submitted by Andrew Eisenberg. PR 48829.
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/contributors.xml
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1040170&r1=1040169&r2=1040170&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Nov 29 16:23:51 2010
@@ -281,6 +281,11 @@ Other changes:
this release of Ant are detected as Java 1.5 and not 1.6.
Bugzilla Report 50256.
+ * It is now possible to write a compiler adapter for <javac> that
+ compiles sources with extensions other than .java (but that still
+ compile to .class files).
+ Bugzilla Report 48829.
+
Changes from Ant 1.8.0 TO Ant 1.8.1
===================================
Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=1040170&r1=1040169&r2=1040170&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Mon Nov 29 16:23:51 2010
@@ -72,6 +72,10 @@
</name>
<name>
<first>Andrew</first>
+ <last>Eisenberg</last>
+ </name>
+ <name>
+ <first>Andrew</first>
<last>Everitt</last>
</name>
<name>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?rev=1040170&r1=1040169&r2=1040170&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java Mon Nov 29 16:23:51 2010
@@ -31,6 +31,7 @@ import org.apache.tools.ant.DirectorySca
import org.apache.tools.ant.MagicNames;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter;
+import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterExtension;
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
@@ -934,7 +935,10 @@ public class Javac extends MatchingTask
*/
protected void scanDir(File srcDir, File destDir, String[] files) {
GlobPatternMapper m = new GlobPatternMapper();
- m.setFrom("*.java");
+ String[] extensions = findSupportedFileExtensions();
+
+ for (int i = 0; i < extensions.length; i++) {
+ m.setFrom(extensions[i]);
m.setTo("*.class");
SourceFileScanner sfs = new SourceFileScanner(this);
File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
@@ -949,6 +953,33 @@ public class Javac extends MatchingTask
compileList.length, newFiles.length);
compileList = newCompileList;
}
+ }
+ }
+
+ private String[] findSupportedFileExtensions() {
+ String compilerImpl = getCompiler();
+ CompilerAdapter adapter =
+ nestedAdapter != null ? nestedAdapter :
+ CompilerAdapterFactory.getCompiler(compilerImpl, this,
+ createCompilerClasspath());
+ String[] extensions = null;
+ if (adapter instanceof CompilerAdapterExtension) {
+ extensions =
+ ((CompilerAdapterExtension) adapter).getSupportedFileExtensions();
+ }
+
+ if (extensions == null) {
+ extensions = new String[] { "java" };
+ }
+
+ // now process the extensions to ensure that they are the
+ // right format
+ for (int i = 0; i < extensions.length; i++) {
+ if (!extensions[i].startsWith("*.")) {
+ extensions[i] = "*." + extensions[i];
+ }
+ }
+ return extensions;
}
/**
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java?rev=1040170&r1=1040169&r2=1040170&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java Mon Nov 29 16:23:51 2010
@@ -44,7 +44,9 @@ import org.apache.tools.ant.taskdefs.con
*
* @since Ant 1.3
*/
-public abstract class DefaultCompilerAdapter implements CompilerAdapter {
+public abstract class DefaultCompilerAdapter
+ implements CompilerAdapter, CompilerAdapterExtension {
+
private static final int COMMAND_LINE_LIMIT;
static {
if (Os.isFamily("os/2")) {
@@ -128,6 +130,15 @@ public abstract class DefaultCompilerAda
}
/**
+ * By default, only recognize files with a Java extension,
+ * but specialized compilers can recognize multiple kinds
+ * of files.
+ */
+ public String[] getSupportedFileExtensions() {
+ return new String[] { "java" };
+ }
+
+ /**
* Get the project this compiler adapter was created in.
* @return the owner project
* @since Ant 1.6