Compile failed; see the compiler error output for

2019-01-18 22:13发布

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 ?

标签: java ant
5条回答
Viruses.
2楼-- · 2019-01-18 22:28

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.

查看更多
干净又极端
3楼-- · 2019-01-18 22:28

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.

查看更多
仙女界的扛把子
4楼-- · 2019-01-18 22:31

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.

查看更多
Emotional °昔
5楼-- · 2019-01-18 22:36

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.

查看更多
Emotional °昔
6楼-- · 2019-01-18 22:42

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

查看更多
登录 后发表回答