quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.88k stars 2.71k forks source link

Remove %dev and %test configuration values after build #17931

Closed hamburml closed 3 years ago

hamburml commented 3 years ago

Description

Quarkus uses dev and test configuration profiles (https://quarkus.io/guides/config). When we package the application inside a jar (uber-jar for example) the %dev and %test values are still in the application.properties.

I think it would be better if the %dev and %test config values are automatically removed. It's cleaner and if other developers, departments or simply third parties get the jar-file they cannot read the properties. The test-URLs or dev-credentials are not made public.

Implementation ideas

Maybe clear all %dev and %test values from the application.properties after it was copied to the target-folder.

famod commented 3 years ago

/cc @radcortez

famod commented 3 years ago

I like the general idea that such things usually should not end up in the "productive" artifact. A few remarks:

radcortez commented 3 years ago

I'm not totally convinced about this.

While it is true that both dev and test are active by default on quarkus:dev or when running a test, it is also perfectly valid to activate any of these profiles (or even a custom one) in the final package or runner. While I understand the request, I fear that we may be removing something that some users may be using.

My recommendation is to use the profile aware file application-test.properties, application-dev.properties and place those files outside main/resources. Quakus also looks like from an external config folder and the test properties may be placed in src/test/resources.

For reference:
https://quarkus.io/version/main/guides/config-reference#application-properties-file https://quarkus.io/version/main/guides/config-reference#profile-aware-files

aloubyansky commented 3 years ago

If you choose the profile-aware-files approach, you can also use ignoredEntries to filter those profile config files out from the uber-jar, e.g.

<configuration>
   <uberJar>true</uberJar>
   <ignoredEntries>
     <ignoredEntry>META-INF/BC2048KE.SF</ignoredEntry>
     <ignoredEntry>META-INF/BC2048KE.DSA</ignoredEntry>
     <ignoredEntry>META-INF/BC1024KE.SF</ignoredEntry>
     <ignoredEntry>META-INF/BC1024KE.DSA</ignoredEntry>
   </ignoredEntries>
 </configuration>
hamburml commented 3 years ago

I'll check out the profile aware files and ignoredEntry, thanks!

famod commented 3 years ago

@hamburml does it work?

I'm inclined to close this because as @radcortez wrote it might be really fragile to remove config like this.

famod commented 3 years ago

I'm closing this. Please open a new issue in case the `ignoredEntry``solution doesn't work for you.