ant mail task using mail and activation jar in external location

后端 未结 3 1214
余生分开走
余生分开走 2021-01-21 08:28

I have following ant mail task -

 
    
               


        
相关标签:
3条回答
  • 2021-01-21 09:03

    Unforunately you can't. You have to put Library Dependencies into the ant classpath somehow.

    This could be the ANTH_HOME/lib dir or a change to the command line arguments.

    Ant has a command-line argument to specify a lib dir:

    -lib <path> specifies a path to search for jars and classes
    

    You could also call ant from ant itself with that info, which may be a bit ugly:

    <exec executable="ant">
      <arg value="-lib"/>
      <arg value="PATH_TO_MY_LIB"/>
      <arg value="target"/>
    </exec>
    

    If you execute this task from eclipse, you can add the libs to the run definition of the task and share this run definition with other developers.

    0 讨论(0)
  • 2021-01-21 09:09

    See this answer to a similar question for a solution of library dependencies in ant.

    In short, put all your ant addon libs, e.g. mail.jar,activation.jar, commons in a special folder and make it available for all your ant scripts via ANT_ARGS.
    Being forced to use the exec task in ant to resolve a library dependency seems VERY strange.

    In Eclipse common practice is to create a module in your repository (cvs,subversion,git). Then every team member has that module in his workspace and simply uses Window > Preferences > Ant > Runtime > Global Entries to make those dependencies available for ant.

    0 讨论(0)
  • 2021-01-21 09:28

    There is a nice approach which is already answered here. It solves this problem with the Ant Tasks Classloader:

    <taskdef resource="net/jtools/classloadertask/antlib.xml" 
        classpath="ant-classloadertask.jar"/>
    <!-- now you can load activation.jar and mail.jar into the project's classpath -->
    <classloader loader="project">
        <classpath>
            <pathelement path="lib/activation.jar"/>
            <pathelement path="lib/mail.jar"/>
        </classpath>
    </classloader>
    
    0 讨论(0)
提交回复
热议问题