Code Monkey home page Code Monkey logo

Comments (23)

Wrywulf avatar Wrywulf commented on May 29, 2024 2

I could get around this by applying the 'maven-publish' plugin explicitly

from bintray-release.

blundell avatar blundell commented on May 29, 2024

You want to publish 1 jar with another jar inside it?
Or you want to publish 1 jar with a dependency on another jar?

from bintray-release.

jcranky avatar jcranky commented on May 29, 2024

Neither, just a new jar file, with a different classifier - a new artifact. Something like this:

task deobfJar(type: Jar) {
    from sourceSets.main.output
    classifier = 'deobf'
}

from bintray-release.

jcranky avatar jcranky commented on May 29, 2024

By the way, I currently have the task mentioned above and this

tasks.build.dependsOn('deobfJar')

which generates the -deobf.jar file. I just wanted to have it published together with the other 3 artifacts already being published :)

from bintray-release.

xrigau avatar xrigau commented on May 29, 2024

I'm not 100% sure but this wiki page might be useful https://github.com/novoda/bintray-release/wiki/Defining-a-custom-Publication

I think you need to define your own publication and add the atrifacts you want in there

from bintray-release.

jcranky avatar jcranky commented on May 29, 2024

I read that, but I don't know how to define my publication. Perhaps I'm not seeing something obvious because I don't know much about groovy and gradle - that's why the examples would be helpful, not just to me, but anyone in a similar situation :)

from bintray-release.

xrigau avatar xrigau commented on May 29, 2024

I assume you're working on a java project (not an android project)

See here you can use just a string to define an artifact https://github.com/novoda/bintray-release/blob/master/core/src/main/groovy/com/novoda/gradle/release/AndroidArtifacts.groovy#L29

So if you know what's the path to the jar you generate (the -deobf.jar one) then I think you can just extend the JavaArtifacts class and override the all() method to return the super plus your own artifact.

I'm not exactly sure about the syntax but something like:

class JavaWithDeobfArtifacts extends JavaArtifacts {

  @Override
  def all(Project project) {
    def list = super.all(project)
    list.add(deobfuscatedJar())
    return list
  }

  def deobfuscatedJar(Project project) {
    "$project.buildDir/foobar-deobf.jar" // TODO: Replace with the right path
  }

}

and then you should be able to use that with something like this:

    void attachArtifacts(Project project) {
        Artifacts artifacts = new JavaWithDeobfArtifacts()
        String projectVersion = getString(project, 'version', project.publish.version)
        project.publishing {
            publications {
                maven(MavenPublication) {
                    groupId project.publish.groupId
                    artifactId project.publish.artifactId
                    version projectVersion

                    artifacts.all(project).each {
                        delegate.artifact it
                    }

                    from artifacts.from(project)
                }
            }
        }
    }

and then call attachArtifacts() from your gradle script after applying the release plugin (probably after defining the publish closure).

I haven't checked that code so it might not work or be incomplete.

Let me know if that works and if it doesn't I'll try to replicate it with a simple project

from bintray-release.

jcranky avatar jcranky commented on May 29, 2024

Yes, it is a Java (Scala, actually, but it is the same from this perspective). Where should I put my custom JavaWithDeobfArtifacts?

from bintray-release.

xrigau avatar xrigau commented on May 29, 2024

the easiest would be to put it inside your build.gradle file directly

from bintray-release.

jcranky avatar jcranky commented on May 29, 2024

I should have though of that XD
I tried it and it didn't work with this error:

Caused by: org.gradle.api.InvalidUserDataException: Cannot add task ':sourcesJar' as a task with that name already exists.

from bintray-release.

ouchadam avatar ouchadam commented on May 29, 2024

I raised a PR to fix the task name issue, #42

from bintray-release.

xrigau avatar xrigau commented on May 29, 2024

@jcranky try again but using 0.2.10 and see if there's more luck

from bintray-release.

jcranky avatar jcranky commented on May 29, 2024

I'm still a bit lost on what I should do. I tried some stuff here and the best I got until now is

Caused by: org.gradle.api.InvalidUserDataException: Maven publication 'maven' cannot include multiple components

My current working build is here: https://github.com/easyforger/easyforger/blob/master/build.gradle, but without the custom publishing. Locally, the publish / publishing / publications doesn't seem to have any effect =(

from bintray-release.

ouchadam avatar ouchadam commented on May 29, 2024

have you also selected the publication like -

publish {
    userOrg = 'novoda'
    groupId = 'com.novoda'
    artifactId = rootProject.name
    version = project.version

    description = 'Super duper easy way to release your Android and other artifacts to bintray'
    website = "https://github.com/novoda/${rootProject.name}"

    publishing {
        publications {
            superPublication(MavenPublication) {
                groupId project.publish.groupId
                artifactId project.publish.artifactId
                version project.publish.version

                Artifacts artifacts = new JavaArtifacts()

                artifacts.all(it.name, project).each {
                    delegate.artifact it
                }

                from artifacts.from(project)
            }
        }
    }

    publications =["superPublication"]

}

The error seems like you've reused the maven publication name, it'll need to be unique!

from bintray-release.

jcranky avatar jcranky commented on May 29, 2024

You mean the publications =["superPublication"] line, right? I had it, but it seemed to be ignored. I'll try again later today from scratch and if I get different results I'll post back here.

from bintray-release.

jcranky avatar jcranky commented on May 29, 2024

For a quick try, what I did:

  1. update bintray-release to 0.2.10:
classpath 'com.novoda:bintray-release:0.2.10'
  1. Add this import:
import com.novoda.gradle.release.*
  1. added @ouchadam 's publishing block, and set the publications as well

With that, I couldn't get the results from the superPublication to run. I executed:

./gradlew --stacktrace clean build publishMavenPublicationToMavenLocal

And got:

:build
:generatePomFileForMavenPublication
:mavenJavadocJar
:mavenSourcesJar
:publishMavenPublicationToMavenLocal

Perhaps I'm not doing something I should be doing?

Also, IDEA shows me the publishing inside of the publish closure as underlined gray, meaning it doesn't seem to find it.

from bintray-release.

jcranky avatar jcranky commented on May 29, 2024

After some investigation, the problem seems to be that I was using publishMavenPublicationToMavenLocal. With bintrayUpload the custom publication is found.

I still have to do some more testing, but how can we have the same results with both publishMavenPublicationToMavenLocal and bintrayUpload? The idea is to use local maven publishing to test stuff, and the bintray upload when everything is ready.

thanks!

from bintray-release.

ouchadam avatar ouchadam commented on May 29, 2024

sorry for the delay

the "maven" part of "publishMavenPublicationToMavenLocal" is the publication name, so in the example I gave it was called "superPublication" would be "publishSuperPublicationPublicationToMavenLocal"

The ...publicationToMavenLocal task is done by default when using dryRun=true (which is also the default setting for bintrayUpload) which means bintrayUpload will always do a maven local deploy unless you provide dryRun=false and in that case it'll upload to bintray

hope that helps!

from bintray-release.

jcranky avatar jcranky commented on May 29, 2024

Perfect, thank you! bintrayUpload with dryRun fit the bill just fine. This is how I ended up setting up my publication, in case you want to use it as an example in the documentation:

import com.novoda.gradle.release.*

def deobfJarPublish(String publicationName, Project project) {
    project.task(publicationName + 'DeobfJar', type: Jar) {
        classifier = 'deobf'
        from sourceSets.main.output
    }
}

publish {
    ...
    dryRun = true

    publishing {
        publications {
            deobfPublication(MavenPublication) {
                groupId project.publish.groupId
                artifactId project.publish.artifactId
                publishVersion project.publish.publishVersion

                Artifacts artifacts = new JavaArtifacts()
                (artifacts.all(it.name, project) + deobfJarPublish(it.name, project)).each {
                    delegate.artifact it
                }
                from artifacts.from(project)
            }
        }
    }

    publications = ['deobfPublication']
}

I still find it a bit verbose, but it works :D

thank you!

from bintray-release.

friedger avatar friedger commented on May 29, 2024

Added a short wiki (https://github.com/novoda/bintray-release/wiki/Defining-an-additional-artifact)

from bintray-release.

jcranky avatar jcranky commented on May 29, 2024

I just updated to version 0.3.5 and the custom publication discussed above seems to be broken now:

Caused by: org.gradle.api.internal.MissingMethodException: Could not find method publishing() for arguments [build_12cycqr9h1kaaswhvdttv9vva$_run_closure5_closure10@1f71e024] on root project

Should I open a new issue? Or perhaps I missed something in the update process?

from bintray-release.

xrigau avatar xrigau commented on May 29, 2024

hey @jcranky there's an issue already #75

the temporary solution is to just revert back to 0.3.4 until we fix and release a new one

from bintray-release.

jcranky avatar jcranky commented on May 29, 2024

Uhmmm not sure if this is the same thing. Using 0.3.4 gives me the same result:

Caused by: org.gradle.api.internal.MissingMethodException: Could not find method publishing() for arguments [build_hvucr0990rgadjc575ptdeb4m$_run_closure5_closure10@384472bf] on root project

Reverting to 0.3.2 works though.

from bintray-release.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.