Target -post-jar no se ejecuta cuando está en el script de compilación importado

I'm fairly new to netbeans and its build definition so what I'm trying to achieve may just not be possible ...

I'm developping several plugins using netbeans and I want all the jar files to be copied in a common directory after beeing generated.

I can do that with a <target name="-post-jar"> block in every build.xml file, but as there will be more common things to do in the future I want to put the copy instructions in a common file that will be included in every build.xml file of every plugin.

Aquí esta lo que hice :

Creé un movejar.xml file in the directory where all my projects are located (/home/xxx/dev/plugins) with this content :

<?xml version="1.0" encoding="UTF-8"?>
<project name="movejar" default="default" basedir=".">
    <target name="-post-jar">
        <property name="mcp.destpath" value="/home/xxx/dev/plugins" />
        <echo message="Moving ${dist.jar} to ${mcp.destpath}" />
        <copy file="${dist.jar}" flatten="true" todir="${mcp.destpath}" />
    </target>
</project>

Luego agregué un import instrucción para /home/xxx/dev/plugins/myplugin/build.xml :

<?xml version="1.0" encoding="UTF-8"?>
<project name="myplugin" default="default" basedir=".">
    <description>Builds, tests, and runs the project myplugin.</description>
    <import file="nbproject/build-impl.xml"/>
    <import file="../movejar.xml"/>
</project>

The import is fine because when I put a <echo>foo</echo> in movejar.xml (fuera del target section) it shows up in the compile log.

El problema es que -post-jar target is not executed at compile time (jar generation is enabled in project properties of course), the echo don't show up in the compile log and the jar file is not copied, no errors either ...

Algunas ideas ?

preguntado el 28 de agosto de 12 a las 12:08

1 Respuestas

Ok, nailed it, I'm a bit shameful I didn't try this before ...

Version corta : import your stuff before netbeans' import.

When importing things then first definition kind of "locks" future definitions so anything defined in a previous import makes it impossible to override the definition in a later import ...

Netbeans automagically generate all possible target secciones en nbproject/build-impl.xml, even empty ones, so everything you need to define must be imported beforehand (whereas adding a target section at the root of build.xml can be done after importing build-impl.xml without problem ...).

Respondido 28 ago 12, 12:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.