aChartEngine app testing using Maven - java

I am rather new to Maven and I am having trouble using it. I have a working Android app, which uses aChartEngine, that runs fine in Eclipse but I need to use Maven for testing. There has been a repository set up for ACE but I can't seem to access it properly. Here is my POM:
<?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>com.mycompany.my-app</groupId>
<artifactId>my-app</artifactId>
<packaging>apk</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>my-app</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.achartengine</groupId>
<artifactId>achartengine</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>achartengine</id>
<name>Public AChartEngine repository</name>
<url>https://repository-achartengine.forge.cloudbees.com/snapshot/</url>
</repository>
</repositories>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<!-- platform or api level (api level 16 = platform 4.1)-->
<platform>17</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
Is there something I'm doing wrong here? Let me know if I can add any more information.
Note that I am not using Maven from Eclipse, I am running it in a command prompt on windows 7.
UPDATE: I think I have found the problem but I'm not sure yet, so I'll still post the error message:
[ERROR] Failed to execute goal on project my-app: Could not resolve
dependencies for project com.mycompany:my-app:apk:0.0.1-
SNAPSHOT: Could not find artifact org.achartengine:achartengine:jar:1.1.0 in ...(my companies repository)

It turned out that the jar was not loaded into the repository that was being used. Got it all functional now.

Related

Eclipse JDT core Java runtime error - java.lang.NoSuchMethodError

I could not find any helping document regarding this error hence I am posting this question.
I am trying to use locally built Eclipse JDT core jar in my project. I followed the flowing steps.
Created an eclipse workspace as described in Link
Built eclipse.jdt.core using the mvn -P build-individual-bundles package
Added the resulting jar file that is created in the target folder to my project (i.e., project A) as a maven dependency.
After the above steps, I could successfully compile project A and now it gives me the following runtime error.
Exception in thread "pool-2-thread-1" java.lang.NoSuchMethodError: org.eclipse.core.runtime.SubMonitor.split(I)Lorg/eclipse/core/runtime/SubMonitor;
at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:820)
at utils.JavaASTUtil.parseSource(JavaASTUtil.java:87)
at change.CFile.<init>(CFile.java:32)
at change.RevisionAnalyzer.buildGitModifiedFiles(RevisionAnalyzer.java:310)
at change.RevisionAnalyzer.analyzeGit(RevisionAnalyzer.java:130)
at change.ChangeAnalyzer.analyzeGit(ChangeAnalyzer.java:243)
at change.ChangeAnalyzer.analyzeGit(ChangeAnalyzer.java:228)
at main.MainChangeAnalyzer$2.run(MainChangeAnalyzer.java:99)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
pom.xml of the project is given below
<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>AtomicASTChangeMining</groupId>
<artifactId>AtomicASTChangeMining</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<repository>
<id>local-maven-repo</id>
<url>file:///Users/xx/Documents/Research_Topic_2/</url>
</repository>
</repositories>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!--Below is the locally built jdt core jar -->
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.23.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>runtime</artifactId>
<version>3.10.0-v20140318-2214</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.core.resources</artifactId>
<version>3.10.0.v20150423-0755</version>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
<version>3.10.0-v20140606-1445</version>
</dependency>
</dependencies>
</project>
Does anybody have any idea about the runtime error?
Thanks a lot!
org.eclipse.core.runtime.SubMonitor is actually in the org.eclipse.equinox.common plug-in.
According to the Javadoc the split methods were added to SubMonitor in version 3.8 of org.eclipse.equinox.common. This corresponds to Eclipse release 4.6.
Do experiments on org.eclipse.core version. You might need to upgrade the version of org.eclipse.birt.runtime. Select the version that contains the method SubMonitor.split().

Fail to execute goal : tycho-p2-plugin

When trying to create a headless rcp eclipse version using tycho with the following 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>eclipse-mars</id>
<url>http://download.eclipse.org/releases/latest</url>
<layout>p2</layout>
</repository>
</repositories>
<packaging>eclipse-test-plugin</packaging>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<configuration>
<strictVersions>false</strictVersions>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration />
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.7.1</version>
</dependency>
</dependencies>
</project>
I get the folllowing error :
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-p2-plugin:1.4.0:p2-metadata-default (default-p2-metadata-default) on project test2: Execution default-p2-metadata-default of goal org.eclipse.tycho:tycho-p2-plugin:1.4.0:p2-metadata-default failed. IllegalArgumentException
Which arguments does this IllegalArgumentException refer to?
Is this a bug or a result from the pom.xml itself or rather an issue from other files (I don't want to include the whole project here so feel free to ask for files)
Run the buıild with -X flag. like mvn clean verify -X. In my case it was a typo in version.
Wrote 1.0.0.SNAPSHOT instead 1.0.0-SNAPSHOT

Broadleaf 5.2.7 - mysql migration

Hello I am using the latest version of Broadleaf (5.2.7). The project works perfectly fine running with HSQL. The problem is that I am trying to migrate to mysql. I am trying to follow the tutorials here and here
The problem is that I cannot find the dependancies in my root pom.xml that the tutorials mention
So for instance the tutorial mentions on step 3:
In your root pom.xml, find the following in the section under the with org.apache.tomcat.maven
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.1</version>
<type>jar</type>
<scope>compile</scope>
Where should this exist? I might have a huge misunderstanding here but I cannot find it.As far as I understand this is my root pom.xml (??) and it looks like this
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.broadleafcommerce</groupId>
<artifactId>broadleaf-boot-starter-parent</artifactId>
<version>5.2.7-GA</version>
<relativePath />
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany-community</groupId>
<artifactId>boot-community-demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Broadleaf Spring Boot Community Demo</name>
<repositories>
<repository>
<id>public snapshots</id>
<name>public snapshots</name>
<url>http://nexus.broadleafcommerce.org/nexus/content/groups/community-snapshots/</url>
</repository>
<repository>
<id>public releases</id>
<name>public releases</name>
<url>http://nexus.broadleafcommerce.org/nexus/content/groups/community-releases/</url>
</repository>
</repositories>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<google-closure-compiler.version>v20180506</google-closure-compiler.version>
<debug.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${debug.port}</debug.args>
<boot.jvm.memory>-Xmx1536M</boot.jvm.memory>
<boot.jvm.args>${boot.jvm.memory} ${debug.args}</boot.jvm.args>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.uri>${project.baseUri}</project.uri>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>${boot.jvm.args}</jvmArguments>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
<version>1.1.7</version>
<executions>
<execution>
<id>generate-rebel-xml</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>jrebel</id>
<properties>
<boot.jvm.args>${boot.jvm.memory} ${debug.args} ${jrebel.agent.args}</boot.jvm.args>
</properties>
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.mycompany-community</groupId>
<artifactId>boot-community-demo-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.javascript</groupId>
<artifactId>closure-compiler-unshaded</artifactId>
<version>${google-closure-compiler.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>core</module>
<module>site</module>
<module>admin</module>
<module>api</module>
</modules>
Any tips of what I am missing?
Thanks!!!
So I opened an issue at broadleaf's github and found a solution. This might be useful for anyone interested in the future:
https://github.com/BroadleafCommerce/DemoSite/issues/40
I would suggest to not follow the tutorials for migrating to mysql as it seems to be outdated. Follow the changes I describe in the github link.
The first time you create the db it might take up to 15+ minutes. Be prepared for that and don't stop the compiling process. After the first time you can change "blPU.hibernate.hbm2ddl.auto" from "create" to "none" or "update".
Finally after the update if you try and visit localhost:8081/admin you might get this error
2018-12-08 19:55:26.540 INFO 6616 --- [nio-8081-exec-3] o.apache.coyote.http11.Http11Processor : Error parsing HTTP request header
As contributors informed there's no known solution for that so what you can do is go directly to the https link : https://localhost:8444/admin

Export custom android eclipse project to maven build type

The goal was to export existing android eclipse project to maven type. To do this, it was required to download .m2 plugin. Right click on project and Configure-->Convert To Maven Project, what opened the window "Create new POM" with:
The question is what should be selected in packaging type while there is only jar/pom/war . I believe there should be "apklib" but when we type it there after pom.xml generation:
<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>X.0.0</modelVersion>
<groupId>Name</groupId>
<artifactId>Artifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apklib</packaging>
</project>
Eclipse response with :
Project build error: Unknown packaging: apklib
Regards
maven has no built-in packaging "apklib", which is probably why youre getting the error.
you havent specified which maven plugin youre using to build android artifacts, but assumming its this one your pom needs to look like this (taken from their samples)
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_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>com.simpligility.android</groupId>
<artifactId>helloflashlight</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>
<name>HelloFlashlight</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<!-- platform as api level (api level 16 = platform 4.1)-->
<platform>16</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>

Supporting android library projects with maven

I am writing an android library project and would like to add the support for maven. My library project pom file looks like this:
<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>my_group_id</groupId>
<artifactId>my_artifactId</artifactId>
<version>1.0.1</version>
<packaging>apklib</packaging>
<name>My Library Project</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>
<extensions>true</extensions>
<configuration>
<sdk>
<platform>19</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>
My main project pom file looks like this:
<?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>com.simpligility.android</groupId>
<artifactId>helloflashlight</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>
<name>HelloFlashlight</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>my_group_id</groupId>
<artifactId>my_artifactId</artifactId>
<version>1.0.1</version>
<type>apklib</type>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>
<extensions>true</extensions>
<configuration>
<sdk>
<platform>19</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>
I am installing the library project to my local repository using:
mvn clean install
then I am compiling and installing the main project to my local repository using:
mvn clean install
and generating the apk using:
mvn android:deploy
Now the problem occurs when I compile the project with maven. The project compiles successfully, however when I am running the apk on the device I receive NullPointerException when trying to perform findById for resources that are inside the library project. Please note that part of the time findById does return value, but not always the correct type (e.g, expected layout but got a button). It is important to say that when running in eclipse without maven everything works perfectly.
Please advise
Finally I found the solution, so I'll update my answer for future readers.
The solution to this problem was to create aar file instead of apklib file using maven.

Categories