I’m using a customized publication using Ivy in one of my projects and tried to externalize that into a Java plugin. So I simply created a class extending IvyPublishPlugin
and am applying my own class to the project. In the apply
-method I’m forwarding to the base class, because I hoped that would be enough already to properly configure the plugin with all its tasks etc.
The problem is that when I’m trying to access the publications which should have been created by IvyPublishPlugin
, there aren’t any. I have the feeling I’m simply too early or such, but don’t know further and didn’t find anything regarding that topic of help.
@Override
public void apply(Project project)
{
super.apply(project);
this.project = project;
//this.configPublication();
//this.configRepo();
project.afterEvaluate(new Action<Project>()
{
@Override
public void execute(Project paramT)
{
CustomIvyPublish.this.configPublication();
CustomIvyPublish.this.configRepo();
}
});
/*project.getExtensions().configure( PublishingExtension.class,
new Action<PublishingExtension>()
{
@Override
public void execute(PublishingExtension extension)
{
CustomIvyPublish.this.configPublication();
CustomIvyPublish.this.configRepo();
}
});*/
}
private void configPublication()
{
// TODO cleanup
Project project = this.project;
PublishingExtension publishing = this.getPusblishing();
Class<IvyPublication> pubsType = IvyPublication.class;
//Class<IvyPublicationInternal> pubsType = IvyPublicationInternal.class;
//Class<DefaultIvyPublication> pubsType = DefaultIvyPublication.class;
publishing.publications(new Action<PublicationContainer>()
{
@Override
public void execute(PublicationContainer pubs)
{
Logger logger = CustomIvyPublish.this.project.getLogger();
System.err.println("alles murks: ".concat(Integer.toString(pubs.size())));
pubs.forEach((pub) -> { System.err.println(pub.toString()); });
IvyPublication pub = pubs.withType(pubsType).iterator().next();
JavadocToJar task = JavadocToJar.findSelf(project);
Map<String, Object> artifact = ImmutableMap.of( "source", task,
"type", "javadoc");
pub.from(project.getComponents().findByName("java"));
pub.artifact(artifact);
CustomIvyPublish.this.configPubArtifacts(pub);
}
});
}
PublicationContainer
is always empty.
Is it even possible to extend some plugin this way? If so, when and how am I able to access the publications? Am I even able to reconfigure them at that point?
Thanks!