Checking a JAR for android compatibility in maven - java

Some of our jar libraries should run on android, as well as normal JDKs. The jar is build by maven. Specifically I want to know:
Is it possible to build against another runtime library or to check the API compatibility?
Is there some maven plugin that runs the JUnit tests on an android platform?
What other verification steps should be taken to ensure that your library project will run on android?

Related

Can we build java application through build plagin of maven without installing local JDK

Can we build java web app through build plagin of maven without installing local JDK.
As we all know that we have plugins in POM.xml and maven is using them for different steps, So my question is that is it possible that I write java code with POM.xml file and then add build/compile plugins to that POM.xml file and then compile this code only through maven plugin instead of installing jdk locally ?
If this is not possible then what is purpose of adding build and compile plugins to POM file ?
The short answer, as #khmarbaise mentioned, is no. Building java applications without jdk is not an option.
Maven plugins solve issues, depending on the plugin they may move things, generate code or do similar things to make the real build possible. They do not in any way replace a jdk tho.

Version gradle for different modules

I am really confused about how gradle works with android subproject and simple server-java subproject tied to Project.
Android is using not the latest version of gradle, but my server app can use it.
Should I use the minimum version that supports all modules, or can I somehow edit the build file for each module?

IntelliJ plugin: maven, gradle and travis-ci

Currently, my built structure for a plugin in is a bit messy: I'm using the normal IDEA project file to build the plugin locally. When I push it to the repo and travis-ci is building it, it uses the maven pom.xml because for travis to work, it always has to download the complete IDEA sources.
Although this works, this has several drawbacks:
I need to keep two built mechanisms up to date. This is
When a new IDEA version is out (every few weeks), I need to change the SDK in maven and in my IDEA settings
When I add a new library, change resources, etc. I need to do this for two the two settings as well
I ran into problems when I kept the IDEA Maven plugin turned on because it saw the pom.xml and interfered with my local built. Turning it off means, I cannot download libraries with Maven which has the feature of tracking dependencies.
I saw that Gradle has an 'idea' plugin and after googling, I got the impression that Gradle is the preferred choice these days. I have seen Best way to add Gradle support to IntelliJ IDEA and I'm sure I can use the answers there to turn my pom.xml into a valid build.gradle.
However, maybe someone else has already done this or can provide a better approach. What I'm looking for is a unified way to build my plugin locally and on Travis-CI.
Some Details
For compiling an IDEA plugin, you need its SDK which you can access through an installation of IDEA or a download of the complete package. Locally, I'm using my installation for the SDK. With Travis, my maven built has the rule to download the tar.gz and extract it.
It turns out that in particular for building an IntelliJ plugin, Gradle seems to have many advantages. This is mainly due to the great IntelliJ plugin for Gradle which makes compiling plugins so much easier. With Gradle, I could turn my >220 lines of Maven build into a few lines of easily readable Gradle code. The main advantages are that
It takes care of downloading and using the correct IDEA SDK while you only have to specify the IDEA version.
It can publish your plugin to your Jetbrains repository and make it instantly available to all users
It fixes items in your plugin.xml, e.g. you can use one central version number in gradle.build and it will keep plugin.xml up-to-date or it can include change-notes
It seamlessly integrates with Travis-CI
How to use Gradle with an existing IDEA plugin
Do it manually. It's much easier.
Create an empty build.gradle file
Look at an example and read through the README (there are many build.gradle of projects at the end) to see what each intellij property does.
Adapt it to your plugin by
Setting the intellij.version you want to build against
Setting your intellij.pluginName
Define where your sources and resources are
Define your plugin version
Define a Gradle wrapper that enables people (and Travis) to build your plugin without having Gradle
Create the gradle wrapper scripts with gradle wrapper
Test and fix your build process locally with ./gradlew assemble
If everything works well, you can push build.gradle, gradlew, gradlew.bat and the gradle-folder to your repo.
Building with Travis-CI
For Travis you want to use the gradlew script for building. To do so, you need to make it executable in the travis run. An example can be found here.

Play framework and gradle

I would like to build the play framework with Gradle in a multiproject build.
The play application would be one of my gradle subprojects. The controllers in play, will call methods in my other gradle projects.
Gradle uses sbt by default. Should I just use sbt command line calls in the gradle build file? And if I do that, would I be able to package it as an application (e.g. a jar file)?
Native support for play is currently in the works for Gradle. This is still in development, but you can take a look at some sample projects in the samples/play directory of the 'all' distribution of Gradle 2.3.

Do I need to install an ADT plugin if I want to use Maven?

Is it necessary to download and install ADT plugin into Eclipse, if I want to build all projects using maven?
You might be able to get your project to build by just relying on maven, but you'd miss out on debug tools, Android-specific editors, the simulator, the ADB shell...
For a mavenized android project, if you are talking about build project from commandline, for instance, check out some projects from GitHub and do a mvn clean install, you only need install and setup:
Android SDK
Maven
If you are talking about develop/build project inside IDE like Eclipse, besides Android SDK and Maven, you need the following Eclipse plugins (all available via Eclipse Marketplace), in order to create/import and work on mavenized android project inside Eclipse:
adt
m2e (Maven Integration for Eclipse)
m2e-android (Android Configurator for M2E)
Check out answer here and see screenshot of installed Eclipse plugin.
the ADT plugin is required as It holds the APIs though I am not familiar with maven It would probably be a good idea to install the android ADT to get these APIs. also included in the ADT is the system images and java files needed to build on to create an app.
as I said I am not familiar with maven but I would still recommend installing android ADT

Categories

Resources