jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven 2.x Compiler Plugin
  • MCOMPILER-3

Module paths for system scope are relative to parent pom instead of its own

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Labels:
    None
  • Environment:
    Win XP, Maven 2.0

Description

When building from the parent POM dir, all paths are relative to it. A problem occurs when its modules have dependencies of <scope>system</scope> - the module's corresponding <systemPath> is relative to the parent POM dir, instead of the module's POM dir.

With a module's <systemPath> set to compile correctly it on its own, compiling from its parent POM dir gives this error:

[ERROR] BUILD ERROR
[INFO] ----------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

GroupId: thegrp
ArtifactId: subsystem
Version: 2.1-SNAPSHOT

Reason: System artifact: thegrp:subsystem:jar:2.1-SNAPSHOT not found in
path: src\lib\subsystem.jar
thegrp:subsystem:2.1-SNAPSHOT:jar

(would be nice to have the fully qualified path name listed there, instead of the relative one so users would know where it is really looking for it
from)

Expected behavior is that Maven treats system scope paths relative to the module POM, not the parent's POM.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    MNG-1471-maven-project.patch
    22/Nov/05 11:38 PM
    2 kB
    Edwin Punzalan

Issue Links

is depended upon by

Task - A task that needs to be done. MNG-1867 deprecate system scope, analyse other use cases

  • Trivial - Cosmetic problem like misspelt words or misaligned text.
  • Open - The issue is open and ready for the assignee to start work on it.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Brett Porter added a comment - 09/Nov/05 11:00 PM

this should be won't fix: system scope must be absolute.

Instead, we should validate the systemPath and ensure this is the case.

Show
Brett Porter added a comment - 09/Nov/05 11:00 PM this should be won't fix: system scope must be absolute. Instead, we should validate the systemPath and ensure this is the case.
Hide
Permalink
Jeff Jensen added a comment - 09/Nov/05 11:28 PM

I see your argument that having systemPath an absolute path enables successful builds both from the standalone module itself for CI as well as in the parent dir to get the multi-module site benefits.

However, in practice, it can't be absolute. The dir can be in different absolute locations on different machines/for different users. Files in the module are relative to its root - to the pom file location in Maven's case.

Perhaps using systemPath is the wrong way to solve the problem then - How does one get the jars in a ${basedir}/lib dir on the classpath to build with?

If not possible, then the argument that it "must be absolute" is off base, and makes the systemPath option rather worthless, and Maven 2 fails to handle many common situations.

Show
Jeff Jensen added a comment - 09/Nov/05 11:28 PM I see your argument that having systemPath an absolute path enables successful builds both from the standalone module itself for CI as well as in the parent dir to get the multi-module site benefits. However, in practice, it can't be absolute. The dir can be in different absolute locations on different machines/for different users. Files in the module are relative to its root - to the pom file location in Maven's case. Perhaps using systemPath is the wrong way to solve the problem then - How does one get the jars in a ${basedir}/lib dir on the classpath to build with? If not possible, then the argument that it "must be absolute" is off base, and makes the systemPath option rather worthless, and Maven 2 fails to handle many common situations.
Hide
Permalink
Brett Porter added a comment - 09/Nov/05 11:46 PM

systemPath was put in place for a couple of use cases which will actually be rendered obsolete in 2.1. For example, using tools.jar. It is meant to be absolute, using properties to determine the correct base directory for this system.

for files in lib/, the previous solution was and should still be to copy them into the repository, otherwise - as you've seen - when they are requested transitively they can not be found.

You could work around this by setting the system path to ${basedir}/lib - but I strongly advise against it.

Show
Brett Porter added a comment - 09/Nov/05 11:46 PM systemPath was put in place for a couple of use cases which will actually be rendered obsolete in 2.1. For example, using tools.jar. It is meant to be absolute, using properties to determine the correct base directory for this system. for files in lib/, the previous solution was and should still be to copy them into the repository, otherwise - as you've seen - when they are requested transitively they can not be found. You could work around this by setting the system path to ${basedir}/lib - but I strongly advise against it.
Hide
Permalink
Jeff Jensen added a comment - 10/Nov/05 11:48 AM

Thanks for the workaround.

I like the repo approach and strong Maven recommendation, especially for the plugins and tools.

I think it is a Maven failing to enforce that on everything and not have a simple supported mechanism to get ${basedir}/lib (or whatever dir) on the classpath. It causes headaches for some adopters, including us, and may cause it not to get used (that is IMO worse than supporting the relative system path that deviates from the vision of all artifacts/dependencies in a Maven repo).

> when they are requested transitively they can not be found.

A use case is with 3rd party libs/jars that are source controlled and delivered to the workspace in that manner. They are not housed by any Maven repos (you say "put them in there", the product team's decision is "no"). The repo is the source control repository. The version to use is the one in the referenced directory. In this situation, the dependency is resolved in the process around accepting a new lib version into source control and integrating to the correct product versions. This is part of the reproducible builds best practice - all "source" artifacts are sourced in the codeline. Jars without source are source artifacts when that is the closest original source artifact obtainable.

Not everyone can get away from having jars source controlled and instead having them in Maven repos.

My summary is instead of the tool forcing this particular manner on users, let the user decide when it is correct to put them in a Maven repo and when not to by having the local reference feature. This is flexibility and supports easier Maven adoption.

Show
Jeff Jensen added a comment - 10/Nov/05 11:48 AM Thanks for the workaround. I like the repo approach and strong Maven recommendation, especially for the plugins and tools. I think it is a Maven failing to enforce that on everything and not have a simple supported mechanism to get ${basedir}/lib (or whatever dir) on the classpath. It causes headaches for some adopters, including us, and may cause it not to get used (that is IMO worse than supporting the relative system path that deviates from the vision of all artifacts/dependencies in a Maven repo). > when they are requested transitively they can not be found. A use case is with 3rd party libs/jars that are source controlled and delivered to the workspace in that manner. They are not housed by any Maven repos (you say "put them in there", the product team's decision is "no"). The repo is the source control repository. The version to use is the one in the referenced directory. In this situation, the dependency is resolved in the process around accepting a new lib version into source control and integrating to the correct product versions. This is part of the reproducible builds best practice - all "source" artifacts are sourced in the codeline. Jars without source are source artifacts when that is the closest original source artifact obtainable. Not everyone can get away from having jars source controlled and instead having them in Maven repos. My summary is instead of the tool forcing this particular manner on users, let the user decide when it is correct to put them in a Maven repo and when not to by having the local reference feature. This is flexibility and supports easier Maven adoption.
Hide
Permalink
John Casey added a comment - 14/Nov/05 10:26 PM

Need to fail if systemPath is not absolute. This will probably happen in DefaultArtifactResolver, if not in DefaultModelValidator...

Show
John Casey added a comment - 14/Nov/05 10:26 PM Need to fail if systemPath is not absolute. This will probably happen in DefaultArtifactResolver, if not in DefaultModelValidator...
Hide
Permalink
Edwin Punzalan added a comment - 17/Nov/05 11:24 PM

Hi. If the specified systemPath is absolute, wouldn't that be machine specific?

Show
Edwin Punzalan added a comment - 17/Nov/05 11:24 PM Hi. If the specified systemPath is absolute, wouldn't that be machine specific?
Hide
Permalink
Brett Porter added a comment - 22/Nov/05 1:41 AM

Edwin: the value is meant to contain a property that gives the machine specific absolute path, eg:

${java.home}/../..

Show
Brett Porter added a comment - 22/Nov/05 1:41 AM Edwin: the value is meant to contain a property that gives the machine specific absolute path, eg: ${java.home}/../..
Hide
Permalink
Edwin Punzalan added a comment - 22/Nov/05 11:38 PM

Got it. Please see attached patch...

Show
Edwin Punzalan added a comment - 22/Nov/05 11:38 PM Got it. Please see attached patch...
Hide
Permalink
Jeff Jensen added a comment - 25/Nov/05 8:49 PM

Brett, in your comment on 09/Nov/05, you say "systemPath....will acutally be rendered obsolete in 2.1". What is the planned feature that replaces this one?

Show
Jeff Jensen added a comment - 25/Nov/05 8:49 PM Brett, in your comment on 09/Nov/05, you say "systemPath....will acutally be rendered obsolete in 2.1". What is the planned feature that replaces this one?
Hide
Permalink
Brett Porter added a comment - 26/Nov/05 6:58 PM

systemPath was only intended for use in finding system libraries. This was for two specific purposes:

  • location of Java system libraries (tools.jar, for example). We hope to have this handled by specification dependencies
  • location of system libraries in a native build. This now can be handled by custom resolvers

Aside from that, its use was originally going to be omitted so it will be discouraged going forward.

Show
Brett Porter added a comment - 26/Nov/05 6:58 PM systemPath was only intended for use in finding system libraries. This was for two specific purposes:
  • location of Java system libraries (tools.jar, for example). We hope to have this handled by specification dependencies
  • location of system libraries in a native build. This now can be handled by custom resolvers
Aside from that, its use was originally going to be omitted so it will be discouraged going forward.
Hide
Permalink
Matthew Wheaton added a comment - 05/Dec/05 12:24 PM

I would REALLY not like to see systemPath go away. We have no option to store our jars in a maven repository. They must be pulled down from source control and used at build time. Maven 2 is a significant step backwards in terms of being able to dynamically add Jars to the classpath at runtime. Is there any plan to allow using some kind of mask, like .jar;.zip to discover jars in a specified directory ?

I was able to, with an ANT script in 1.x, add Jars to the maven classpath so that each Jar would not need to be referenced manually in the POM.

Any plans to support that kind of flexibility ?

I've been using Maven 1.x for years, and I have to say, I believe that while some things are easier to do now, others have become more inflexible.

Show
Matthew Wheaton added a comment - 05/Dec/05 12:24 PM I would REALLY not like to see systemPath go away. We have no option to store our jars in a maven repository. They must be pulled down from source control and used at build time. Maven 2 is a significant step backwards in terms of being able to dynamically add Jars to the classpath at runtime. Is there any plan to allow using some kind of mask, like .jar;.zip to discover jars in a specified directory ? I was able to, with an ANT script in 1.x, add Jars to the maven classpath so that each Jar would not need to be referenced manually in the POM. Any plans to support that kind of flexibility ? I've been using Maven 1.x for years, and I have to say, I believe that while some things are easier to do now, others have become more inflexible.
Hide
Permalink
Matthew Wheaton added a comment - 05/Dec/05 12:32 PM

f they take systemPath away, as he says, then that'll break me again, for sure.
I'm really contemplating NOT using M2.

In any case, my workaround to make it truly dynamic, is my build.bat file first calls an ANT script that compiles a DependencyBuilder class that I created, which iterates through the jar files in my "lib" directory, and creates a string that has all the <dependency> entries in it. Then, I have a pom that lives in my "lib" project called pom-template.xml, that, while still in ANT, I copy to the same directory renaming to pom.xml. I filter the file using the ANT filter mechanism to ADD the string I just created in the DependencyBuilder class, giving a psuedo-dynamic discovery of dependencies.

Then, I reference the "libs" project in each of the sub-projects.

A little complicated, but then I don't have to manually add JARs to the build when the developers add them.

Show
Matthew Wheaton added a comment - 05/Dec/05 12:32 PM f they take systemPath away, as he says, then that'll break me again, for sure. I'm really contemplating NOT using M2. In any case, my workaround to make it truly dynamic, is my build.bat file first calls an ANT script that compiles a DependencyBuilder class that I created, which iterates through the jar files in my "lib" directory, and creates a string that has all the <dependency> entries in it. Then, I have a pom that lives in my "lib" project called pom-template.xml, that, while still in ANT, I copy to the same directory renaming to pom.xml. I filter the file using the ANT filter mechanism to ADD the string I just created in the DependencyBuilder class, giving a psuedo-dynamic discovery of dependencies. Then, I reference the "libs" project in each of the sub-projects. A little complicated, but then I don't have to manually add JARs to the build when the developers add them.
Hide
Permalink
John Casey added a comment - 05/Dec/05 4:33 PM

The whole point of maven is to have your project declaratively specified, and then use that information to build the project artifact, project documentation, etc., etc. Why would you want to remove that safety net?

Aside from this discussion, there is an SCM wagon provider (not sure of what quality it currently is), which can retrieve your dependencies from CVS/SVN/etc. if your scm repository is structured as a normal maven repository. Then, it's just a matter of specifying the correct <repositories/> configuration, and adding a build <extension/> for the scm wagon. Would this work?

It seems as if you've been using Maven 1 as a shell around Ant for some time now, if you're still adding lib/.jar. System dependencies are "broken", in that they don't support transitivity, and can *very easily become non-portable (like, if lib/ exists outside your project directory...it doesn't, does it??). For things like tools.jar, we're planning to support the notion of specification dependencies, where tools.jar might implement some javac POM or something. For native builds, where the dependency is actually installed on the system somewhere, alternative artifact resolver implementations are more appropriate, since specifying the path of these deps on the user-POM side isn't very efficient.

Show
John Casey added a comment - 05/Dec/05 4:33 PM The whole point of maven is to have your project declaratively specified, and then use that information to build the project artifact, project documentation, etc., etc. Why would you want to remove that safety net? Aside from this discussion, there is an SCM wagon provider (not sure of what quality it currently is), which can retrieve your dependencies from CVS/SVN/etc. if your scm repository is structured as a normal maven repository. Then, it's just a matter of specifying the correct <repositories/> configuration, and adding a build <extension/> for the scm wagon. Would this work? It seems as if you've been using Maven 1 as a shell around Ant for some time now, if you're still adding lib/.jar. System dependencies are "broken", in that they don't support transitivity, and can *very easily become non-portable (like, if lib/ exists outside your project directory...it doesn't, does it??). For things like tools.jar, we're planning to support the notion of specification dependencies, where tools.jar might implement some javac POM or something. For native builds, where the dependency is actually installed on the system somewhere, alternative artifact resolver implementations are more appropriate, since specifying the path of these deps on the user-POM side isn't very efficient.
Hide
Permalink
Brett Porter added a comment - 05/Dec/05 4:45 PM

it will just be discouraged, not removed (at least not without a reasonable deprecation period and plenty of discussion of alternatives).

We might need some other resolvers, but the dependenchy mechanism in m2 relies on the repository information to perform. I guess what you are asking for here is to turn off the dependency mechanism and just use local jars - that's a possibility, and a separate feature request.

Show
Brett Porter added a comment - 05/Dec/05 4:45 PM it will just be discouraged, not removed (at least not without a reasonable deprecation period and plenty of discussion of alternatives). We might need some other resolvers, but the dependenchy mechanism in m2 relies on the repository information to perform. I guess what you are asking for here is to turn off the dependency mechanism and just use local jars - that's a possibility, and a separate feature request.
Hide
Permalink
Matthew Wheaton added a comment - 06/Dec/05 8:16 AM

Hi John,

I think your assessment is correct in that I think my usage model of Maven is a convenience wrapper around ANT, and using the event driven model around compilation, etc. I'm going to stick with Maven 2 and see if there's any other issues that crop up, but I'm going to try and adopt the Maven 2 usage model as closely as possible.

thx all,
mw

Show
Matthew Wheaton added a comment - 06/Dec/05 8:16 AM Hi John, I think your assessment is correct in that I think my usage model of Maven is a convenience wrapper around ANT, and using the event driven model around compilation, etc. I'm going to stick with Maven 2 and see if there's any other issues that crop up, but I'm going to try and adopt the Maven 2 usage model as closely as possible. thx all, mw
Hide
Permalink
Jeff Jensen added a comment - 06/Dec/05 9:12 AM

John, Matt's may be what you describe, but ours is not. I gleefully shed anything Ant-ish when I began using Maven. My situation is described in my comment on 10/Nov/05 11:48 AM].

Brett's comment on 05/Dec/05 04:45 PM sounds right on for our situation.

Show
Jeff Jensen added a comment - 06/Dec/05 9:12 AM John, Matt's may be what you describe, but ours is not. I gleefully shed anything Ant-ish when I began using Maven. My situation is described in my comment on 10/Nov/05 11:48 AM]. Brett's comment on 05/Dec/05 04:45 PM sounds right on for our situation.
Hide
Permalink
John Casey added a comment - 06/Dec/05 10:07 AM

You have your third party libraries in SCM, and it's been decided that this should remain the case...how would this preclude your using an SCM-based Maven repository? As I mentioned in my comment to Matthew on 05-Dec, the Maven-Wagon project does have an SCM provider (not sure what the status of it is, though). This, along with a custom artifact repository layout (to adapt to non-m2-ish layout of your /lib), should enable you to resolve those libraries without any custom design on the part of Maven.

While this practice has not been fully realized yet, there is nothing tying users to the default Maven 2.x repository layout for their own repository instances; you only need to have an appropriate ArtifactRepositoryLayout and the right wagon provider in place. These two tasks are still non-trivial, but possible with the current implementation.

Would this solve your problem? Would there be any problem with checking in POMs for those third party libraries, to help make transitive dependencies possible for those? If not, it's still possible to use them.

Show
John Casey added a comment - 06/Dec/05 10:07 AM You have your third party libraries in SCM, and it's been decided that this should remain the case...how would this preclude your using an SCM-based Maven repository? As I mentioned in my comment to Matthew on 05-Dec, the Maven-Wagon project does have an SCM provider (not sure what the status of it is, though). This, along with a custom artifact repository layout (to adapt to non-m2-ish layout of your /lib), should enable you to resolve those libraries without any custom design on the part of Maven. While this practice has not been fully realized yet, there is nothing tying users to the default Maven 2.x repository layout for their own repository instances; you only need to have an appropriate ArtifactRepositoryLayout and the right wagon provider in place. These two tasks are still non-trivial, but possible with the current implementation. Would this solve your problem? Would there be any problem with checking in POMs for those third party libraries, to help make transitive dependencies possible for those? If not, it's still possible to use them.
Hide
Permalink
John Casey added a comment - 06/Dec/05 6:43 PM

Applied patch, with small logic fix. This patch will validate that if a systemPath is specified for a dependency, it is absolute. It's possible to use expressions in this path, but by the time it's validated in this step, those expressions will have been resolved.

My change was to add the same validation to managed dependencies.

Show
John Casey added a comment - 06/Dec/05 6:43 PM Applied patch, with small logic fix. This patch will validate that if a systemPath is specified for a dependency, it is absolute. It's possible to use expressions in this path, but by the time it's validated in this step, those expressions will have been resolved. My change was to add the same validation to managed dependencies.

People

  • Assignee:
    John Casey
    Reporter:
    Jeff Jensen
Vote (0)
Watch (4)

Dates

  • Created:
    08/Nov/05 9:08 PM
    Updated:
    08/Mar/06 10:47 PM
    Resolved:
    06/Dec/05 6:43 PM

Time Tracking

Estimated:
30m
Original Estimate - 30 minutes
Remaining:
30m
Remaining Estimate - 30 minutes
Logged:
Not Specified
Time Spent - Not Specified
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.