6

im trying to upload my discord bot project to Heroku using Git bash My project is java 10 and im using Maven but i get this error :

remote:        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project bot_discord: Fatal error compiling: invalid flag: --release -> [Help 1]
remote:        [ERROR]
remote:        [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
remote:        [ERROR] Re-run Maven using the -X switch to enable full debug logging.
remote:        [ERROR]
remote:        [ERROR] For more information about the errors and possible solutions, please read the following articles:
remote:        [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
remote:
remote:  !     ERROR: Failed to build app with Maven
remote:        We're sorry this build is failing! If you can't find the issue in application code,
remote:        please submit a ticket so we can help: https://help.heroku.com/
remote:
remote:  !     Push rejected, failed to compile Java app.
remote:
remote:  !     Push failed

i think i need to add something to my Pom.xml but i dont understand what to add ! my pom.xml :

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>kino.bot</groupId>
  <artifactId>bot_discord</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>Bot Ryo</name>
  <description>Mon bot</description>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <release>10</release>
        </configuration>
      </plugin>
    </plugins>
  </build>


  <repositories>
    <repository>
        <id>jcenter</id>
        <name>jcenter-bintray</name>
        <url>http://jcenter.bintray.com</url>
    </repository>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
        <groupId>net.dv8tion</groupId>
        <artifactId>JDA</artifactId>
        <version>3.7.1_422</version>
    </dependency>
    <dependency>
        <groupId>com.mashape.unirest</groupId>
        <artifactId>unirest-java</artifactId>
        <version>1.4.9</version>
    </dependency>
  </dependencies>

</project>

what do i need to add to my pom.xml ?

Honza Zidek
  • 9,204
  • 4
  • 72
  • 118
Aghiles Kebaili
  • 105
  • 1
  • 3
  • 9
  • Hi, you need to clarify what command you used to package/install/deploy your project. Looks like you (or your setup) is using some extra unsupported flag wth the mvn command. My suggestion would be to first do an "mvn clean package" to see that your project compiles okay. – Jang-Vijay Singh Sep 16 '18 at 05:34
  • im using the commands `$ git add . $ git commit -am "make it better" $ git push heroku master` and how can i do an "mvn clean package" ? thanks – Aghiles Kebaili Sep 16 '18 at 07:16
  • 1
    Java 9+ is the minimum you have to use otherwise you can't use `release` configuration for Javac...Furthermore I recommend to use maven-compiler-plugin version 3.8.0....Apart from that I strongly discourage to use `src` remove this and keep the convention... – khmarbaise Sep 16 '18 at 11:29
  • Do you have a `system.properties` file that is configured to use Java 10? https://devcenter.heroku.com/articles/java-support#supported-java-versions – codefinger Sep 16 '18 at 13:36
  • I changed `3.7.0` to `3.8.0` but same erreor . And No i dont have a file named system.properties in my project folder – Aghiles Kebaili Sep 16 '18 at 16:26

5 Answers5

3

Ensure that you have system.properties file in the root directory of your repository with the following contents:

java.runtime.version=10

For more info see the Heroku documentation on Java versions

codefinger
  • 10,088
  • 7
  • 39
  • 51
2

The -release argument is supported only since Java9 (https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html). Make sure your maven installation is using at least Java9.

  • im using maven 3.8.0 so i think the argument is supported – Aghiles Kebaili Sep 16 '18 at 07:26
  • It is supported by maven, but maven uses Java (precisely javac command) behind the hood to compile your sources. You have to make sure that javac command supports -version argument (JAVA_HOME environment variable should point to at least a Java9 installation). This is because you can have multiple Java installations on the same machine, and the JAVA_HOME variable defines which of those installations should be used to compile your sources. –  Sep 16 '18 at 07:40
  • so what should i do ? i dont really understand how this maven works , how can i check if my java_home is pointing to at least java9 ? – Aghiles Kebaili Sep 16 '18 at 16:29
  • On linux, you can use 'echo $JAVA_HOME' to print the environment variable JAVA_HOME. It should output something like '/usr/lib/jvm/java-10-oracle'. –  Sep 16 '18 at 16:34
0

Try using version 3.8.0 instead of 3.7.0. Also make sure your JAVA_HOME is set to your Java 8 installation. See this link

tom
  • 1,331
  • 1
  • 15
  • 28
  • tried this but i get the same error with the new version : `Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project bot_discord: Fatal error compiling: invalid flag: --release -> [Help 1] ` org.apache.maven.plugins maven-compiler-plugin 3.8.0 10 ` – Aghiles Kebaili Sep 16 '18 at 07:25
0

There's another option instead of adding the properties file in the repo location.

You can add this code in POM.xml:

<properties>
    <java.version>1.8.0_171</java.version>
</properties>
dan
  • 1,198
  • 8
  • 25
0

Remove <release>10</release> from pom.xml and add system.properties in resources with content java.runtime.version=10. It should work with jdk 10. Or you can change the JDK as per your need.

Abhishek
  • 648
  • 7
  • 8