Reputation: 20585
I am trying to create a custom task so that I can publish to a specific repository that is not normally part of the project-level publishing {}
block in build.gradle
. My initial thought was to create a task of type PublishToIvyRepository
, which has a field for a custom repository. My code looks like this:
task publishToSpecialIvyRepo(type: PublishToIvyRepository) {
repository = ivy {
url "http://example.com/mySpecialIvyRepo"
layout 'pattern' , {
artifact '[organization]/[module]/[revision]/[artifact](-[revision])(-[classifier]).[ext]'
ivy '[organization]/[module]/[revision]/[artifact].[ext]'
}
}
publication = project.publishing.publications[0]
}
However, this doesn't seem to work because I get an error message involving not recognizing the ivy {}
syntax.
Could not find method ivy() for arguments [build_6twdleybkcdvojdar8mcpb96g$_run_closure7$_closure23@60c8966b] on task ':MyProject:publishToSpecialIvyRepo' of type org.gradle.api.publish.ivy.tasks.PublishToIvyR epository.
Unfortunately, the documentation about publishing to Ivy repositories doesn't describe writing your own PublishToIvyRepository
task, so I'm not sure what I'm doing wrong.
Is this the right approach to trying to publish to a specific repo? If so, then what am I doing incorrectly? Is there a better way to accomplish my goal?
Upvotes: 0
Views: 152
Reputation: 14503
The ivy
method is part of the RepositoryHandler
, so it is not available in the Project
or PublishToIvyRepository
task scope.
You can try to create the repository via the default RepositoryHandler
:
repository = repositories.ivy {
// configure the repository
}
Please note, that this method will add the repository to the list of repositories used for artifact resolution.
Upvotes: 1