Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spring-boot-dependencies should not define a spring-boot.version property #23174

Closed
wilkinsona opened this issue Sep 3, 2020 · 5 comments
Closed
Assignees
Labels
type: bug A general bug
Milestone

Comments

@wilkinsona
Copy link
Member

The migration of the build to Gradle and the usage of our bom plugin has resulted in a spring-boot.version property in spring-boot-dependencies being introduced unintentionally. We should remove it for the reasons described in the following issues:

@wilkinsona wilkinsona added type: bug A general bug for: team-attention An issue we'd like other members of the team to review labels Sep 3, 2020
@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Sep 9, 2020
@philwebb philwebb added this to the 2.3.x milestone Sep 9, 2020
@wilkinsona wilkinsona modified the milestones: 2.3.x, 2.3.4 Sep 16, 2020
@wilkinsona wilkinsona self-assigned this Sep 16, 2020
@theHilikus
Copy link

theHilikus commented Oct 5, 2020

Is there any other property (or technique) that we should use to retrieve the current version of spring-boot? this issue broke our build since we were relying on this property to reconfigure some spring dependencies. Here's a snippet of our corporate-wide parent-pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.4.RELEASE</version>
        <relativePath/>
    </parent>
...
</dependencyManagement>
...
  </dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <version>${spring-boot.version}</version>
      <optional>true</optional>
      <scope>runtime</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <version>${spring-boot.version}</version>
      <exclusions> <!-- override only to exclude tomcat. Children still need to declare this AND the actual container to use -->
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
</dependencyManagement>

The first dependency is declared by spring-boot-dependencies as mandatory and with compile scope so we overwrite it here to optional and runtime (IMO this should be the default, but that's another discussion)
The second one is to avoid having each of our microservices to have to exclude tomcat explicitly since we are using jetty

With this technique all our projects can just declare a dependency to devtools and starter-web that are pre-configured while leaving the version number managed in the spring pom by you guys. Now we will have to duplicate the spring-boot version in the <parent> section and in these dependencies and not forget to keep them in sync

@alan-czajkowski
Copy link

alan-czajkowski commented Oct 6, 2020

@wilkinsona please undo the work of removing spring-boot.version, as it is vitally important to keep it, as described here: #5014 (comment)

@wilkinsona
Copy link
Member Author

Sorry for the inconvenience. Unfortunately, we won't be reinstating spring-boot.version as it was introduced accidentally as part of migrating our build to Gradle. While we are aware there are some uses for the property, experience has taught us that its presence does more harm than good.

@theHilikus
Copy link

But is there a proposed workaround? i.e. other official, more reliable, read-only way to know in the maven build what version of spring-boot a spring-boot-starter-parent is pulling? if not, would this be an acceptable feature request worth creating?

@wilkinsona
Copy link
Member Author

@theHilikus It depends on what you are trying to do.

Where you want to exclude Tomcat in favour of Jetty, I'd provide your own starter that depends on spring-boot-starter-web with spring-boot-starter-tomcat excluded and spring-boot-starter-jetty. Each of your web-based projects can then depend on this starter rather than having to depend on both spring-boot-starter-web and spring-boot-starter-jetty.

if not, would this be an acceptable feature request worth creating?

We're limited by Maven's capabilities here. We can suggest alternatives like the one above, but any feature request would have to be raised against Maven.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants