Skip to content

Update maven plugin to support smart exclusions #649

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

Closed
snicoll opened this issue Apr 9, 2014 · 4 comments
Closed

Update maven plugin to support smart exclusions #649

snicoll opened this issue Apr 9, 2014 · 4 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Apr 9, 2014

Boot's maven plugin creates executable jar/war with a somewhat specific semantic behind Maven's provided scope that would need smart exclusions options for advanced use cases

A lot of projects out there are relying on the provided Maven scope: plugins dependency, annotation processor, etc. In the end, this jar file should not be placed at all in the executable. There are other (nasty?) use cases that requires some advanced options of, for instance, the war-plugin: packaging-excludes is the most obvious (see some doc).

Boot brings a new use case: executable jars. Previously, Maven users were relying on features of either the Maven lifecycle (running custom code before the archive is packaged) or the war plugin. With executable jars, those features are gone.

A first attempt to solve this issue would be to introduce some smart exclusions, similar to the copy-dependencies goal of the maven-dependency-plugin, that is:

  • excludeArtifactIds
  • excludeClassifiers
  • excludeGroupIds
  • excludeScope

One would expect that the transitive dependencies of excluded dependencies are also excluded. This can tricky to achieve but the maven-dependency-tree shared component can help.

@philwebb
Copy link
Member

See #413 (comment) for some background of why we currently bundle provided dependencies.

@philwebb
Copy link
Member

I'm targeting this to 1.1 and I'm tempted to change the behavior at that point to exclude provided dependencies by default. The lombok example in #674 is the most compelling case that I've seen so far.

@snicoll
Copy link
Member Author

snicoll commented May 2, 2014

Quick summary of our brainstorming goes towards changing the behaviour and exclude provided dependencies by default. The problem is that the container itself is specified through that means.

In an ideal situation, the plugin should be updated to support an implicit list of "container dependencies" so instead of relying on starter-tomcat we would specify that dependency in the plugin's configuration instead. That way, the classpath would not contain the container anymore.

I need to investigate that a bit further to see if that's doable (i.e. via ProjectDependenciesResolver)

@snicoll
Copy link
Member Author

snicoll commented May 5, 2014

okay so back on this issue. The container should be on the classpath as the story is to start the app from the IDE by invoking a simple main method and no further tuning of the classpath is foreseen.

The original issue remains though (the container itself is specified through that means) and both the run and package goals are impacted by this issue. Note that in case of conflict between the container and used-defined provided dependencies, running the application from the IDE (i.e. without the plugin) would not work. It's important that the run goal behaves the same way as java -jar app.jar by default.

As our intend is to define the container through the provided scope, we should probably go the exclude way and document that a Spring boot-based project uses provided scope that way.

@snicoll snicoll closed this as completed in 15501ea May 6, 2014
snicoll pushed a commit that referenced this issue May 19, 2014
Previous to this commit, any groupId starting with one of the
configured exclude would be excluded as well. This potentially
leads to unintentional dependency filtering: for example the
GroupIdFilter with an exclusion of "org.springframework"
also removes "org.springframework.boot" dependencies.

Add MatchingGroupIdFilter that uses an exact match instead.

See #649
mdeinum pushed a commit to mdeinum/spring-boot that referenced this issue Jun 6, 2014
This commit provides several options to exclude one or more
dependencies:

* excludes allows to specify an arbitrary number of exclude sub
  element defining the groupId and artifactId of the dependency
  to exclude
* excludedGroupIds defines the comma separated list of groupIds
  to exclude
* excludeArtifactIds defines the comma separated list of artifactIds
  to exclude

While any artifact can be excluded, this is designed to exclude
provided-scoped dependencies that should not be bundled in the
executable jar/war.

The outcome of java -jar myapp.jar should be consistent with the run
goal: these exclusions are therefore applied to the classpath that
the run goal computes to launch the application.

This commit also adds some integration tests and updates the
plugin's documentation

Fixes spring-projectsgh-649, spring-projectsgh-650 and spring-projectsgh-674
mdeinum pushed a commit to mdeinum/spring-boot that referenced this issue Jun 6, 2014
Previous to this commit, any groupId starting with one of the
configured exclude would be excluded as well. This potentially
leads to unintentional dependency filtering: for example the
GroupIdFilter with an exclusion of "org.springframework"
also removes "org.springframework.boot" dependencies.

Add MatchingGroupIdFilter that uses an exact match instead.

See spring-projects#649
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants