Bug 1115409 - javapackages-tools: mvn_artifact.py: Generated <requestedVersion> is empty
Summary: javapackages-tools: mvn_artifact.py: Generated <requestedVersion> is empty
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: javapackages-tools
Version: rawhide
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: ---
Assignee: Michal Srb
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-07-02 10:07 UTC by Mikolaj Izdebski
Modified: 2014-09-09 15:12 UTC (History)
4 users (show)

Fixed In Version: javapackages-tools-4.2.0-1.fc22
Clone Of:
Environment:
Last Closed: 2014-09-09 15:12:29 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
pom1.xml (6.47 KB, text/xml)
2014-07-02 10:12 UTC, Mikolaj Izdebski
no flags Details
pom2.xml (5.62 KB, text/xml)
2014-07-02 10:13 UTC, Mikolaj Izdebski
no flags Details

Description Mikolaj Izdebski 2014-07-02 10:07:29 UTC
Description of problem:
<requestedVersion> generated by mvn_artifact.py can be empty.

Version-Release number of selected component (if applicable):
4.2.0-0.4.gitf5f02e4

Steps to Reproduce:
$ touch foo.jar
$ python /usr/share/java-utils/mvn_artifact.py pom1.xml
$ python /usr/share/java-utils/mvn_artifact.py pom2.xml foo.jar 
$ grep requestedVersion .xmvn-reactor 

Actual results:
Some  <ns1:requestedVersion> tags are empty.

Comment 1 Mikolaj Izdebski 2014-07-02 10:12:59 UTC
Created attachment 914094 [details]
pom1.xml

Comment 2 Mikolaj Izdebski 2014-07-02 10:13:25 UTC
Created attachment 914095 [details]
pom2.xml

Comment 3 Michal Srb 2014-07-02 11:44:26 UTC
They are empty simply because neither pom itself nor parent pom(s) contain information about version of given dependency. IIRC xmvn-install checks for such inconsistencies and stops the build if metadata doesn't contain all necessary information. So even current version of javapackages-tools shouldn't really cause any problems. It would be probably nice to print some warning in mvn_artifact and maybe fail the build there. This will be addressed in javapackages-tools 4.2.0.

Comment 4 Mikolaj Izdebski 2014-07-02 12:00:06 UTC
(In reply to Michal Srb from comment #3)
> They are empty simply because neither pom itself nor parent pom(s) contain
> information about version of given dependency.

These POMs would be incorrect with upstream Maven, but XMvn always allowed unset versions. In these cases it is assumed that version is SYSTEM.

> IIRC xmvn-install checks for
> such inconsistencies and stops the build if metadata doesn't contain all
> necessary information.

Yes it does.

> So even current version of javapackages-tools
> shouldn't really cause any problems.

The problem is that generated reactor file is invalid and xmvn-install will fail.

Comment 5 Mikolaj Izdebski 2014-07-02 12:07:19 UTC
[ERROR] Artifact installation failed
org.fedoraproject.xmvn.tools.install.impl.ArtifactInstallationException: Artifact dependency must have requested version set
	at org.fedoraproject.xmvn.tools.install.impl.InstallationPlan.validate(InstallationPlan.java:118)
	at org.fedoraproject.xmvn.tools.install.impl.InstallationPlan.<init>(InstallationPlan.java:55)
	at org.fedoraproject.xmvn.tools.install.impl.DefaultInstaller.install(DefaultInstaller.java:298)
	at org.fedoraproject.xmvn.tools.install.cli.InstallerCli.run(InstallerCli.java:65)
	at org.fedoraproject.xmvn.tools.install.cli.InstallerCli.main(InstallerCli.java:86)

What I used as workaround:

# Workaround for rhbz#1115409
sed -i 's|<ns1:requestedVersion></ns1:requestedVersion>|<ns1:requestedVersion>SYSTEM</ns1:requestedVersion>|' .xmvn-reactor

Comment 6 Michal Srb 2014-07-02 12:21:35 UTC
(In reply to Mikolaj Izdebski from comment #4)
> (In reply to Michal Srb from comment #3)
> > They are empty simply because neither pom itself nor parent pom(s) contain
> > information about version of given dependency.
> 
> These POMs would be incorrect with upstream Maven, but XMvn always allowed
> unset versions. In these cases it is assumed that version is SYSTEM.
> 

So should I set requestedVersion to "SYSTEM" in cases like this? If so, then maybe xmvn-install and other tools don't have to be so strict about it and assume that requestedVersion is SYSTEM if not specified otherwise. Current behavior of mvn_artifact with empty version is a bit ugly, but it would be easy to skip whole requestedVersion if it's empty.


> 
> The problem is that generated reactor file is invalid and xmvn-install will
> fail.

The problem from my POW is that there is no real definition of valid reactor file. If we assume that reactor file should conform to metadata XSD, then requestedVersion doesn't have to be specified at all (it has minOccurs=0).

Comment 7 Mikolaj Izdebski 2014-07-02 14:34:35 UTC
(In reply to Michal Srb from comment #6)
> (In reply to Mikolaj Izdebski from comment #4)
> > (In reply to Michal Srb from comment #3)
> > > They are empty simply because neither pom itself nor parent pom(s) contain
> > > information about version of given dependency.
> > 
> > These POMs would be incorrect with upstream Maven, but XMvn always allowed
> > unset versions. In these cases it is assumed that version is SYSTEM.
> > 
> 
> So should I set requestedVersion to "SYSTEM" in cases like this? If so, then
> maybe xmvn-install and other tools don't have to be so strict about it and
> assume that requestedVersion is SYSTEM if not specified otherwise. Current
> behavior of mvn_artifact with empty version is a bit ugly, but it would be
> easy to skip whole requestedVersion if it's empty.

I can make it optional in XMvn.

> > The problem is that generated reactor file is invalid and xmvn-install will
> > fail.
> 
> The problem from my POW is that there is no real definition of valid reactor
> file. If we assume that reactor file should conform to metadata XSD, then
> requestedVersion doesn't have to be specified at all (it has minOccurs=0).

Reactor file (installation plan) must be valid metadata (conform to XSD) and addtionally pass these checks:

https://github.com/mizdebsk/xmvn/blob/2.0.0/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/InstallationPlan.java#L75-L137

Comment 8 Mikolaj Izdebski 2014-07-02 14:56:28 UTC
XMvn will now use default value SYSTEM if requestedVersion is not specified. But empty requestedVersion is still incorrect.

Comment 9 Michal Srb 2014-07-02 15:08:15 UTC
Commit 6a98089 in javapackages-tools sets requestedVersion to "SYSTEM" if it couldn't be determined, so requestedVersion should never be empty now.

Comment 10 Mikolaj Izdebski 2014-07-02 17:45:34 UTC
My change that made requestedVersion optional seems to break maven.prov:

Traceback (most recent call last):
  File "/usr/lib/rpm/maven.prov", line 56, in <module>
    builder = TagBuilder()
  File "/usr/lib/rpm/maven.prov", line 49, in __init__
    for artifact in mdata.get_provided_artifacts():
  File "/usr/lib/python2.7/site-packages/javapackages/metadata/metadata.py", line 100, in get_provided_artifacts
    artifact = MetadataArtifact.from_metadata(a)
  File "/usr/lib/python2.7/site-packages/javapackages/metadata/artifact.py", line 143, in from_metadata
    for dep in metadata.dependencies.dependency}
  File "/usr/lib/python2.7/site-packages/javapackages/metadata/artifact.py", line 143, in <setcomp>
    for dep in metadata.dependencies.dependency}
  File "/usr/lib/python2.7/site-packages/javapackages/metadata/dependency.py", line 85, in from_metadata
    requestedVersion = metadata.requestedVersion.strip()
AttributeError: 'NoneType' object has no attribute 'strip'

Comment 11 Michal Srb 2014-07-03 06:58:35 UTC
Good catch, it should be fixed in 4b24185.

Comment 12 Michal Srb 2014-09-09 15:12:29 UTC
Fixed in Rawhide.


Note You need to log in before you can comment on or make changes to this bug.