Home > front end >  Build fail Heroku java
Build fail Heroku java

Time:10-14

I have issue deploy project java. i configed pom.xml version jar 11 and mvn 3.8.1. I build success project in local so when i deployed in heroku. What I need to do?

[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-javac/2.8.4/plexus-compiler-javac-2.8.4.jar (21 kB at 211 kB/s)
   [INFO] Changes detected - recompiling the module!
   [INFO] Compiling 149 source files to /tmp/build_740f92f8/target/classes
   [INFO] ------------------------------------------------------------------------
   [INFO] BUILD FAILURE
   [INFO] ------------------------------------------------------------------------
   [INFO] Total time:  10.581 s
   [INFO] Finished at: 2022-10-14T02:29:49Z
   [INFO] ------------------------------------------------------------------------
   [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project NCKHSV: Fatal error compiling: invalid flag: --release -> [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/MojoExecutionException

! ERROR: Failed to build app with Maven We're sorry this build is failing! If you can't find the issue in application code, please submit a ticket so we can help: https://help.heroku.com/ ! Push rejected, failed to compile Java app. ! Push failed

CodePudding user response:

The problem is heroku currently using Java 8: Heroku Java versions

The indicator is this line:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project NCKHSV: Fatal error compiling: invalid flag: --release -> [Help 1]

I've encountered this problem when building maven application with target is Java 11 but running JDK is Java 8. I can't help with heroku since I haven't used it yet

CodePudding user response:

At heroku you could really use the configurations in your pom.xml below, please look carefully. :)

please check maven-plugin mentioned in pom.xml under <project> I have something like this below.

...
    <packaging>maven-plugin</packaging>
</project>

Futher more please check this plugin you could replace the below plugin code and modify as per your need. It can be added under build->plugins->THIS_PLUGIN

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>3.6.4</version>
                <configuration>
                    <!-- see http://jira.codehaus.org/browse/MNG-5346 -->
                    <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
                </configuration>
                <executions>
                    <execution>
                        <id>default-descriptor</id>
                        <phase>process-classes</phase>
                    </execution>
                    <execution>
                        <id>help-descriptor</id>
                        <phase>process-classes</phase>
                    </execution>
                    <execution>
                        <id>mojo-descriptor</id>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Also please add the below dependency in your pom.xml, under ```dependencies-> THIS DEPENDENCY

       <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.7.4</version>
        </dependency>

I hope, it helps!

  • Related