Выполнение проекта через Maven Invoker вызывает ошибку компиляции - PullRequest
1 голос
/ 03 февраля 2020

Я пытаюсь выполнить проект maven из java main. Пожалуйста, обратитесь к приведенному ниже коду.


public static void main(String args[]) throws MavenInvocationException
    {
        InvocationRequest request = new DefaultInvocationRequest();

        request.setPomFile( new File( "C:\\Users\\DPKA764\\git\\be.axa.testautomation.phoenixiard\\pom.xml" ) );
        request.setGoals( Arrays.asList( "clean", "install" ) );

        Invoker invoker = new DefaultInvoker();
        invoker.setMavenHome(new File("C:\\J\\apache-maven-3.5.3"));
        System.out.println(""+invoker.getMavenHome());

        invoker.execute( request );
        System.out.println("suites are completed");
    }

, и когда я выполняю код как 'Java Application', возникает следующая ошибка .

[WARN] Maven will be executed in interactive mode, but no input stream has been configured for this MavenInvoker instance.
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------< be.axa.PhoenixIARD:PhoenixIARD >-------------------
[INFO] Building git-training 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ PhoenixIARD ---
[INFO] Deleting C:\Users\DPKA764\git\be.axa.testautomation.phoenixiard\target
[INFO] 
[INFO] --- properties-maven-plugin:1.0.0:read-project-properties (default) @ PhoenixIARD ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ PhoenixIARD ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\DPKA764\git\be.axa.testautomation.phoenixiard\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ PhoenixIARD ---
[INFO] Compiling 57 source files to C:\Users\DPKA764\git\be.axa.testautomation.phoenixiard\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
  C:\Program Files\Java\jre7\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.885 s
[INFO] Finished at: 2020-02-03T18:24:34+05:30
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "metadata" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project PhoenixIARD: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR]   C:\Program Files\Java\jre7\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

, но когда я выполню проект напрямую, как Maven Test, он будет работать нормально. Пожалуйста, предложите любые изменения, которые мне нужно сделать

...