I started an Android project, and by default it is built with ANT, I am trying to upgrade it to Maven so I can get rid of compile time problems I am having with Android SDK, and ease of library import and management. The problems I have encountered are :
1) How to modify build.xml to instruct it to use maven.
2) Maven complaining folder structure is wrong.
Here is my build.xml :
<?xml version="1.0" encoding="UTF-8"?>
<project name="myapp" default="help">
<property file="local.properties"/>
<property file="ant.properties"/>
<property environment="env"/>
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME"/>
</condition>
// and more
So I presume I have to modify the ant.properties attribute, how can I suggest to use Maven??
Here is the POM.xml I have pasted in the Parent directory of the project, but when I try to run mvn compile, I get the following error :
Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:4.0.0-rc.2:generate-sources (default-generate-sources) on project gs-maven-android:
[ERROR]
[ERROR] Found files or folders in non-standard locations in the project!
[ERROR] ....This might be a side-effect of a migration to Android Maven Plugin 4+.
[ERROR] ....Please observe the warnings for specific files and folders above.
[ERROR] ....Ideally you should restructure your project.
[ERROR] ....Alternatively add explicit configuration overrides for files or folders.
[ERROR] ....Finally you could set failOnNonStandardStructure to false, potentially resulting in other failures.
[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/MojoExecutionException
And finally, here is the POM.xml :
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.hello</groupId>
<artifactId>MyAPP</artifactId>
<version>1.0</version>
<packaging>apk</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.0.0-rc.2</version>
<configuration>
<sdk>
<platform>20</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
So what am I doing wrong here? Any help would be nice. I am using Intellij Idea on Ubuntu Linux. Thanks.
Please update to a full release version and then update the error message in the post. The latest release is 4.3.0.
The warning is about the source code and other sources being located in non-standard folders. You should use the standard structure. The full version will show error message with details where everything should be.
Related
I am completely new to this so pretty much clueless and need help.
I have done a few things involving setting up a pom.xml file and Procfile, but whether that's working and the file hierarchy is correct is also kind of a mystery to me...
Anyway, when I deploy to Heroku, this is the error message I get:
[ERROR] Failed to execute goal on project TokenBot1.0: Could not resolve dependencies for project org.example:TokenBot1.0:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: net.dv8tion:JDA:jar:4.2.0_214, com.jagrosh:jda-utilities:jar:3.0.4: Could not find artifact net.dv8tion:JDA:jar:4.2.0_214 in central (https://repo.maven.apache.org/maven2) -> [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/DependencyResolutionException
! 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
I also don't understand maven vs. gradle all that much, but I think my project was using gradle initially, and then I followed a guide to try setup with maven since a lot of the Heroku guides wanted maven.
Files look something like this:
TokenBot 1.0
Procfile
build.gradle
.git
src
pom.xml
main
build
libs
.jar file
Procfile
worker: java -jar target/TokenBot 1.0-1.0-SNAPSHOT.jar
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>TokenBot1.0</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.0_214</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.jagrosh</groupId>
<artifactId>jda-utilities</artifactId>
<version>3.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Please let me know if you need to know anything else.
Thanks in advance to anyone that can help!
I remade my whole project (just salvaged the code) using maven instead of gradle since basically every tutorial I could find used maven.
Next I made sure that I could still run my bot fine locally (I had to do a bit to my pom.xml file to achieve that)
The only tutorial I found that matched my exact case for deploying to heroku (minus github) was this Russian one: https://www.youtube.com/watch?v=LRapMfUMe4s
After following this tutorial exactly, the only thing that was missing for me was to create a Procfile, which I did. Once that's done, head over to heroku and enable the dyno that should show up.
So basically:
Create a fresh project file using maven instead of gradle
Make sure it runs fine locally (both with 'run' button in IntelliJ and executing the .jar file)
Deploy to heroku following the video/journey above
Procfile; make sure to create one in your root folder
This question already has an answer here:
Maven not recognising 'configuration' tag in pom.xml
(1 answer)
Closed 3 years ago.
I am packaging my application as
mvn package
It creates a jar file by the name JasperCSVDataSource-1.0-SNAPSHOT.jar
When I try to run the jar file as :
java -jar JasperCSVDataSource-1.0-SNAPSHOT.jar
I get an error saying no main manifest attribute, in target/JasperCSVDataSource-1.0-SNAPSHOT.jar. To automatically add manifest file in the created JAR, I updated my pom.xml by adding the following:
<configuration>
<archive>
<manifest>
<mainClass>com.comp.main.CommandLineRunner</mainClass>
</manifest>
</archive>
</configuration>
The complete pom.xml looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<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>com.comp</groupId>
<artifactId>JasperCSVDataSource</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<archive>
<manifest>
<mainClass>com.suhail.main.CommandLineRunner</mainClass>
</manifest>
</archive>
</configuration>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.8.0</version>
</dependency>
<dependency>
<groupId>ar.com.fdvs</groupId>
<artifactId>DynamicJasper</artifactId>
<version>5.0.11</version>
</dependency>
</dependencies>
</project>
But now when I try to build the file, I get an error saying:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Malformed POM /Users/tambro/jasper-test/pom.xml: Unrecognised tag: 'configuration' (position: START_TAG seen ...</version>\n \n <configuration>... #12:20) # /Users/tambro/jasper-test/pom.xml, line 12, column 20
#
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.tambro:JasperCSVDataSource:1.0-SNAPSHOT (/Users/tambro/jasper-test/pom.xml) has 1 error
[ERROR] Malformed POM /Users/tambro/jasper-test/pom.xml: Unrecognised tag: 'configuration' (position: START_TAG seen ...</version>\n \n <configuration>... #12:20) # /Users/tambro/jasper-test/pom.xml, line 12, column 20 -> [Help 2]
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
I could not understand the reason for this. Is this not the correct way of adding manifest file to the jar?
You need to provide <configuration> tag with specific maven plugin. In this case it could be maven-jar-plugin
So your pom.xml should have something like inside your <project> tags
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
...
<configuration>
<archive>
<manifest>
<mainClass>com.comp.main.CommandLineRunner</mainClass>
</manifest>
</archive>
</configuration>
...
</plugin>
</plugins>
</build>
Please guide me how to proceed further while doing the mvn release:prepare in my spring boot project also do tell how to add ssh key to my project if it is required.
I tried many solutions but none work as it is showing the same error everytime and this is my modular approach based project and IDE I am using is IntelliJ.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release- plugin:2.5.3:prepare (default-cli) on project vj-pet-clinic: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] git#github.com: Permission denied (publickey).
[ERROR] fatal: Could not read from remote repository.
[ERROR] Please make sure you have the correct access rights
[ERROR] and the repository exists.
[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
my pom.xml file is :-
<?xml version="1.0" encoding="UTF-8"?>
<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>
<packaging>pom</packaging>
<modules>
<module>pet-clinic-data</module>
<module>pet-clinic-web</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.vinamra</groupId>
<artifactId>vj-pet-clinic</artifactId>
<version>0.0.1</version>
<name>vj-pet-clinic</name>
<description>VJ pet clinic project</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<goals>install</goals>
<checkModificationExcludes>
<checkModificationExclude>pom.xml</checkModificationExclude>
</checkModificationExcludes>
</configuration>
</plugin>
</plugins>
</build>
<scm>
<developerConnection>scm:git:git#github.com:username/repository.git</developerConnection>
<tag>vj-pet-clinic-0.0.1</tag>
Please help me how to push the release the plugin using maven.
You can use HTTPS instead of SSH to avoid the keys exchange. Here is an example:
<scm>
<url>https://github.com/(username)/(repo)</url>
<connection>scm:git:https://github.com/(username)/(repo).git</connection>
</scm>
Replace (username) and (repo) accordingly.
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 ?
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
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.
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
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>
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.
I am running mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies in my project, and I'm seeing the following errors:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies (default-cli) on project beam-sdks-java-core: Some problems were encountered while processing the POMs:
[ERROR] [ERROR] Unknown packaging: bundle # line 6, column 16: 1 problem was encountered while building the effective model for org.xerial.snappy:snappy-java:1.1.4
[ERROR] [ERROR] Unknown packaging: bundle # line 6, column 16
Looking at Snappy's pom file, it looks like so:
<?xml version='1.0' encoding='UTF-8'?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<packaging>bundle</packaging>
<description>snappy-java: A fast compression/decompression library</description>
<version>1.1.4</version>
<name>snappy-java</name>
....
Specifically, the <packaging>bundle</packaging> line seems to be the problem.
I tried adding the maven-bundle-plugin to my own POM file's <build> tag, but that won't fix it (and why should it? I'd think that a dependency's config shouldn't affect my pom?)
How do I enable the maven-bundle-plugin for my dependencies? Do I need to add it to a specific subsection of my pom that refers to apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies?
Also, for extra info, my Maven version is 3.5.0
I tried adding the maven-bundle-plugin to my own POM file's
tag, but that won't fix it (and why should it? I'd think that a
dependency's config shouldn't affect my pom?
And you are right : it is not the maven-bundle-plugin as a dependency that you need to
add to make the bundle package usable in your build.
What you need is adding the maven-bundle-plugin as a plugin to
enhance the default Maven lifecycle such as :
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Include-Resource>
....
</Include-Resource>
</instructions>
</configuration>
</plugin>
</plugins>
<build>
You can find the information in the apache-felix-maven-bundle-plugin.
This is actually an issue with snappy-java 1.1.4. Their pom does not include the bundle plugin. However, version 1.1.7 switches to jar packaging.
You can work around this by using maven-dependency-plugin 2.10.