libgdx / gdx-pay

A libGDX cross-platform API for InApp purchasing.
Apache License 2.0
224 stars 83 forks source link

building -googleplay from source, deploying to local maven repo? #92

Closed junkdog closed 8 years ago

junkdog commented 8 years ago

What's the proper way to build the maven artifacts for the googleplay backend? I thought this would install everything:

$ ./gradlew -DLOCAL clean install

This installs everything except -googleplay, as it's not mentioned in the main build.gradle and seems to have a custom config going.

Btw, I could be wrong - not been exposed much to gradle, but I wasn't expecting a qualifier in build.gradle::libraryJar:

    task libraryJar(type: Jar, dependsOn:classes) {
        from sourceSets.main.output.classesDir
        if (configurations.findByName('compileAndIncludeClassesInLibraryJar') != null) {
            from configurations.compileAndIncludeClassesInLibraryJar.collect { it.isDirectory() ? it : zipTree(it) }
        }
        classifier = 'library' // <-- adds `-library` suffix right before `.jar` 
    }
keesvandieren commented 8 years ago

Hi,

Never used the 'install' task (I know its a maven goal, but did not know yet it is also available in Gradle as task :) )

We use this command:

./gradlew -PLOCAL uploadArchives

Add mavenLocal() repo to build script:

repositories { mavenLocal() }

This works fine for local testing.

The android module is of type android library (not jar). Therefore, there is an alternative publishing gradle script: publish_android.gradle. Maybe it is caused by a difference in publish_android.gradle and publish_java.gradle?

Hope this helps.

keesvandieren commented 8 years ago

Does the suggested solution help you out?

junkdog commented 8 years ago

Hi, sorry for the delay in getting back.

I never quite managed to get snapshot artifacts working - they looked correct in the m2 repo folder, but I think it failed to record the new snapshot. Maybe I placed the repositories { mavenLocal() }-part in the wrong section? Same result if completely omitted: older snapshot is downloaded from sonatype. In the end, I set the version to a non-snapshot version, which solved it.

We have working consumables on our end now; I'll send a PR once I get a chance to test it a bit more + clean it up a bit.

(heh, funny timing ;))

edit: my internal branches started drifting apparently; https://github.com/junkdog/gdx-pay/commits/maven has all the commits

junkdog commented 8 years ago

It'd be good to know if ./gradlew -PLOCAL uploadArchives correctly installs -SNAPSHOT artifacts into the local m2 repo or if it's me. Otherwise, feel free to close.

keesvandieren commented 8 years ago

It should be in the repository of sub-projects, not in buildscripts. We have this in our root build.gradle:

allprojects {
    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
}

Could you give that a little try :)?

If this works, I will publish this in some kind of guide.

junkdog commented 8 years ago

We have this in our root build.gradle

Is this the same file separate from build.gradle - or something more akin to maven's settings.xml? I only tried messing around with the aforementioned gdx-pay/build.gradle. It's possible I had some weird dirty state or something. I can see if I have any more success later this week.

keesvandieren commented 8 years ago

It has also been documented now on README, and I verified it to work correctly: https://github.com/libgdx/gdx-pay#using-gdx-pay-locally-build-binaries-in-a-project