This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Foreign project cannot set dependency on freeform project artifact if build.xml not inside projdir | ||
---|---|---|---|
Product: | projects | Reporter: | navneet <navneet> |
Component: | Generic Infrastructure | Assignee: | David Konecny <dkonecny> |
Status: | CLOSED FIXED | ||
Severity: | blocker | Keywords: | API |
Priority: | P3 | ||
Version: | 4.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | 51151, 52886 | ||
Bug Blocks: | 41535 |
Description
navneet
2004-10-07 13:12:07 UTC
Navneet: please use the attachment facility in Issuezilla. Do not paste large stack traces etc. into the body of an issue. Workaround available: do not use "Add Project". Use "Add JAR" instead. The freeform project will not be considered a subproject of the web project, but otherwise things will work. For David: there are several problems here. The immediate problem is that the current semantics of ReferenceHelper forbids you to have a build script for an artifact which is not under the project directory (or at least located relative to it). I think it is too risky to change this for D. Therefore I recommend that for now, FreeformProjectGenerator simply not generate an <export> element at all if the build.xml is not located within the project directory. With that changed, this could be downgraded to P3 I think. The full fix is more complicated. ReferenceHelper would need to accept an absolute URI for scriptLocation. But just storing a full file name (or file: URI) in <script> is not acceptable - needs to load file paths from project.properties or private.properties (acc. to CollocationQ) for proper VCS interaction. Consider dirs: ~/src/myapp/web [original web app src dir] ~/src/myapp/lib [original lib src dir, w/ build.xml] ~/src/nbprj/web [web/project project dir] ~/src/nbprj/lib [freeform project dir] Assume for example that ~/src is a CVS root. Probably the RH would need to store something like this: <reference> <foreign-project>myfreeform</> <artifact-type>jar</> <script qualified="true">${basedir.reference.lib}/build.xml</> <target>jar</> <clean-target>clean</> <id>jar</> </> Note the added attribute to <script> - will require a schema change. At the same time, it would need to have in ~/src/nbprj/web/nbproject/project.properties: # Unused, actually... but as now project.lib=../lib # Location of build.xml... ADDED basedir.reference.lib=../../myapp/lib # Location of artifact... as now file.reference.lib.jar=../../myapp/lib/build/lib.jar Now build-impl.xsl in both java/j2seproject and web/project (and whatever else) would need to change to accommodate the new references schema: if qualified="false" (or unspecified), should generate as now e.g. <ant dir="${project.lib}" .../> but if qualified="true" it should use the basedir as given, without a project location prefix: <ant dir="${basedir.reference.lib}" .../> Note that the above makes <script> include at least one slash, so that the actual build script file name is specified distinctly from the containing dir. This is for consistency with the current XSLT, which produces different Ant code depending on the format; either <ant dir="something" target="x"/> or <ant dir="something" antfile="build.xml" target="x"/> since <ant antfile="something/build.xml" target="x"/> does *not* work - fails to ${basedir} to "something". An alternative would be to keep the complete file path in <script>: <script qualified="true">${build.script.reference.lib}</> build.script.reference.lib=../../myapp/lib/build.xml and make the XSLT simpler by doing more work at runtime in Ant: <dirname property="sub.dir" file="${build.script.reference.lib}"/> <basename property="sub.file" file="${build.script.reference.lib}"/> <ant dir="${sub.dir}" antfile="${sub.file}" target="x"/> which is a little uglier in the build-impl.xml but a bit more robust since you can change the build script name in project.properties too. Re. the last long note here - unnecessary after all, cf. issue #50072. Should be fine to keep complete path to script in a property. We could also consider making an incompatible schema change for <references> (would just upgrade existing project.xml's quietly before regenerating build-impl.xml; use a new namespace, /2): rather than a qualified="true" attr, assume it is always true, so the choices would be <script>${project.lib}/build.xml</> for the normal case of build.xml inside the project dir, or <script>${build.script.reference.lib}</> for the case of some other location. Then build-impl.xsl would just use the raw value from <script> directly in the 'antfile' attribute without further interpretation. Why keep track of how to build a project ? Isn't it more logical for a procect to just keep track of the "project" it is dependent on. And whenever you need more info, just ask the other project for it, realtime. This way everything goes smooth. I think this is what a "dependent" or "sub" project would mean. "Why keep track of how to build a project ? Isn't it more logical for a procect [sic] to just keep track of the "project" it is dependent on. And whenever you need more info, just ask the other project for it, realtime." - can't; we need to generate an Ant script for the superproject that calls <ant> on the subproject. Look at the build-impl.xml for your superproject to see what is going on. Agreed with Jesse. The exports are not generated if build script lies outside of project folder. There is also workaround suggested. Lowering to P3. src/org/netbeans/modules/ant/freeform/FreeformProjectGenerator.java; new revision: 1.29; previous revision: 1.28 test/unit/src/org/netbeans/modules/ant/freeform/FreeformProjectGeneratorTest.java; new revision: 1.15; previous revision: 1.14 I just realized that my change is not correct. I'm going to fix it. Improved now: src/org/netbeans/modules/ant/freeform/FreeformProjectGenerator.java; new revision: 1.30; previous revision: 1.29 src/org/netbeans/modules/ant/freeform/ui/ProjectModel.java; new revision: 1.7; previous revision: 1.6 test/unit/src/org/netbeans/modules/ant/freeform/FreeformProjectGeneratorTest.java; new revision: 1.16; previous revision: 1.15 One more change. If script file is relative do not call URI.relativize which would make it absolute. Fixed in: src/org/netbeans/spi/project/support/ant/ReferenceHelper.java new revision: 1.19; previous revision: 1.18 Implemented as part of the issue 52886. |