What is the meaning of "ant maven-setup" in Roboelectic Maven Build? - android

I am trying to use RobolectricSample application for unit testing Android application.
In the instruction for installation of application with Maven the first step is
ant maven-setup. I could not understand why is this command required and what it will do?
Any explanation will be great help.

According to the Ant build file build.xml, ant maven-setup does two things:
maven-install-jars:
Install 2 required jar libraries (guice-2.0-no_aop.jar & maps.jar) into Maven local repository.
maven-set-android-sdk:
Reset Android SDK path in pom.xml iff <path> is defined in android-maven-plugin.
This is not a elegant solution, ideally all those tasks should be handled purely by Maven. However, as this project provide both Ant and Maven build, it reuse the script from Ant in Maven build lifecycle for convenience.

Related

Android library maven dependency from gitlab local server's private repository

We have a Gitlab local server with private repositories. It's only accesible inside our network.
We want a way to distribute our Android libraries as maven dependencies, instead of copying modules, aar/jar etc...
An example of what we want to achieve. We have an Android project A, and an Android library B, both in our Gitlab local server, A has B as dependency. This would be our A's app build gradle file:
dependencies {
...
implementation '...B'
}
From our understanding jitpack only supports public Gitlab servers for self hosted gits.
https://jitpack.io/docs/PRIVATE/#self-hosted-git
I ended up using JFrog's Artifactory OSS (open source). A repository where you will store your libraries. In my case through gradle, there are more solutions like maven, nugget etc, gradle is free, the others require to pay.
What you'll have to make this works:
A server for the Artifacotry OSS.
A .gitlab-ci.yml file in your Android's project root directory.
A publishing gradle task in your Android's library gradle file.
Access to your GitLab's library repository to define variables.
In the .gitlab-ci.yml is specified which GitLab's branch to listen to, so every time you make a push in that branch a pipeline will execute with the docker settings specified in .gitlab-ci.yml. This will download everything necessary in the docker to execute the gradle publishing task in your Android's library gradle file.
Artifactory OSS documentation
GitLab CI documentation

Cling how to install from github?

I trying include to project Cling, but before I never used manually install from maven.
On page instructions is:
Install Maven 3.2.3 or newer.
Install the Android SDK and set the ANDROID_HOME environment variable
to the SDK install directory.
Clone the Cling source:
git clone https://github.com/4thline/cling.git
Change into the cling/ directory.
Install everything into your local ~/.m2 Maven repository (this will
take a few minutes if all dependencies have to be downloaded for the
first time).
mvn clean install
If your build fails with Android/dex packaging errors, you forgot the clean.
Use Cling in your pom.xml with:
don't know why, but pom.xml not insert here
you can see pom.xml on github page
I have done 1,2,3,4 steps, but what is "Install everything" in step 5, how to do it ?
And last step with pom.xml, where need to put it?
Step 5 comes down to running the command mvn clean install from the command line.
Maven is configured with the help of a file, called the POM file. It is an XML file named pom.xml. This file contains everything that Maven will do during the build. One of those things is to compile the Java sources into a final artifact. To compile the source code, it needs to resolve its dependencies; that is, other libraries that Cling depends on. All of those required libraries are declared in this POM file.
Maven will automatically download every dependency of the project. It will store them (or install them in the Maven jargon) into a local repository. This repository is just a directory structure on your local drive that will contain every JAR and POM that Maven will have downloaded from the Internet (more precisely from remote repositories configured for the project).
Maven will only do that process once. When all the dependencies are installed in your local repository, it won't download them again (by default). That is why the very first build will be longer that the subsequent builds.
So, to go through step 5, you need to:
Open a command prompt
Go into the directory where you checked out Cling with the command git clone https://github.com/4thline/cling.git at step 3.
Go into the cling subdirectory.
There should be a pom.xml file here. This is the main entry point for Maven. Run the command mvn clean install from this location.
Step 6 targets the project you are building. When steps 1 to 5 are done, you have compiled and installed the latest version of Cling. Now is the time to use it then!
Well to use it, you need to create a Maven project (there are facilities for that with every major IDE like Eclipse or IntelliJ) and declare that your project will have a dependency on Cling. That declaration is done with this bit of XML in the POM file of your project.
<dependencies>
<dependency>
<groupId>org.fourthline.cling</groupId>
<artifactId>cling-core</artifactId>
<version>2.1.1-SNAPSHOT</version>
</dependency>
</dependencies>
I strongly suggest that you read the Maven book from Sonatype to get you acquainted with using Maven.

Build Jenkins: Android project with dependencies

I use Jenkins as an integration server. And, I try to build an Android project which contains many project dependencies without using Maven. So I want to ask how can I do this task?
You want to use a "free-style software project". You'll need to create an Ant build file and add your dependencies manually.
You could also look into using Ivy to manage your dependencies if you don't want to use Maven.

Packaging / Mavenizing commonsware components

I am using merge list in my android project and up until now I have just been shoving the source into my src root with the rest of my code. However I'm not modifying anything so I figured it was time to include this stuff as libraries. I clone the first repo and:
$ ant
Buildfile: /Users/user/dev/projects/cwac-sacklist/build.xml
BUILD FAILED
/Users/user/dev/projects/cwac-sacklist/build.xml:49: taskdef class com.android.ant.SetupTask cannot be found
using the classloader AntClassLoader[]
Total time: 0 seconds
It looks like this ant script is looking for some stuff created by the "android" tool.. but I don't see any docs.. but I see the missing prop sdk.dir.. so I create that in local.properties.. but then I get:
/Users/user/dev/libs/android-sdk-mac_x86/tools/ant/lib_rules.xml:126: Reference android.libraries.src not found.
What is the right way to go about packaging this stuff so I can shove it in my local maven repo? Or better yet, where can I find it pre-packaged or in an existing maven repo?
UPDATE - 2014-07-08
It looks like commonsware now has all this stuff in a proper repo:
from: https://github.com/commonsguy/cwac-sacklist
repositories {
maven {
url "https://repo.commonsware.com.s3.amazonaws.com"
}
}
dependencies {
compile 'com.commonsware.cwac:sacklist:1.0.0'
}
Your first error is a standard one, caused by a discrepancy between the build files in the repo and your version of the build tools. Simply run:
android update project -p ...
where ... is the path to the project in question, to update the build files.
Your second error is solved by adding the following lines to build.xml, just after the <setup/> tag:
<path id="android.libraries.src"><path refid="project.libraries.src" /></path>
<path id="android.libraries.jars"><path refid="project.libraries.jars" /></path>
You will see those lines in the MergeAdapter edition of build.xml, though they apparently are not in the SackOfViewsAdapter build.xml file, as I have not touched that project in some time.
Or better yet, where can I find it pre-packaged or in an existing maven repo?
If there is one, it's unofficial, as I am not a Maven user.

Android Maven and Refresh Problem

i've a strange problem with maven and android
I've 3 maven project and 2 normal java maven project divided in this manner :
normal project :
model project ... packaged as jar ... contains java Pojo Bean and Interface.
Dao Project ... packaged as jar ... contains Db Logic - Depend on model Project
Android Application Maven project
ContentProvider ... packaged as apk ... contains ContentProviders only. Depends on Dao Project
Editors ... packaged as apk ... contains only Editor, Depends on Dao project
MainApp ... packaged as apk ... contains MyApp, Depends on DAO ...
The Problem is that if i modify DAO Project , Then do a maven clean and maven install of all apk project, then run as Android Application within Eclipse, i don't see updated app on my Emulator.
Nicely if i shut down my ubuntu workstation and restart it i can see The updated app on my Emulator.
Do you know a solution for this issue ?
thanks and regards
Occasionally, I will have to remove the app from the emulator to get the new version to deploy properly from within Eclipse. I use the following maven command from within the project directory to remove the app. This command assumes you are using the Android Maven Plugin with your Android app.
mvn android:undeploy
Conversely, you can also deploy the app with the following command.
mvn android:deploy

Categories

Resources