Skip to content

Commit

Permalink
Fix publishing
Browse files Browse the repository at this point in the history
- Breaking change in artifactory plugin with gradle 8.x
  which mean we need to go back to maven publish instead
  of relying archives configuration.
- Relates #1145
  • Loading branch information
jvalkeal committed Mar 14, 2024
1 parent 362e5f0 commit 7a81d6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ void apply(Project project) {
// bom is not a java project so plugin doesn't
// add defaults for publications.
aTask.publications("mavenJava");
aTask.publishConfigs("archives");

// plugin is difficult to work with, use this hack
// to set props before task does its real work
Expand All @@ -63,7 +62,7 @@ void apply(Project project) {
ArtifactSpec spec = ArtifactSpec.builder()
.artifactNotation("*:*:*:*@zip")
// archives is manually set for zip in root plugin
.configuration("archives")
.configuration("mavenJava")
.properties(propsMap)
.build();
artifactSpecs.add(spec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.gradle.api.Project;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.PluginManager;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.MavenPublication;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.bundling.Zip;
Expand All @@ -40,6 +42,7 @@ public void apply(Project project) {
PluginManager pluginManager = project.getPluginManager();
pluginManager.apply(MavenPublishPlugin.class);
pluginManager.apply(PublishLocalPlugin.class);
pluginManager.apply(SpringMavenPlugin.class);
new ArtifactoryConventions().apply(project);
Javadoc apiTask = createApiTask(project);
Zip zipTask = createZipTask(project);
Expand All @@ -65,7 +68,14 @@ private Zip createZipTask(Project project) {
});
});

project.getArtifacts().add("archives", zipTask);
project.getPlugins().withType(MavenPublishPlugin.class).all(mavenPublish -> {
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
publishing.getPublications().withType(MavenPublication.class)
.all(mavenPublication -> {
mavenPublication.artifact(zipTask);
});
});

return zipTask;
}

Expand Down

0 comments on commit 7a81d6b

Please sign in to comment.