Skip to content

Commit 749f22d

Browse files
committed
Re-instate the PublishLocalPluin.
Use the PublishLocalPlugin to review and verify Project artifacts locally before they are published to a remove repository, such as Artifactory or Maven Central.
1 parent eeab7c1 commit 749f22d

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2017-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13+
* or implied. See the License for the specific language governing
14+
* permissions and limitations under the License.
15+
*/
16+
package org.springframework.gradle.maven;
17+
18+
import java.io.File;
19+
20+
import org.gradle.api.Plugin;
21+
import org.gradle.api.Project;
22+
import org.gradle.api.publish.PublishingExtension;
23+
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
24+
25+
/**
26+
* Gradle Plugin used to publish all {@link Project} artifacts locally
27+
* under {@literal rootProject/buildDir/publications/repos}.
28+
*
29+
* This is useful for inspecting the generated {@link Project} artifacts to ensure they are correct
30+
* before publishing the {@link Project} artifacts to Artifactory or Maven Central.
31+
*
32+
* @author Rob Winch
33+
* @author John Blum
34+
* @see org.gradle.api.Plugin
35+
* @see org.gradle.api.Project
36+
* @since 2.0.0
37+
*/
38+
public class PublishLocalPlugin implements Plugin<Project> {
39+
40+
@Override
41+
public void apply(Project project) {
42+
43+
project.getPlugins().withType(MavenPublishPlugin.class).all(mavenPublish -> {
44+
45+
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
46+
47+
publishing.getRepositories().maven(maven -> {
48+
maven.setName("local");
49+
maven.setUrl(new File(project.getRootProject().getBuildDir(), "publications/repos"));
50+
});
51+
});
52+
}
53+
}

buildSrc/src/main/java/org/springframework/gradle/maven/SpringMavenPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public void apply(Project project) {
4141
pluginManager.apply(MavenPublishingConventionsPlugin.class);
4242
pluginManager.apply(PublishAllJavaComponentsPlugin.class);
4343
pluginManager.apply(PublishArtifactsPlugin.class);
44+
pluginManager.apply(PublishLocalPlugin.class);
4445
pluginManager.apply(SpringSigningPlugin.class);
4546
pluginManager.apply(ArtifactoryPlugin.class);
4647
}

0 commit comments

Comments
 (0)