Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
fb3796da
Commit
fb3796da
authored
Apr 14, 2021
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x' into 2.4.x
Closes gh-26121
parents
1f012703
fcb2210a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
4 deletions
+83
-4
MavenPublishingConventions.java
...pringframework/boot/build/MavenPublishingConventions.java
+28
-3
build.gradle
...t/spring-boot-tools/spring-boot-maven-plugin/build.gradle
+1
-1
EclipseM2eIntegrationTests.java
...pringframework/boot/maven/EclipseM2eIntegrationTests.java
+54
-0
No files found.
buildSrc/src/main/java/org/springframework/boot/build/MavenPublishingConventions.java
View file @
fb3796da
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -19,7 +19,10 @@ package org.springframework.boot.build;
import
org.apache.maven.artifact.repository.MavenArtifactRepository
;
import
org.gradle.api.Project
;
import
org.gradle.api.attributes.Usage
;
import
org.gradle.api.component.AdhocComponentWithVariants
;
import
org.gradle.api.component.ConfigurationVariantDetails
;
import
org.gradle.api.plugins.JavaPlugin
;
import
org.gradle.api.plugins.JavaPluginConvention
;
import
org.gradle.api.plugins.JavaPluginExtension
;
import
org.gradle.api.publish.PublishingExtension
;
import
org.gradle.api.publish.maven.MavenPom
;
...
...
@@ -49,8 +52,6 @@ import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
* </ul>
* </ul>
*
* <p/>
*
* @author Andy Wilkinson
* @author Christoph Dreis
* @author Mike Smithson
...
...
@@ -80,6 +81,7 @@ class MavenPublishingConventions {
customizePom
(
publication
.
getPom
(),
project
);
project
.
getPlugins
().
withType
(
JavaPlugin
.
class
)
.
all
((
javaPlugin
)
->
customizeJavaMavenPublication
(
publication
,
project
));
suppressMavenOptionalFeatureWarnings
(
publication
);
}
private
void
customizePom
(
MavenPom
pom
,
Project
project
)
{
...
...
@@ -98,12 +100,35 @@ class MavenPublishingConventions {
}
private
void
customizeJavaMavenPublication
(
MavenPublication
publication
,
Project
project
)
{
addMavenOptionalFeature
(
project
);
publication
.
versionMapping
((
strategy
)
->
strategy
.
usage
(
Usage
.
JAVA_API
,
(
mappingStrategy
)
->
mappingStrategy
.
fromResolutionOf
(
JavaPlugin
.
RUNTIME_CLASSPATH_CONFIGURATION_NAME
)));
publication
.
versionMapping
((
strategy
)
->
strategy
.
usage
(
Usage
.
JAVA_RUNTIME
,
(
mappingStrategy
)
->
mappingStrategy
.
fromResolutionResult
()));
}
/**
* Add a feature that allows maven plugins to declare optional dependencies that
* appear in the POM. This is required to make m2e in Eclipse happy.
* @param project the project to add the feature to
*/
private
void
addMavenOptionalFeature
(
Project
project
)
{
JavaPluginExtension
extension
=
project
.
getExtensions
().
getByType
(
JavaPluginExtension
.
class
);
JavaPluginConvention
convention
=
project
.
getConvention
().
getPlugin
(
JavaPluginConvention
.
class
);
extension
.
registerFeature
(
"mavenOptional"
,
(
feature
)
->
feature
.
usingSourceSet
(
convention
.
getSourceSets
().
getByName
(
"main"
)));
AdhocComponentWithVariants
javaComponent
=
(
AdhocComponentWithVariants
)
project
.
getComponents
()
.
findByName
(
"java"
);
javaComponent
.
addVariantsFromConfiguration
(
project
.
getConfigurations
().
findByName
(
"mavenOptionalRuntimeElements"
),
ConfigurationVariantDetails:
:
mapToOptional
);
}
private
void
suppressMavenOptionalFeatureWarnings
(
MavenPublication
publication
)
{
publication
.
suppressPomMetadataWarningsFor
(
"mavenOptionalApiElements"
);
publication
.
suppressPomMetadataWarningsFor
(
"mavenOptionalRuntimeElements"
);
}
private
void
customizeOrganization
(
MavenPomOrganization
organization
)
{
organization
.
getName
().
set
(
"Pivotal Software, Inc."
);
organization
.
getUrl
().
set
(
"https://spring.io"
);
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle
View file @
fb3796da
...
...
@@ -33,7 +33,7 @@ dependencies {
intTestImplementation
(
"org.testcontainers:testcontainers"
)
intTestImplementation
(
"org.testcontainers:junit-jupiter"
)
optional
(
"org.apache.maven.plugins:maven-shade-plugin"
)
mavenOptionalImplementation
(
"org.apache.maven.plugins:maven-shade-plugin"
)
runtimeOnly
(
"org.sonatype.plexus:plexus-build-api"
)
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/EclipseM2eIntegrationTests.java
0 → 100644
View file @
fb3796da
/*
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
maven
;
import
java.io.File
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.util.FileCopyUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Tests to check that our plugin works well with Eclipse m2e.
*
* @author Phillip Webb
*/
public
class
EclipseM2eIntegrationTests
{
@Test
// gh-21992
void
pluginPomIncludesOptionalShadeDependency
()
throws
Exception
{
SpringBootDependenciesBom
bom
=
new
SpringBootDependenciesBom
();
String
version
=
bom
.
get
(
"version"
);
File
repository
=
new
File
(
"build/int-test-maven-repository"
);
File
pluginDirectory
=
new
File
(
repository
,
"org/springframework/boot/spring-boot-maven-plugin/"
+
version
);
File
[]
pomFiles
=
pluginDirectory
.
listFiles
(
this
::
isPomFile
);
Arrays
.
sort
(
pomFiles
,
Comparator
.
comparing
(
File:
:
getName
));
File
pomFile
=
pomFiles
[
pomFiles
.
length
-
1
];
String
pomContent
=
new
String
(
FileCopyUtils
.
copyToByteArray
(
pomFile
),
StandardCharsets
.
UTF_8
);
assertThat
(
pomContent
).
contains
(
"maven-shade-plugin"
);
}
private
boolean
isPomFile
(
File
file
)
{
return
file
.
getName
().
endsWith
(
".pom"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment