Compile failed; see the compiler error output for details

107,795

Solution 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.

Solution 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.

Solution 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

Share:
107,795
user1121120
Author by

user1121120

Updated on May 04, 2022

Comments

  • user1121120
    user1121120 almost 2 years

    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 ?

    • Ewald
      Ewald over 12 years
      Looks like the actual error message might be higher up than we can see, all this tells us is that build.xml failed somewhere around line 36, which I guess is where it tries to compile your Java source code. There must be something wrong with your Java code, do you use an IDE?
    • user1121120
      user1121120 over 12 years
      In my logs, I have got [javac] C:\Users\workspace\testrepo\src\testrepo\testrepoclass.java:‌​3: error: package org.junit does not exist [javac] import org.junit.After
  • user1121120
    user1121120 over 12 years
    Thank you for the answer. I got one warning warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds. Is it because of that warning??
  • AbdullahC
    AbdullahC over 12 years
    Nope, that shouldn't be the problem.
  • user1121120
    user1121120 over 12 years
    In my logs, I have got [javac] C:\Users\workspace\testrepo\src\testrepo\testrepoclass.java:‌​3: error: package org.junit does not exist [javac] import org.junit.After;
  • AbdullahC
    AbdullahC over 12 years
    Yep...that's the problem. Including the JUnit jar in javac's classpath should fix the issue.
  • user1121120
    user1121120 over 12 years
    I copied the Jnuit Jar files and pasted in C:\eclipse\jre\bin which is the JAVA_HOME path. Even then I am getting the same problem.
  • AbdullahC
    AbdullahC over 12 years
    Try pasting it in the Java lib directory.
  • user1121120
    user1121120 over 12 years
    I pasted in C:\eclipse\jre\lib. But even then same error is displaying.
  • AbdullahC
    AbdullahC over 12 years
    Hmm...I guess javac is using a different lib directory on your machine. It might be C:\eclipse\lib, or it might be something else. Alternatively, you could add the path to the jar in the classpath attribute of the javac task.
  • user1121120
    user1121120 over 12 years
    '-classpath' 'C:\Users\workspace\testrepo\build; C:\eclipse\plugins\org.apache.ant_1.8.2.v20110505-1300\lib\a‌​nt-antlr.jar; C:\eclipse\plugins\org.apache.ant_1.8.2.v20110505-1300\lib\a‌​nt-junit.jar; C:\eclipse\plugins\org.apache.ant_1.8.2.v20110505-1300\lib\a‌​nt-junit4.jar C:\eclipse\jre\lib\tools.jar; C:\eclipse\plugins\org.eclipse.swt.win32.win32.x86_64_3.7.1.‌​v3738a.jar' '-sourcepath' 'C:\Users\workspace\testrepo\src\testrepo' '-g:none' The ' characters around the executable and arguments are not part of the command. [javac] File to be compiled: In the classpath, so junit are all there
  • AbdullahC
    AbdullahC over 12 years
    @user1121120: I don't see the junit-4.xx.jar in the classpath - the ant-junit jars are definitely different.
  • user1121120
    user1121120 over 12 years
    I pasted junit.jar in C:\eclipse\plugins\org.apache.ant_1.8.2.v20110505-1300\lib location,C:\eclipse\jre\lib location, C:\eclipse\jre\bin location and C:\eclipse\configuration\org.eclipse.osgi\bundles\39\1\.cp\l‌​ib locations. Still in the log file, i cannot see junit in the classpath and still the same error is displaying and also I restarted eclipse after doing each and every changes.:(
  • AbdullahC
    AbdullahC over 12 years
    @user1121120: Where is javac present on your machine? You'll need to place it in the lib directory corresponding to that.
  • user1121120
    user1121120 over 12 years
    Javac.exe is present in C:\eclipse\jre\bin location. In eclipse, I have configured the JAVA_HOME path as C:\eclipse\jre\bin.
  • AbdullahC
    AbdullahC over 12 years
    @user1121120: Since it doesn't seem to work that way, try adding junit explicitly to the classpath. Use the classpath attribute of the javac task. To begin with, you can hardcode the whole path you pasted above and add the path to the junit jar to it.
  • Pwnstar
    Pwnstar about 7 years
    Thanks that saved me time :D Consider extending this code by: 'boolean isDebug = java.lang.management.ManagementFactory.getRuntimeMXBean().ge‌​tInputArguments().to‌​String() .indexOf("-agentlib:jdwp") > 0; if (isDebug) { logger.debug(cmd.toString()); } '
  • Mugshep
    Mugshep over 2 years
    Dec 2021, the above command doesn't work for me, but simply this does: ant > log.txt