0

Iam trying to create a jar file, which requires eclipse plugins in the classpath . So i was trying to give a regular expression in the path attribute of "pathelement" tag .

Here is my sample code

<target name="compile" depends="init,copy-non-java-files">
    <javac srcdir="${src}" destdir="${build}" source="1.6">
        <classpath>
            <pathelement path="${java.class.path}/" />
            <fileset dir="*\\eclipse\\plugins">
                <include name="**/*.jar" />
            </fileset>
            <fileset dir="${lib}">
                <include name="**/*.jar" />
            </fileset>
        </classpath>
    </javac>
</target>

But when i try to build i get build failed because ant is unable to evaluate the class path .

Iam not looking for ant4Eclipse solution , but i want to know is it possible to use regular expression in ant or not , if yes can any one suggest what i am doing wrong here .

Learner
  • 177
  • 1
  • 2
  • 16

1 Answers1

0

The problem is with this part:

<fileset dir="*\\eclipse\\plugins">
    <include name="**/*.jar" />
</fileset>

The fileset element does not accept glob patterns in the dir attribute. The dir specifies the root directory under which all included files in the include nested element exist. Therefore the directory must be a specific path.

If this build is intended to generate an Eclipse-based Jar (e.g. an Eclipse plugin), then there should be an existing Ant property defined in the Eclipse Ant which points to the Eclipse installation, something like ${eclipse.home}.

M A
  • 71,713
  • 13
  • 134
  • 174
  • I can do that but the eclipse installation path can be different on different users systems , i cant hard code it – Learner Nov 16 '15 at 17:55
  • @Learner Then you shouldn't rely on the Eclipse installation. Either ship the required plugins or force the user to have Eclipse installed and pass an Ant property that points to that installation. – M A Nov 16 '15 at 18:01
  • And again there should be a property in the Eclipse Ant that points to the installation. – M A Nov 16 '15 at 18:02
  • I appreciate your suggestion , but is there any other work around . I will be invoking this build.xml from python . – Learner Nov 16 '15 at 18:03
  • @Learner How will you be invoking it from Python? You should add that to code. Might help people to answer your question. Maybe this can help you. http://stackoverflow.com/questions/3730880/use-ant-for-running-program-with-command-line-arguments No one will be able to give you correct answer till they have more information – Aseem Bansal Nov 16 '15 at 21:18