Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I've tried like this (link):

<taskdef resource="net/sf/antcontrib/antlib.xml" />
<taskdef resource="net/sf/ant4eclipse/antlib.xml" />

<target name="copy_jars">
  <getEclipseClasspath workspace="${basedir}/.."
                       projectname="MyProject"
                       property="classpath"
                       relative="false"
                       runtime="true"
                       pathseparator="#" />

  <!-- iterate over all classpath entries -->
  <foreach list="${classpath}" delimiter="#"
    target="copy_jar_file" param="classpath.entry" />
</target>

<target name="copy_jar_file">
  <!-- check if current is a .jar-file ... -->
  <if>
    <isfileselected file="${classpath.entry}">
      <filename name="**/*.jar" />
    </isfileselected>
    <then>
      <!-- copy the jar file to a destination directory -->
      <copy file="${classpath.entry}" tofile="${dest.dir}"/>
    </then>
  </if>
</target>

But I get the exception:

[getEclipseClasspath] net.sf.ant4eclipse.model.FileParserException: Could not parse plugin project 'E:\...\MyProject' since it contains neither a Bundle-Manifest nor a plugin.xml!
[getEclipseClasspath]  at net.sf.ant4eclipse.model.pdesupport.plugin.PluginDescriptorParser.parseEclipseProject(Unknown Source)
[getEclipseClasspath]  at net.sf.ant4eclipse.model.pdesupport.plugin.PluginProjectRoleIdentifier.applyRole(Unknown Source)
[getEclipseClasspath]  at net.sf.ant4eclipse.model.roles.RoleIdentifierRegistry.applyRoles(Unknown Source)
[getEclipseClasspath]  at net.sf.ant4eclipse.tools.ProjectFactory.readProjectFromWorkspace(Unknown Source)
[getEclipseClasspath]  at net.sf.ant4eclipse.tools.resolver.AbstractClasspathResolver.resolveEclipseClasspathEntry(Unknown Source)
[getEclipseClasspath]  at net.sf.ant4eclipse.tools.resolver.AbstractClasspathResolver.resolveProjectClasspath(Unknown Source)
[getEclipseClasspath]  at net.sf.ant4eclipse.tools.resolver.ProjectClasspathResolver.resolveProjectClasspath(Unknown Source)
[getEclipseClasspath]  at net.sf.ant4eclipse.ant.task.project.GetEclipseClassPathTask.resolvePath(Unknown Source)
[getEclipseClasspath]  at net.sf.ant4eclipse.ant.task.project.AbstractGetProjectPathTask.execute(Unknown Source)
[getEclipseClasspath]  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[getEclipseClasspath]  at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
[getEclipseClasspath]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[getEclipseClasspath]  at java.lang.reflect.Method.invoke(Method.java:597)
[getEclipseClasspath]  at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
[getEclipseClasspath]  at org.apache.tools.ant.Task.perform(Task.java:348)
[getEclipseClasspath]  at org.apache.tools.ant.Target.execute(Target.java:357)
[getEclipseClasspath]  at org.apache.tools.ant.Target.performTasks(Target.java:385)
[getEclipseClasspath]  at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
[getEclipseClasspath]  at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
[getEclipseClasspath]  at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[getEclipseClasspath]  at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[getEclipseClasspath]  at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
[getEclipseClasspath]  at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[getEclipseClasspath]  at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

BUILD FAILED
E:\...\build.xml:132: Exception whilst resolving the classpath of project MyProject! Reason: Could not parse plugin project 'E:\...\MyProject' since it contains neither a Bundle-Manifest nor a plugin.xml!

I wan't to copy just the jars, not the referenced projects. Is there a way to parametrize the task getEclipseClasspath so it only gets the jars, not the projects?

share|improve this question
    
I've made a mistake in retyping the error is: Could not parse plugin project 'E:\...\MyReferencedProject' since it contains neither a Bundle-Manifest nor a plugin.xml! I've tried removing MyReferencedProject from "MyProject" classpath and then copies all jars and works fine. Does anybody have any idea why it treats "MyReferencedProject" as a plugin project? Which is not. –  davorp Oct 22 '09 at 11:04
    
The classpath entry of MyReferencedProject looks like this: <classpathentry combineaccessrules="false" kind="src" path="/MyReferencedProject"/> While the classpath entry for a jar looks like: <classpathentry kind="lib" path="lib/commons-collections-2.1.jar"/> I want to filter classpath entries, just take those where kind = "lib". –  davorp Oct 22 '09 at 11:10

1 Answer 1

verify: 1. that the getEclipseClasspath attribute for projectname is, in fact, "MyProject" 2. that "MyProject" is actually a java project and has entries defined in the build path 3. that you have added the jars for Ant4Eclipse and AntContrib to the Ant-Runtime classpath: Menu:Window->Preferences->Ant->Runtime->Classpath(tab)->Ant Home Entries->"Add jars"(button)

The sample code you quote will not work if Ant4Eclipse and AntContrib are only referenced from your ant script -- those jars have to be added to the Ant runtime classpath in the Eclipse configuration.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.