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

When spring-boot-configuration-processor is a dependency exclude it automatically in spring-boot-maven-plugin's configuration #528

Closed
wilkinsona opened this issue Sep 3, 2020 · 7 comments
Assignees

Comments

@wilkinsona
Copy link
Contributor

As suggested by @mkheck, when a Maven project depends upon spring-boot-configuration-processor, we could automatically configure the following exclusion that's described in the reference documentation:

<project>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-configuration-processor</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
@snicoll
Copy link
Contributor

snicoll commented Dec 11, 2020

Blocked by spring-io/initializr#1165

@mkheck
Copy link

mkheck commented Dec 14, 2020

If I'm reading the other issue correctly and also correctly grokking the implication, there is already an exclude being processed that precludes this being added, per the docs?

@snicoll
Copy link
Contributor

snicoll commented Dec 14, 2020

I don't know what you mean by "the other issue" and "per the docs", I am afraid. If you're talking about the feature that we flag certain annotation processors to exclude them automatically, this is a 2.4+ feature only and the customiser handles that.

@mkheck
Copy link

mkheck commented Dec 14, 2020

"Per the docs" refers to the documentation @wilkinsona links in the issue in which it states that the developer must manually exclude the spring-boot-configuration-processor from the Maven plugin. The other issue is the one you reference directly above: spring-io/initializr#1165

Creating a Boot 2.4.1 project with the configuration processor using Initializr doesn't show the exclusion Andy and I discussed as captured in this issue. This is the plugin section from the Initializr-generated POM for 2.4.1:

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

The question really revolves around this:

Since we state this in the docs that...

If you have defined @ConfigurationProperties in your application, make sure to configure the spring-boot-maven-plugin to prevent the repackage goal from adding the dependency into the fat jar:

<project>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-configuration-processor</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

...couldn't we/shouldn't we do that automatically when generating the build file?

@mkheck
Copy link

mkheck commented Dec 14, 2020

@snicoll I believe some of the confusion is over the docs vs. the apparent reality (?) of 2.4+, as the current (2.4.1) docs still show the same set of steps for devs to take when using the configuration processor, implying it's still necessary.

@snicoll
Copy link
Contributor

snicoll commented Dec 14, 2020

Thanks for the additional context.

Creating a Boot 2.4.1 project with the configuration processor using Initializr doesn't show the exclusion Andy and I discussed as captured in this issue

It does not because this particular annotation processor has extra metadata and we filter it out automatically. See spring-projects/spring-boot#22036. If you select lombok that is the other annotation processor our production instance defines, you'll see the exclude. Alternatively, you can take that existing setup and chose another Spring Boot version (pre 2.4) and you'll see the exclude as well. All those, including the one you've described above does not include the annotation processor in the repackaged archive.

I believe some of the confusion is over the docs vs. the apparent reality (?) of 2.4+, as the current (2.4.1) docs still show the same set of steps for devs to take when using the configuration processor, implying it's still necessary

We're on the same page now. Yes, the doc should have been updated, thanks for spotting that. I've created spring-projects/spring-boot#24498

@mkheck
Copy link

mkheck commented Dec 14, 2020

Makes sense. Thank you @snicoll, this is good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants