0
votes

I'm using Android Studio with LibGDX and I'm trying to create a gradle task to export android project as a jar. I have added the following code to default build.gradle file under android project folder:

task exportMyLib(type: Jar){
    from android.sourceSets.main.java.srcDirs
}

That orks fine to export source files. But I need to export compiled classes also - how can I do that?

1
I'm curious what you're trying to do with an Android app on a jar.Tenfour04
Android is only part of it. I have created my own library based on LibGDX. It has classes related to android, desktop and html projects. When I was using Eclipse I could simply export this lib as a Jar and select all classes that I neede to export (from different projects). Now with Android studio I'm trying to do just the same using gradle. I have figured out how to export data from html and core projects, but cannot figure out android - hence this question.Lez77

1 Answers

0
votes

Maybe this would be interesting to somebody else out there -I have finally come up with this:

task exportMyLib(dependsOn: build, type: Jar) {
    from android.sourceSets.main.java.srcDirs
    from('build/intermediates/classes/release/')
    from project(':core').sourceSets.main.output.classesDir
    from project(':core').sourceSets.main.allSource
}

I don't like the fact that it uses hardcoded path instead of variable, but I could not figure this out otherwise.