Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Maven erro para deploy no heroku

Estou tentando fazer o deploy pelo cmd no heroku, porem esta dando erro no maven, pelo menos foi o que eu entendi kkk O maven nao esta envontrando o java 12 para fazer a compilação

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

eu ainda não conegui achar como resolver, podem me ajudar? Obs: Ja configurei o JAVA_HOME no Win para 12, Ja coloquei o Path do Win para java 12 e também o pom.xml para 12 https://github.com/BryanMotta/FormacaoJava/blob/master/pom.xml Log completo

-----> Java app detected
-----> Installing JDK 1.8... done
-----> Installing Maven 3.3.9... done
-----> Executing: mvn -DskipTests clean dependency:list install
       [INFO] Scanning for projects...

<---downloads omitidos---> 

[INFO] Downloaded: https://repo.maven.apache.org/maven2/com/google/collections/google-collections/1.0/google-collections-1.0.jar (625 KB at 3322.3 KB/sec)
       [INFO] Changes detected - recompiling the module!
       [INFO] Compiling 25 source files to /tmp/build_99bf93d9901378d94045dafa7dbc95b8/target/classes
       [INFO] ------------------------------------------------------------------------
       [INFO] BUILD FAILURE
       [INFO] ------------------------------------------------------------------------
       [INFO] Total time: 11.610 s
       [INFO] Finished at: 2019-08-28T03:53:20+00:00
       [INFO] Final Memory: 18M/163M
       [INFO] ------------------------------------------------------------------------
       [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project bitbank: Fatal error compiling: invalid target release: 12 -> [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
3 respostas

Coloque isso no seu pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <release>12</release>
                <compilerArgs>--enable-preview</compilerArgs>
            </configuration>
        </plugin>
        <!-- This is just to make sure the class is set as main class to execute from the jar-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                            <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>com.stackoverflow.nullpointer.expression.SwitchExpressions</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
solução!

Fala ai Otávio, então seu codigo não funcionou infelizmente, ele ficou dando erro no

<release>12</release>

e se eu trocasse para

<version>12</version>

como era sugerido nas minhas pesquisas, voltava para o erro inicial.

Mas consegui achar solução, fazer o deploy direto pelo Eclipse sem precisa usar linha de comando. Precisei colocar o plugin no pom.xml

</plugin>
                <plugin>
                    <groupId>com.heroku.sdk</groupId>
                    <artifactId>heroku-maven-plugin</artifactId>
                    <version>2.0.8</version>
                </plugin>
        </plugins>

e executar pelo maven do eclipese esse comando

heroku:deploy-war

Esse é o link completo das intruções https://devcenter.heroku.com/articles/deploying-java-applications-to-heroku-from-eclipse-or-intellij-idea

Perfeito amigo, obrigado por compartilhar!