Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to publish packages to a maven repository #499

Closed
sabberworm opened this issue Nov 11, 2019 · 7 comments
Closed

Document how to publish packages to a maven repository #499

sabberworm opened this issue Nov 11, 2019 · 7 comments

Comments

@sabberworm
Copy link
Collaborator

sabberworm commented Nov 11, 2019

Sorry if this has come up before or if it’s documented somewhere but I couldn’t figure out how to publish a generated content package to a maven repository.

If I understood everything correctly, the following should do that:

configure<PublishingExtension> {
    publications {
        create<MavenPublication>("aemPackage") {
            artifact(project.tasks.named("packageCompose"))
        }
    }
}

However this results in the following error during configuration:

* What went wrong:
Cannot convert the provided notation to an object of type MavenArtifact: task ':packageCompose'.
The following types/formats are supported:
  - Instances of MavenArtifact.
  - Instances of AbstractArchiveTask, for example jar.
  - Instances of PublishArtifact
  - Maps containing a 'source' entry, for example [source: '/path/to/file', extension: 'zip'].
  - Anything that can be converted to a file, as per Project.file()

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

This message confuses me since clearly :packageCompose is a task that inherits from com.cognifide.gradle.aem.common.tasks.ZipTask, which inherits from org.gradle.api.tasks.bundling.Zip, which, in turn, inherits from AbstractArchiveTask, as required.

I’m not sure if this is an issue with the gradle-aem-plugin or the maven-publishing plugin. I suspect this is not a bug but simply a misconfiguration on my part but I think it’s a common-enough use-case that it needs to be documented.

@sabberworm
Copy link
Collaborator Author

I figured out that using tasks.get("packageCompose") instead of tasks.named("packageCompose") fixes the error and lets me publish the generated package correctly. It would be good to have this in the documentation.

@pun-ky
Copy link
Contributor

pun-ky commented Nov 11, 2019

So that's for sure Gradle issue / not plugin related.

I am quite sure that I saw added support for your case in some recent version of gradle. I mean providers support in supplying Maven artifact to be published.

@pun-ky pun-ky closed this as completed Nov 11, 2019
@pun-ky
Copy link
Contributor

pun-ky commented Nov 11, 2019

Still I will consider documenting publication but... Then publishing to nexus, bintray and so on also should be documented to be consistent.

@pun-ky
Copy link
Contributor

pun-ky commented Nov 11, 2019

Don't hesitate to create PR 😉

@pun-ky
Copy link
Contributor

pun-ky commented Nov 19, 2019

just like a said earlier ... @sabberworm Gradle fixed this in 6.0.1
gradle/gradle#11054

@sabberworm
Copy link
Collaborator Author

I tried with Gradle 6.0.1 but it seems passing a NamedDomainObjectProvider<Task> to artifact is still unsupported, it needs to be a Task instance.

@pun-ky
Copy link
Contributor

pun-ky commented Nov 21, 2019

@sabberworm heh, but it was looking promising ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants