问题
When I tried to compile build.xml file, below error is hitting:
BUILD FAILED
C:\Users\workspace\testrepo\src\build.xml:36: Compile failed; see the compiler error output for details.
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1150)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:912)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
Can someone help me ?
回答1:
There is a compile error that occurred earlier during the build. Look for that error in the same output log file and try to fix it.
回答2:
To see compiled error in log use below given command:
d:\yourdirectory of checkout>ant clean deploy>log.txt
It will create a complete log in your check out directory. So now you can check actual errors there.
回答3:
The following solution worked out good for me:
1) Define the following class:
package somepackage;
import org.apache.tools.ant.taskdefs.Javac;
import org.apache.tools.ant.types.Commandline;
import org.eclipse.jdt.core.JDTCompilerAdapter;
public class JDTCompiler15 extends JDTCompilerAdapter {
@Override
public void setJavac(Javac attributes) {
if (attributes.getTarget() == null) {
attributes.setTarget("1.6");
}
if (attributes.getSource() == null) {
attributes.setSource("1.6");
}
super.setJavac(attributes);
}
// THIS METHOD IS RESPONSIBLE FOR PRINGTING THE ERRORS/WARNING.
@Override
protected void logAndAddFilesToCompile(Commandline cmd) {
super.logAndAddFilesToCompile(cmd);
System.err.println(cmd.toString());
}
}
2) Add the following VM parameter: -Dbuild.compiler=somepackage.JDTCompiler15
回答4:
If you are using Weblogic to generate the client, you must add the "weblogic.jar" from the installation directory into the Additional Classpath, so Ant will know where the Ant.tools.... exist.
I got the same issue and I am trying to solve this problem not adding it as additional classpath since I copy all jars into my project, but still getting this error.
回答5:
In my case, there was an unused import statement in a class whose package cannot be found elsewhere but was copied over because I copied the class from another project of mine. Be it was listed in the error log as "package not found" even if the error log itself wasn't clear-cut. I had to search through all the warnings the log generated in my case.
来源:https://stackoverflow.com/questions/8667798/compile-failed-see-the-compiler-error-output-for-details