Bug 1225808

Summary: xmvn: missing packaging type in generated POM files
Product: [Fedora] Fedora Reporter: Michal Srb <msrb>
Component: xmvnAssignee: Mikolaj Izdebski <mizdebsk>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: medium    
Version: rawhideCC: java-sig-commits, mat.booth, mizdebsk, msimacek, msrb
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-06-02 05:18:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michal Srb 2015-05-28 09:30:05 UTC
Description of problem:

Jenkins uses maven-hpi-plugin to build its plugins. These plugins have packaging type "hpi", instead of default "jar". During the build, maven-hpi-plugin tries to resolve POM files of project's dependencies and checks whether packaging type is "hpi". If so, given dependency is added to the manifest file and Jenkins later treats it as a dependency on other Jenkins plugin. Since POM files generated by XMvn doesn't contain packaging type, it always defaults to "jar" - resulting in incorrect (empty) plugin dependencies in the manifest file.

Version-Release number of selected component (if applicable):
xmvn-2.4.0-2.fc23.noarch

How reproducible:
always

Steps to Reproduce:

- tested on Rawhide
1. wget https://msrb.fedorapeople.org/reproducer.tar.gz
2. unpack and "mvn clean install" the reproducer
3. git clone https://github.com/jenkinsci/matrix-project-plugin.git
4. dnf install jenkins-junit-plugin jenkins-script-security-plugin
5. build matrix-project-plugin with xmvn: "xmvn sample.plugin:hpi-deps:1:list-plugin-dependencies"

Actual results:
[INFO] --- hpi-deps:1:list-plugin-dependencies (default-cli) @ matrix-project ---

Expected results:
[INFO] --- hpi-deps:1:list-plugin-dependencies (default-cli) @ matrix-project ---
[INFO] org.jenkins-ci.plugins:junit:1.2
[INFO] org.jenkins-ci.plugins:script-security:1.13

Additional info:
$ xmvn-resolve org.jenkins-ci.plugins:junit:pom:
/builddir/.cache/xmvn/C0/C0E3A056937477D4B401723B4FA0215CDB81DFC2/junit-SYSTEM.pom
$ cat /builddir/.cache/xmvn/C0/C0E3A056937477D4B401723B4FA0215CDB81DFC2/junit-SYSTEM.pom
<?xml version="1.0" encoding="UTF-8"?><project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.jenkins-ci.plugins</groupId>
  <artifactId>junit</artifactId>
  <version>SYSTEM</version>
</project>

Comment 1 Mikolaj Izdebski 2015-05-28 10:43:18 UTC
Packaging is build-time information and as such it is intentionally excluded from effective POMs generated by XMvn, which are meant to be used for dependency resolution, and nothing else - you shouldn't expect them to contain build-time information such as packaging type.

Possible solutions to the problem:
- patch plugin to not rely on build-time information in POMs, for example:
  * try to resolve HPI artifact (instead of POM), if it is found then assume it's Jenkins plugin
  * resolve JAR (instead of POM) and check if manifest contains "Hudson-Version" or "Jenkins-Version" attribute
- force resolution of raw POM:
  * set system property "xmvn.resolver.disableEffectivePom" to "true" when resolving POM (and then reset it to original value)
  * add property "xmvn.resolver.disableEffectivePom" to every Jenkins plugin packaged in Fedora
  * add "-Dxmvn.resolver.disableEffectivePom=true" argument to xmvn (not recommended)

Comment 2 Mikolaj Izdebski 2015-06-02 05:18:01 UTC
As explained above, this is intentional. Closing as NOTABUG.