How to get Ant Build to list all targets in a hierarchy of build files.

I'm using an ant-based SDK that has several levels of hierarchy (This happens to be the Liferay Portlet Plugins SDK, but that is not necessarily important to the question I'm asking).  At an individual project level, I'm at the third layer.

SDK
     build.xml
     plugin-type-A
          build.xml
     plugin-type-B
          build.xml
     plugin-type-C
          build.xml
          project
               build.xml

So say I'm working a the project level.  The build file here has almost nothing in it, it just imports the parent, which imports the parent, etc.  It is here to tie the project-level directory into the build system, and to create a place for you to have your own targets and do customization, but rarely are any needed.  When I do a 'ant -p -v' in my project directory I get this:


< a bunch of messages about properties and classpath info etc...  >

Main targets:

clean          clean
clean-service  clean generated service builder files
Other targets:

all
build-client
build-common-plugin.war
build-css
build-db
build-lang
build-lang-cmd
build-service
build-wsdd
build-wsdl
build-xsd
clean-portal-dependencies
compile
compile-java
compile-test
compile-test-cmd
compile-test-integration
compile-test-unit
deploy
direct-deploy
format-javadoc
format-source
format-wsdl
format-xsd
merge
merge-unzip
print-current-time
setup-eclipse
shrink-zip-cmd
test
test-class
test-cmd
test-integration
test-unit
war
Default target: deploy


But the IDE only shows the one target I happened to define in the project's ant file (in this case clean-service).  I can run the default target, or my locally defined target, but none of the other parent targets are available in any contextual menus or the Ant Build window.

I've read the help and googled for this, but the only info I've found that comes close to addressing this has to do with filters in the Ant Build window.  When I go there, I actually see three possible targets (clean-service, build-css, and war), and I can check the box to make them available, but I don't see anything that comes close to the entire list of targets provided by 'ant -p -v'

So.  What do I do to get Idea to display (and make available in context menus) all targets available to an ant build file?

2 comments
Comment actions Permalink

It's been a while since I've worked on a project with an Ant build (having switched to Maven). But if memory serves me correct, by default, IDEA only shows the default target and targets that have descriptions. To show other targets, you have two options.

  1. There's a filter button filter.png on the top toolbar of the Ant tool window. That toggles on viewing all targets, or the filtered ones (with the default filtering as mentioned above)
  2. You can add targets to the unfiltered view by opening the build file properties by clicking on the properties button properties.png on the top toolbar, or (by default) typing Alt+Enter. On the Build Files Properties dialog, click the Filters tab. There you can select which targets to show when the filter is active.


If I recall correctly, IDEA does not show the targets for ant build files that are imported from a primary file. To see those targets, you need to add the build file to list of build files. Click the add button (the plus sign) on the top of the ant toolbar to add an additional build file to the project window. Alternatively, you can right click the file in the Project Window and select the Add as Ant Build File option (I'm not sure of the exact wording off hand, but it is something like that).

I think that should help you resolve the issue for you.

0
Comment actions Permalink

Thanks Mark,

The steps you outline are the ones I was referring to in my OP regarding the filter settings in the "Ant Build" window and related functions.

I subsequently re-made the project and explicitly added the upstream ant files to the Ant Build tools.  I discovered that if I add the upstream files first, then all the targets appear in the bottom-most antfile target list.  But -- if I add the bottom most file first, then they do not appear.

So... problem solved, in that the targets are available to me as needed.  But, I can't say there's a definitive solution to the behavior of Idea in this case -- this feels like it is just coincidence.

0

Please sign in to leave a comment.