Compiling a maven project with a class from an external jar file (which is not in the maven artifact)

I am a little new to java and very new to maven. I could use some terminology imperfectly.

Since I am developing my project, which I use to create maven, since I need classes that are not part of the main Java language, I added the corresponding section <dependency>to mine pom.xml(usually copied from mvnbrowser.com without my understanding of this very well), and I was able to use the classes I want. It works great.

Now I come across a java class that I want to use, apparently not available in the maven artifact. It com.android.sdklib.build.ApkBuilder, which is distributed along with the android SDK. I wrote a standalone java program to run my code; I will compile it with javac, and not with maven, and this works fine. To do this, I put the jar file containing the class I want sdklib.jarin my directory jre/lib/ext( /usr/local/jdk1.6.0/jre/lib/exton the FreeBSD machine), and my line import com.android.sdklib.build.ApkBuildercompiles fine, and I can access ApkBuilderand use it without any problems.

Now that I have copied my working code into my maven project and tried to build with mvn project, I get errors package com.android.sdklib.build does not existin the import line and errors cannot find symbol: class ApkBuilderwhere I refer to ApkBuilder.

Looking around the net, I found android-maven-pluginhere: http://code.google.com/p/maven-android-plugin/ . He passed me maven-android-sdk-deployerhere: https://github.com/mosabua/maven-android-sdk-deployer . At first, these findings seemed promising, but as far as I can tell, their goal is to develop Android applications using maven, which I am not trying to do. I just want my java program to manage android files apk, but the java program itself should not run on an Android device. Also, the Android SDK is designed to work with linux, not the FreeBSD that I use, so I cannot follow the installation instructions for maven-android-sdk-deployer. I also found an artifact calledmaven-apkbuilder-plugin, but it also looks like creating Android apps, and I haven’t seen any documentation for it. Therefore, I did not pursue these conclusions.

It seems the easiest way would be to get the compiler to look in my folder jre/lib/extfor the file sdklib.jarat startup mvn package. But perhaps this is not the way to go. Or maybe there is a simple change that I can make to my own pom.xml, which will make the compiler find sdklib.jar. I looked at the pom documentation at http://maven.apache.org/pom.html#Build_Settings , but did not see a way to do this. In any case, I am sure that there is at least one solution; I just don’t know this (yet).

? ApkBuilder , maven? , ? !!

+5
1

, . . .

:

mvn install:install-file       \
    -Dfile=<path-to-file>      \
    -DgroupId=<group-id>       \
    -DartifactId=<artifact-id> \
    -Dversion=<version>        \
    -Dpackaging=jar

, group-id, artifact-id version, - , , .

Android, .


.

, Maven Maven?

( , , , "", :)

+8

All Articles