not your typical multiple jars in a project question

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

not your typical multiple jars in a project question

THOMAS DAVID VAUGHAN
through much trial and error, thanks to tim's suggestion, i did get this
to work. i created a project with an existing ant script [1], and had to
hand-edit project.xml [2] to add the "export" elements. the ant script
can be just about anything. i use the one below because it has targets
my scripts depend upon.

when you make another project dependent on this project, all the
exported jarfiles are, well, exported. but the project path is an
absolute path and placed in nbproject/private/private.properties. so i
moved this to nbproject/project.properties (since nbproject/private is
not checked into the subversion repository) and made it relative
(../extras-jfreechart) in all the projects that depend upon
extras-jfreechart.

it seems as though relative paths are used only when they reside within
the project. for example, if i have one project with a "lib" directory
with several precompiled jars, and i make the project depened upon these
jars, then a raltive path is used, and this is placed in
project.properties. but, if these jars were to reside anywhere outside
the project itself, an absolute path would be used, and placed in
private.properties. hope this makes sense.

also, i think i found a bug. somtimes, when i made a project depend upon
extras-jfreechart, it failed to setup the path to this project properly
in project.xml. for example:

            <reference>
                <foreign-project>extras-jfreechart</foreign-project>
                <artifact-type>jar</artifact-type>
                <script>build.xml</script>
                <target>dist</target>
                <clean-target>clean</clean-target>
                <id>dist</id>
            </reference>

note the script element. this should be:

                <script>${project.extras-jfreechart}/build.xml</script>

this has the effect of producing something like this in the deps-clean
target in build-Impl.xml:

    <ant target="clean" inheritall="false" antfile="build.xml"/>

instead of:

    <ant target="clean" inheritall="false"
        antfile="${project.extras-jfreechart}/build.xml"/>

so you see an error message like:

    build-impl.xml:482: ant task calling a target that depends on its
parent target 'deps-clean'.

if you edit project.xml appropriately and rebuild build-Impl.xml (don't
remember how), everything is ok.

thanks much.

-tom


[1]

<?xml version="1.0" encoding="UTF-8"?>
<project name="extras-jfreechart" default="dist" basedir=".">
    <target name="compile" />
    <target name="dist" depends="compile" />
    <target name="jar" />
    <target name="clean" />
</project>

[2]

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
    <type>org.netbeans.modules.ant.freeform</type>
    <configuration>
        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
            <!--Do not use Project Properties customizer when editing
this file manually.-->
            <name>extras-jfreechart</name>
            <properties/>
            <ide-actions>
                <action name="build">
                    <target>compile</target>
                </action>
                <action name="clean">
                    <target>clean</target>
                </action>
                <action name="rebuild">
                    <target>clean</target>
                    <target>compile</target>
                </action>
            </ide-actions>
            <export>
                <type>jar</type>
                <location>dist/jcommon.jar</location>
                <build-target>dist</build-target>
            </export>
            <export>
                <type>jar</type>
                <location>dist/jfreechart.jar</location>
                <build-target>dist</build-target>
            </export>
            <view>
                <items>
                    <source-file>
                        <location>build.xml</location>
                    </source-file>
                </items>
                <context-menu>
                    <ide-action name="build"/>
                    <ide-action name="clean"/>
                    <ide-action name="rebuild"/>
                </context-menu>
            </view>
        </general-data>
        <java-data
xmlns="http://www.netbeans.org/ns/freeform-project-java/1"/>
    </configuration>
</project>