Hi,
In our build we package up various third party binaries which include executables, libraries, archives compressed or not, etc. These third party binaries are not in a maven or ivy repository but we are starting to put them into our own maven repository. It would be convenient to use gradle’s maven publishing capabilities to do this. Once they are published then of course we need to retrieve them and manipulate them in all kinds of ways.
The current solution is a bit clunky but it works:
def ncbiBlastGroupId = 'gov.nih.nlm.ncbi'
def ncbiBlastArtifactId = 'ncbi-blast'
def ncbiBlastVersion = '2.8.1+'
def artifactsDir = 'external'
def ncbiBlastResourcesDir = 'web/BLAST'
def linux64TarballClassifier = 'x64-linux'
def linux64TarballExtension = 'tar.gz'
def linux64TarballFile = file("$artifactsDir/$ncbiBlastArtifactId-$ncbiBlastVersion-${linux64TarballClassifier}.$linux64TarballExtension")
def linux64TarballArtifact = artifacts.add('archives', linux64TarballFile) {
classifier = linux64TarballClassifier
type = 'tgz'
extension = linux64TarballExtension
}
publishing {
publications {
if (updateExternalArtifacts) {
ncbiBlast(MavenPublication) {
groupId ncbiBlastGroupId
artifactId ncbiBlastArtifactId
version ncbiBlastVersion
artifact linux64TarballArtifact
}
}
}
}
configurations {
ncbiBlastArchives
}
dependencies {
if (!updateExternalArtifacts) {
ncbiBlastArchives(group: ncbiBlastGroupId, name: ncbiBlastArtifactId, version: ncbiBlastVersion, classifier: linux64TarballClassifier, ext: linux64TarballExtension)
}
}
prepareResources {
doLast {
copy {
from configurations.ncbiBlastArchives.files
into ncbiBlastResourcesDir
}
}
}
cleanResources {
doLast {
delete "$ncbiBlastResourcesDir"
}
}
When there is a new version we download it to the external
directory, update the version variable, then run ./gradlew publish -DupdateExternalArtifacts
.
I have been trying to create my own plugin so that I could define something like:
externalResources {
artifactsDirectory = 'external'
resources {
ncbiBlast(MavenExternalResourcePublication) {
groupId 'gov.nih.nlm.ncbi'
artifactId 'ncbi-blast'
version '2.8.1+'
artifact(TarballArtifact)
}
}
}
prepareResources {
copy {
from configurations.ncbiBlastArchives.files
into 'web/BLAST'
}
}
I am having a whole lot of trouble because so many things are in the internal API.
I initially tried to copy the MavenPublishPlugin
but I can’t create a PublicationContainer
and implementing one is virtually impossible.
I quickly gave up on that and just went to stick with a normal NamedDomainObjectContainer
and go down the route of extending MavenPublication
. This is even worse. It requires implementations of MavenPom
, MavenArtifact
, MavenArtifactSet
and maybe others. All the defaults would be perfectly adequate but they are internal. It would be really nice if these defaults could be public. Surely at version 5 the API is stable enough to commit to it.
I’m getting tempted to just get the defaults using reflection. The future cost of fixing things when that breaks is going to be way less than implementing any of these interfaces myself.
Is there any other way to create instances of these things? The Instantiator
is also internal so that is out. I see javax.inject
annotations through the examples but I’ve never seen how these are used, regardless I don’t think any of the interfaces I am interested in use these.
Any help would be appreciated.
Cheers,
Jason