Extract embedded POM from JAR during install/deploy instead of generating minimal stub#169
Open
Extract embedded POM from JAR during install/deploy instead of generating minimal stub#169
Conversation
…ssue #44) Agent-Logs-Url: https://github.com/OpenIdentityPlatform/commons/sessions/dfd58a4c-2451-4188-922a-a3f5af0ddfb6 Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add logic to extract POM from JAR for Maven dependencies
Extract embedded POM from JAR during install/deploy instead of generating minimal stub
Apr 1, 2026
Copilot stopped work on behalf of
vharseko due to an error
April 1, 2026 18:00
…n-test Agent-Logs-Url: https://github.com/OpenIdentityPlatform/commons/sessions/6687b976-5466-4881-b09a-f34086f4c014 Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
…ader DoS) Agent-Logs-Url: https://github.com/OpenIdentityPlatform/commons/sessions/6687b976-5466-4881-b09a-f34086f4c014 Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Member
|
@copilot merge from master |
…-from-jar Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Contributor
Author
Done — merged |
maximthomas
reviewed
Apr 2, 2026
Comment on lines
+21
to
+29
| <finalName>${project.groupId}.${project.artifactId}</finalName> | ||
| <extensions> | ||
| <extension> | ||
| <!-- Support HTTP redirects during artifact download --> | ||
| <groupId>org.apache.maven.wagon</groupId> | ||
| <artifactId>wagon-http-lightweight</artifactId> | ||
| <version>3.4.3</version> | ||
| </extension> | ||
| </extensions> |
Contributor
There was a problem hiding this comment.
@copilot There are intendation issues in the pom file
….xml Agent-Logs-Url: https://github.com/OpenIdentityPlatform/commons/sessions/69ad93a8-6c9c-4a0b-8a22-172f59230e4a Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
org.openidentityplatform.commonsgroupId/version (3.0.5-SNAPSHOT)staging.directorypropertymaven-surefire-pluginconfiguration with staging directory system propertyAppTest.javato use JUnit 4 annotations with real assertions about staged artifactsApp.javato use commons-io (replacing obsolete Google Translate API usage)commons-iofrom2.11.0to2.14.0to fix XmlStreamReader DoS vulnerability (affects >= 2.0, < 2.14.0)masterinto branchmaven-external-dependency-plugin-test/pom.xml(consistent 4-space indent throughout)Original prompt
Issue
GitHub Issue: #44
Most JAR files built by Maven already contain their original
pom.xmlinside the JAR atMETA-INF/maven/<groupId>/<artifactId>/pom.xml. Themaven-external-dependency-pluginshould automatically extract and use this embedded POM instead of generating a bare-bones one with only GAV + packaging.Current Behavior
In both
InstallExternalDependencyMojo.javaandDeployExternalDependencyMojo.java, the POM resolution logic is:pomFileis explicitly configured → use itThis means dependency information, parent POM references, and other metadata from the original POM are lost.
Desired Behavior
Add an intermediate step that tries to extract the POM from inside the JAR before falling back to generating a minimal one:
pomFileis explicitly configured → use it (unchanged)META-INF/maven/<groupId>/<artifactId>/pom.xml→ extract it to a temp file and use itFiles to Modify
1.
maven-external-dependency-plugin/maven-external-dependency-plugin/src/main/java/com/savage7/maven/plugin/dependency/AbstractExternalDependencyMojo.javaAdd a new utility method
extractPomFromJar(ArtifactItem artifactItem, File jarFile)that:META-INF/maven/<groupId>/<artifactId>/pom.xmljava.util.jar.JarFilenull2.
maven-external-dependency-plugin/maven-external-dependency-plugin/src/main/java/com/savage7/maven/plugin/dependency/InstallExternalDependencyMojo.javaIn the
execute()method, in theelsebranch (lines ~187-203) where it currently generates a POM, change the logic to:extractPomFromJar(artifactItem, stagedArtifactFile)ProjectArtifactMetadatageneratePomis true, fall back togeneratePomFile()as before3.
maven-external-dependency-plugin/maven-external-dependency-plugin/src/main/java/com/savage7/maven/plugin/dependency/DeployExternalDependencyMojo.javaApply the same logic change as in
InstallExternalDependencyMojo.java. In theelsebranch (lines ~144-155) where it currently generates a POM:extractPomFromJar(artifactItem, installedArtifactFile)4.
maven-external-dependency-plugin/maven-external-dependency-plugin/src/main/java/com/savage7/maven/plugin/dependency/ArtifactItem.javaAdd a new boolean configuration parameter
extractPom(defaulttrue) with getter/setter, so users can disable the automatic extraction behavior per artifact if needed:Important Notes
packagingcheck (!"pom".equals(...)) already exists and should remain — POM-type artifacts don't need POM extraction.jarpackaging (or at minimum, file types that are ZIP-compatible).The following is the prior conversation context from the user's chat exploration (may be truncated):
User: проанализируй
Assistant:
I'll analyze this issue and the relevant codebase to understand what needs to be done.
Assistant: Вот подробный анализ issue #44 и связанного кода:
Анализ Issue #44: «Extract pom from jar when installing in maven repo»
Суть проблемы
Автор (@amichair) просит добавить в
maven-external-dependency-pluginвозможность автоматически извлекать POM-файл из JAR-архива (изMETA-INF/maven/<groupId>/<artifactId>/pom.xml), вместо того чтобы генерировать минимальный «пустой» POM.Большинство JAR-файлов, собранных Maven, уже содержат свой оригинальный
pom.xmlвнутри — с полным описанием зависимостей, properties и т.д. Сейчас плагин этот файл игнорирует.Текущая логика (что нужно менять)
Ключевой файл:
InstallExternalDependencyMojo.javaТекущая цепочка принятия решения о POM (строки 172–203):
...
This pull request was created from Copilot chat.