This work well but for publishing.
Now in sub-projects I would like to benefit from this centralised configuration.
Unfortunately unless I (re)define the repos in the subproject build file in (publishing task). the publish
task do nothing as no repository is defined (I guess)
publishing {
publications {
maven(MavenPublication) {
groupId = 'foo'
artifactId = 'myartifact'
version = 1.0
from components.java
pom {
name = '..'
description = '...'
url = '....'
}
}
}
// <--- unless. I add again a repositories {} close here, nothing happen
}
This centralized declaration - as the name of the enclosing block suggests - is just for the repositories used to resolve dependencies, not for publishing.
Maybe you want to write some convention plugin that defines your repository for publishing that you can then use in the projects that should be published.
Btw. you should strongly consider not to use mavenLocal, especially not as first repository and without any content filter. Like this you make you build much slower than necessary and additionally you make it potentially flaky and unpredictable, as mavenLocal as invented by Maven is heavily broken by design.
Hi,
Thank for the reply.
Indeed as I do not want to duplicate information I would move the repository
declaration in my convention plugin.
The two things I am still struggling with (sorry to be slow , but I am learning at the same time) #1 - how do I reference the repository with the publishing block? I failed trying this.
something like
publishing {
publications {
maven(MavenPublication) {
...
pom {
...
}
}
}
repositories.add(<find the right one by name>)
}
#2 - how do I deal with credentials ? they are passed by properties at ‘root level’
Shall consumed them in the convention plugin or with the publish task ?
thank again.
PS ;I’ll keep in mind your comment on mavenLocal . thx!
how do I reference the repository with the publishing block? I failed trying this.
Show what you tried and you might get help.
But generally said, you don’t.
Your convention plugin sets it, either after applying the publishing plugin, or in reaction to it being applied using pluginManager.withPlugin.
And your project then applies the convention plugin and lets it do its work.
how do I deal with credentials ? they are passed by properties at ‘root level’
Your convention plugin does the same, the settings script was doing. You just define the repositories for resolving dependencies. You need to configure the publishing repositories in your conventions plugin as I suggested earlier already.