Skip to content

Edit starters sometimes not adding 'bom' as needed by new dependency #313

Closed

Description

@kdvolder

To reproduce:

  • create "New Spring Starter" project with 'Reactive Web' starter selected
  • Use 'Edit Starters' to add 'Function' dependency.

If it works correctly a bom should be added like this:

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>${spring-cloud.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

But in reality, no bom gets added and the 'pom' will have an error marker on it because dependencies cannot be resolved.

Note: our 'add bom' code will not use a property like ${spring-cloud.version} to refer to the bom version. It will just include the version directly. This is normal, that's how it also worked originally in initalizer itself, but they changed it a while back (maybe it should be changed in edit starters too, but that is a different issue).

Activity

  1. kdvolder commented on Jun 27, 2019

    @kdvolder
    MemberAuthor

    Not entirely sure what is going 'wrong' exactly. But here is what happens when I add the 'Function Web'.

    • This dependency corresponds to a starter with id: 'cloud-function'.
    • sts requests a pom for the initial selection webflux and the final selection webflux + cloud-function
    • sts computes a delta between the <dependencies> section in both of these pom files.
    • the delta shows that one maven dependency was added: org.springframework.cloud:spring-cloud-function-web
    • sts searches the 'known starters' to find one corresponding to org.springframework.cloud:spring-cloud-function-web.
    • No such starter is found (This is probably the problem!!!)
      => normally in the next step STS would lookup the starter metadata and check if it requires a bom... then add the bom. This is not happening because starter was not found.

    How STS searches for known starters is by using the data from:

    https://start-development.cfapps.io/dependencies?bootVersion=2.1.6.RELEASE

  2. kdvolder commented on Jun 27, 2019

    @kdvolder
    MemberAuthor

    If we examine the info returned from the 'dependencies' url, this is what it lists for 'cloud-function':

    cloud-function: {
      groupId: "org.springframework.cloud",
      artifactId: "spring-cloud-function-context",
      scope: "compile",
      bom: "spring-cloud"
    }
    

    The problem is, that doesn't match the dependency that intializer actually added to the pom file. So essentially... the dependency that got added 'magically' instead of this one is unknown to the Edit Starters wizard and so it has no idea that it requires a bom.

  3. kdvolder commented on Jun 27, 2019

    @kdvolder
    MemberAuthor

    I've commited a 'fix' that addresses this specific case. However the 'dependency' metadata we are getting from intializer is fundamentally incomplete. So there's only so much that I can do about this in STS.

    The changes I've commited now rely on the 'diff' between two poms to determine when to add a bom to the pom. This works for this specific example.

    The problem that remains however is that any pom that has the 'web' variant of the cloud-function dependency will continue to confuse STS 'Edit Starters' to some degree because it is impossible for STS to look at a pom that contains that dependency and infer that it has the 'cloud-function' starter selected.

    A symptom of this problem that I could not fix is that if you create a project that has starters "webflux" and "cloud-function" as selected dependencies... then when you open "Edit Starters" on such a project you will not see the "cloud-function" dependency as selected. (Since no maven dependency listed in the pom is associated with the starter dependencies in the metadata STS receives from intializer service).

    THe only real way to fix is this on the initializer side.

  4. spring-projects-issues commented on Jul 12, 2019

    @spring-projects-issues

    (comment in Pivotal Tracker added by Nieraj Singh:)

    Verified in STS4 4.3.1. When I add "Function" via Edit Starters, the following got added to pom.xml:

    	<dependencyManagement>
    		<dependencies>
    			<dependency>
    				<groupId>org.springframework.cloud</groupId>
    				<artifactId>spring-cloud-dependencies</artifactId>
    				<version>Greenwich.SR2</version>
    				<type>pom</type>
    				<scope>import</scope>
    			</dependency>
    		</dependencies>
    	</dependencyManagement>
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions