Ant execution in IDEA has different class path than standalone ant?

I've got an ant build file (marked as such in IDEA) where one of the tasks is to
create the DDL file for the project's persistent objects (using Hibernate's SchemaExportTask).
The task definition includes a reference to the complete compile/runtime classpath.
When executing ant on the command line, the task performes as expected and I
have an artefact (the sql file). When running the same build file from IDEA I get
Class Not Found exceptions unless I explicitly add specific jar files to the class
path using the 'Additional Classpath' tab entries. The project uses the same ant
that is used on the command line, and not the built in one.

I've tried to turn on debugging but there's scant information presented about the
class path used by/available to the task.

Any idea what is going on? Am I missing something (most likely)?

Any help would be appreciated - I really want to be able to run this task from within
IDEA along with the rest of the project building tasks.

Cheers,

Bonny

7 comments

Can't you just use the your standalone ant rather than the bundled apache ant,
but changing Execution properties of ant build.xml file?

0

As mentioned in my original post, the build file is already configured to use the same
ant version as the one I use on the command line, and that still makes no difference.

As mentioned, once I add some jars using the 'Additional Classpath' tab in the
ant properties, the CNF exceptions do not show up, but I get other errors to do
with paths, namely that files being used (to define hibernate mappings) are not
accessible; this seems like the build file itself is not executed in the right place?

Other ideas?

Thanks in advance,

Bonny

0

When I have some external dependencies on an ant task, I have just put the libraries in the ]]>/lib directory, and then it worked fine within IDEA as long as I used the standalone ant rather than the builtin Ant.

Are you using Ant 1.7.0? I am still using Ant 1.6.5.

0

I've run into this with the Schema Exporter task myself. Once you start adding any of the Hibernate classes to Ant's runtime classpath you will end up having to add the entire project classpath as well, otherwise it can't find the mapped classes or mappings, as you're experiencing.

The only way around it is to manually declare the correct classpath for the task definition in the Ant script.

0

Hello Bonny,

Are you using Selena? I tried a test sample with SchemaExportTask, and it
creates a DDL for 1 table successfully.
A classpath for taskdef includes: hibernate3.jar (nothing more).
Additional classpath includes: compiled bean class (which is mapped to the
table), everything from hibernate-3.2/lib, and hsqldb.jar (test database
is hsql).

Is there anything wrong with this? As I could check, running ant from command
line also requires all these libs to be successful.

I've got an ant build file (marked as such in IDEA) where one of the
tasks is to
create the DDL file for the project's persistent objects (using
Hibernate's SchemaExportTask).
The task definition includes a reference to the complete
compile/runtime classpath.
When executing ant on the command line, the task performes as expected
and I
have an artefact (the sql file). When running the same build file from
IDEA I get
Class Not Found exceptions unless I explicitly add specific jar files
to the class
path using the 'Additional Classpath' tab entries. The project uses
the same ant
that is used on the command line, and not the built in one.
I've tried to turn on debugging but there's scant information
presented about the class path used by/available to the task.

Any idea what is going on? Am I missing something (most likely)?

Any help would be appreciated - I really want to be able to run this
task from within IDEA along with the rest of the project building
tasks.

Cheers,

Bonny

Alexander.


0

Alexander,

I am running Selena.

My problem seems to be that the ant Execution within IDEA is different than that
on the command line even though IDEA is configured to use the same ant version.

In my case, the task definition includes a reference to a whole set of jars that are
part of our project compile/run class path, so hibernate3.jar is on the path and
all of the associated jars as well (dom4j, etc). The particular error I'm seeing
is that when an error occurs, parhaps within SchemaExportTask, the error is that
an Exception class from the dom4j jar is not found, even though the jar is certainly
included.

I will try and use just the hibernate3.jar and friends from the hibernate3 lib to see
if this makes any difference.

Cheers,

Bonny

0

Simon,

I am already doing this (adding the entire project's class path to the task def) and
it working fine when ant is invoked directly on the command line, but not when run
from IDEA.

I'm using the classpathref attribute to refer to our global class path. Is there a particular
method you are using to declare the classpath?

Cheers,

Bonny

0

Please sign in to leave a comment.