Skip to content

Conversation

jorsol
Copy link
Member

@jorsol jorsol commented Jul 29, 2024

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Does ./gradlew styleCheck pass ?
  3. Have you added your new test classes to an existing test suite in alphabetical order?

Changes to Existing Features:

  • Does this break existing behaviour? If so please explain.
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

@vlsi
Copy link
Member

vlsi commented Jul 29, 2024

Could you please clarify what exact issue does the PR resolve?

@jorsol
Copy link
Member Author

jorsol commented Jul 29, 2024

Is just a chore to avoid duplicated license copies in the sourceDistribution.

@vlsi
Copy link
Member

vlsi commented Jul 29, 2024

Is just a chore to avoid duplicated license copies in the sourceDistribution.

The PR title says "exclude META-INF/LICENSE", so I assumed you wanted to exclude it completely.
If there's another copy with the same contents, then, well, something like "keep license under ..." would do better to convey the intention.

By the way, what are the duplicates in your opinion?

@jorsol jorsol force-pushed the exclude-license-sourceDistribution branch from 0d854a3 to e570e2d Compare July 29, 2024 12:53
@jorsol jorsol changed the title Exclude META-INF/LICENSE from sourceDistribution Avoid duplicate dependencies licenses in sourceDistribution Jul 29, 2024
@jorsol
Copy link
Member Author

jorsol commented Jul 29, 2024

The PR title says "exclude META-INF/LICENSE", so I assumed you wanted to exclude it completely. If there's another copy with the same contents, then, well, something like "keep license under ..." would do better to convey the intention.

Agree, it was not clear, I changed the title to "Avoid duplicate dependencies licenses in sourceDistribution"

By the way, what are the duplicates in your opinion?

When building the source distribution, it contains the LICENSE file in
src/main/resources/META-INF/licenses/com.ongres.scram/scram-client-3.1/LICENSE
src/main/resources/META-INF/licenses/com.ongres.scram/scram-client-3.1/META-INF/LICENSE

This excludes the META-INF/LICENSE one, which works similarly to how is excluded on the shadowJar.

I guess you could handle this better on the com.github.vlsi.gradle-extensions plugin but I'm unsure how to improve that.

@vlsi
Copy link
Member

vlsi commented Jul 29, 2024

I believe "extra" copies come from https://github.com/pgjdbc/pgjdbc/tree/cdf429c5e774aa66df4dbe24e2b7f74e756f5e7f/licenses

Have you tried removing them instead?

@jorsol
Copy link
Member Author

jorsol commented Jul 29, 2024

I believe "extra" copies come from https://github.com/pgjdbc/pgjdbc/tree/cdf429c5e774aa66df4dbe24e2b7f74e756f5e7f/licenses

Have you tried removing them instead?

Yes, I tried removing them, but it does not work as expected, the shadowJar adds two META-INF/LICENSE on the jar:

...
        0  02-01-1980 00:00   META-INF/services/
       22  02-01-1980 00:00   META-INF/services/java.sql.Driver
     1269  02-01-1980 00:00   META-INF/LICENSE
...
...
...
     1708  02-01-1980 00:00   META-INF/LICENSE
        0  02-01-1980 00:00   META-INF/licenses/
        0  02-01-1980 00:00   META-INF/licenses/com.ongres.scram/
        0  02-01-1980 00:00   META-INF/licenses/com.ongres.scram/scram-client-3.1/
        0  02-01-1980 00:00   META-INF/licenses/com.ongres.scram/scram-client-3.1/META-INF/
     1269  02-01-1980 00:00   META-INF/licenses/com.ongres.scram/scram-client-3.1/META-INF/LICENSE
        0  02-01-1980 00:00   META-INF/licenses/com.ongres.scram/scram-common-3.1/
        0  02-01-1980 00:00   META-INF/licenses/com.ongres.scram/scram-common-3.1/META-INF/
     1269  02-01-1980 00:00   META-INF/licenses/com.ongres.scram/scram-common-3.1/META-INF/LICENSE
        0  02-01-1980 00:00   META-INF/licenses/com.ongres.stringprep/
        0  02-01-1980 00:00   META-INF/licenses/com.ongres.stringprep/saslprep-2.2/
        0  02-01-1980 00:00   META-INF/licenses/com.ongres.stringprep/saslprep-2.2/META-INF/
     1269  02-01-1980 00:00   META-INF/licenses/com.ongres.stringprep/saslprep-2.2/META-INF/LICENSE
        0  02-01-1980 00:00   META-INF/licenses/com.ongres.stringprep/stringprep-2.2/
        0  02-01-1980 00:00   META-INF/licenses/com.ongres.stringprep/stringprep-2.2/META-INF/
     1269  02-01-1980 00:00   META-INF/licenses/com.ongres.stringprep/stringprep-2.2/META-INF/LICENSE

Maybe a bug on the dependencyLicenses?

@jorsol jorsol force-pushed the exclude-license-sourceDistribution branch from e570e2d to a5f8c40 Compare July 29, 2024 15:37
@jorsol jorsol changed the title Avoid duplicate dependencies licenses in sourceDistribution Cleanup dependency licenses as are now included on the original JARs Jul 29, 2024
@jorsol
Copy link
Member Author

jorsol commented Jul 29, 2024

Check the latest changes, and the shadow JAR contains a duplicate META-INF/LICENSE

@vlsi
Copy link
Member

vlsi commented Jul 30, 2024

Yes, I tried removing them, but it does not work as expected, the shadowJar adds two META-INF/LICENSE on the jar:

Can you please clarify the exact command you perform to check for the duplicates?

I tried a5f8c40, and ../gradlew osgiJar does not produce duplicate files there:

% unzip -l postgresql-42.7.4-SNAPSHOT-osgi.jar  | grep LICE
     1708  02-01-1980 00:00   META-INF/LICENSE
     1269  02-01-1980 00:00   META-INF/licenses/com.ongres.scram/scram-client-3.1/META-INF/LICENSE
     1269  02-01-1980 00:00   META-INF/licenses/com.ongres.scram/scram-common-3.1/META-INF/LICENSE
     1269  02-01-1980 00:00   META-INF/licenses/com.ongres.stringprep/saslprep-2.2/META-INF/LICENSE
     1269  02-01-1980 00:00   META-INF/licenses/com.ongres.stringprep/stringprep-2.2/META-INF/LICENSE

@jorsol
Copy link
Member Author

jorsol commented Jul 30, 2024

Check the -all jar:

$ unzip -l build/libs/postgresql-42.7.4-SNAPSHOT-all.jar | grep LICENSE
     1269  02-01-1980 00:00   META-INF/LICENSE
     1708  02-01-1980 00:00   META-INF/LICENSE
     1269  02-01-1980 00:00   META-INF/licenses/com.ongres.scram/scram-client-3.1/META-INF/LICENSE
     1269  02-01-1980 00:00   META-INF/licenses/com.ongres.scram/scram-common-3.1/META-INF/LICENSE
     1269  02-01-1980 00:00   META-INF/licenses/com.ongres.stringprep/saslprep-2.2/META-INF/LICENSE
     1269  02-01-1980 00:00   META-INF/licenses/com.ongres.stringprep/stringprep-2.2/META-INF/LICENSE

@vlsi
Copy link
Member

vlsi commented Jul 30, 2024

I would suggest the following:

diff --git a/pgjdbc/build.gradle.kts b/pgjdbc/build.gradle.kts
index 86a06b55..9c5e6fa1 100644
--- a/pgjdbc/build.gradle.kts
+++ b/pgjdbc/build.gradle.kts
@@ -218,9 +218,12 @@ tasks.shadowJar {
     exclude("META-INF/versions/9/module-info.class")
     // ignore service file not used in shaded dependency
     exclude("META-INF/services/com.ongres.stringprep.Profile")
-    into("META-INF") {
-        dependencyLicenses(shadedLicenseFiles)
-    }
+    // We explicitly exclude all license-like files, and we re-add them in osgiJar later
+    // It looks like shadowJar can't filter out META-INF/LICENSE, and files with the same name
+    exclude("META-INF/LICENSE*")
+    exclude("META-INF/NOTICE*")
+    exclude("LICENSE")
+    exclude("NOTICE")
     listOf(
             "com.ongres"
     ).forEach {
@@ -231,6 +234,9 @@ tasks.shadowJar {
 val osgiJar by tasks.registering(Bundle::class) {
     archiveClassifier.set("osgi")
     from(tasks.shadowJar.map { zipTree(it.archiveFile) })
+    into("META-INF") {
+        dependencyLicenses(shadedLicenseFiles)
+    }
     bundle {
         bnd(
             """

@jorsol jorsol force-pushed the exclude-license-sourceDistribution branch from a5f8c40 to ee4fe84 Compare July 30, 2024 09:42
…l JARs

Signed-off-by: Jorge Solórzano <jorsol@gmail.com>
@jorsol jorsol force-pushed the exclude-license-sourceDistribution branch from ee4fe84 to 53c7dd0 Compare August 1, 2024 20:27
@jorsol jorsol changed the title Cleanup dependency licenses as are now included on the original JARs Clean up dependency licenses, as they are now included in the origina… …l JARs Aug 1, 2024
@jorsol jorsol changed the title Clean up dependency licenses, as they are now included in the origina… …l JARs Clean up dependency licenses, as they are now included in the original JARs Aug 1, 2024
@jorsol jorsol changed the title Clean up dependency licenses, as they are now included in the original JARs Clean up deps licenses, as they are now included in the original JARs Aug 1, 2024
@jorsol jorsol added this to the 42.7.4 milestone Aug 1, 2024
@jorsol jorsol requested a review from vlsi August 2, 2024 09:47
@jorsol
Copy link
Member Author

jorsol commented Aug 2, 2024

Ok, this should be ready to go.

@vlsi vlsi merged commit f2f3d68 into pgjdbc:master Aug 2, 2024
13 of 17 checks passed
@jorsol jorsol deleted the exclude-license-sourceDistribution branch August 2, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants