Stefan Bodewig wrote:
On Mon, 22 Aug 2005, Steve Loughran <[EMAIL PROTECTED]> wrote:


Why do you have to repeat the full path to an antlib in <typedef>,
when declaring into an antlib url.


antlib descriptor, you mean?

If so, I agree with you, we should magically provide a default for the
resource attribute if uri has been specified and uses the antlib
protocol.


This is working, I now have an importable build file whose aim in life is to make sure an antlib is loaded, and if not, pulls down the files from the maven libraries and declares them.



<?xml version="1.0" ?>
<project name="sftasks"
  xmlns:ac="antlib:net.sf.antcontrib"
  xmlns:sf="antlib:org.smartfrog.tools.ant"
  xmlns:m2="antlib:org.apache.maven.artifact.ant"
  >

  <target name="smartfrog-tasks-classpath"
    depends="core.load-version-info">
    <m2:dependencies pathID="smartfrog.tasks.classpath">
      <dependency groupID="org.smartfrog"
        artifactID="smartfrog"
        version="${smartfrog-version}"
        scope="compile"
        />
      <dependency groupID="org.smartfrog"
        artifactID="sfServices"
        version="${smartfrog-version}"
        scope="compile"
        />
      <dependency groupID="org.smartfrog"
        artifactID="sf-tasks"
        version="${smartfrog-version}"
        scope="compile"
        />
    </m2:dependencies>
  </target>


<target name="use-smartfrog-tasks" depends="sftasks.smartfrog-tasks-classpath" description="declare the classpath and imports for the smartfrog tasks"> <property name="sf.antlib.uri" value="antlib:org.smartfrog.tools.ant" />
    <ac:if>
      <not>
        <typefound
          uri="${sf.antlib.uri}"
          name="startdaemon"/>
      </not>
      <ac:then>
        <typedef
          uri="${sf.antlib.uri}"
          classpathref="smartfrog.tasks.classpath"
          onerror="failall"
      />
      </ac:then>
      <ac:else>
        <echo level="verbose">Tasks already found</echo>
      </ac:else>
    </ac:if>

  </target>


</project>

Next I could tease out some of it into a macro for broader re-use, which leads to the next issue.

One change I have also checked in to Definer.java is some extra logic for naming antlibs. Instead of just

        antlib:org.example.package

you can go

        antlib://org/example/package/file.xml

and have that file's declarations read in. This will let me keep a set of antlibs in a single dir, load it with -lib and then have

antlib://m2-macros.xml
antlib://sf-macros.xml

So, I am clearly +1 in having this feature. What I am 0 about is the exact syntax. Should it be a full path like what I have done, or should it be

antlib://org.example.package/file.xml
antlib:org.example.package/file.xml
antlib://org.example.package/antlib.xml

In which case, the antlib.xml is just something we patch in on the end if there is no /*.xml file defined at the tail.

Thoughts?






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to