This repository has been archived by the owner. It is now read-only.

ant-contrib not installing to ant lib folder #41469

Closed
atrauzzi opened this Issue Jul 7, 2015 · 17 comments

Comments

Projects
None yet
3 participants
@atrauzzi

atrauzzi commented Jul 7, 2015

Just recently attempting to put together a build script in ant that uses ant-contrib. Installed using homebrew.

Ant seems unable to locate the contrib jar. See this stackoverflow answer for more details: http://stackoverflow.com/questions/31277698/how-to-abstract-ant-contrib-cross-platform/31277896#31277896

@atrauzzi

This comment has been minimized.

atrauzzi commented Jul 7, 2015

Solution here might be to ensure ant-contrib gets installed to the correct directory. Otherwise, there isn't much of a point in offering it as part of homebrew.

@DomT4

This comment has been minimized.

Contributor

DomT4 commented Jul 7, 2015

You can see the discussion about inclusion, which includes placement discussion, in #27878.

We could look at adding caveats to the ant-contrib formula with a link to the http://ant-contrib.sourceforge.net/#install page which documents how to use the jar from a separate location.

@atrauzzi

This comment has been minimized.

atrauzzi commented Jul 8, 2015

That doesn't quite make sense unfortunately, especially considering this defines ant as a dependency. Your suggestion obviates using homebrew to manage the package. Currently it's just a glorified downloader and I am better off just statically adding it to my project.
When I install ant-contrib using apt-get on Debian, it gets installed somewhere that ant can resolve and is "ready to go out of the box". This is the behaviour you want to target.

Otherwise, you're effectively telling people to use homebrew to install something and then go to a web page, to download or copy and place it in their projects and ignore the one homebrew installed. Consider that based on your suggestion to use it from a separate location, I'd have to write several lines of ugly detection in my build scripts. Worse still, I wouldn't just be detecting when people are on OSX, I'd also have to detect whether they were using homebrew.

It's much smarter to instead depend on ant-contrib being installed globally on the system. This means placing it where the homebrew-installed ant expects to see jar files. Again, because you have ant-contrib depending on ant, the answer is clear here.

@DomT4

This comment has been minimized.

Contributor

DomT4 commented Jul 8, 2015

Otherwise, you're effectively telling people to use homebrew to install something and then go to a web page, to download or copy and place it in their projects and ignore the one homebrew installed.

I wasn't. The part I was alluding to was:

Keep ant-contrib-0.3.jar in a separate location. You now have to tell Ant explicitly where to find it (say in /usr/share/java/lib):

It's unusual that if this issue is so troublesome as you describe it but we haven't had a report on it before.

I have no particular objection to vendoring it directly into ant as an option aside it isn't an official Apache project and it could mislead people, but will let the rest of @Homebrew/owners discuss it given Mike/Adam made the original decision.

The choice is either the status quo or having it vendored optionally into the ant formula. We're not going to make it so it is its own formula but still installs directly into the ant directory; we've had all sorts of trouble with that dance before.

@atrauzzi

This comment has been minimized.

atrauzzi commented Jul 8, 2015

It's definitely troublesome, and I'd wager that people don't know where to advocate, assume everyone uses OSX or just end up statically bundling it into their projects. Can't always depend on an audience to self-select ;)

If ant is defined as a dependency, why is installing directly to ant a problem? This is the behaviour with apt-get and works beautifully.

@MikeMcQuaid

This comment has been minimized.

Member

MikeMcQuaid commented Jul 8, 2015

Can you provide a reproducible test-case to demonstrate the problem? We aren't apt-get so it's not just as simple as doing things the same way they do.

@atrauzzi

This comment has been minimized.

atrauzzi commented Jul 8, 2015

Here's a "complete" ant build.xml you can use:

<project>
    <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
</project>

On Ubuntu, this works once you install the ant-contrib package. And yeah, while I know you're not apt-get, most everyone brands you as the desperately needed equivalent on OSX. ;)

Again, there is a strong case to be made for removing this package from homebrew if it's not going to be integrated with the system. If it can't be referenced globally, the installation is incomplete and people won't be able to use it without having their build scripts take a dependency on homebrew conventions.

Which won't end well when the build scripts run on a remote build server running linux.

The only way around this problem right now is to download and copy the ant-contrib.jar into the project and reference it directly via:

    <taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <pathelement location="bin/ant-contrib.jar" />
        </classpath>
    </taskdef>
@MikeMcQuaid

This comment has been minimized.

Member

MikeMcQuaid commented Jul 8, 2015

Here's a "complete" ant build.xml you can use:

Sorry, please can you let me know where I should write that file, what command I should run, etc.

@atrauzzi

This comment has been minimized.

atrauzzi commented Jul 8, 2015

Just toss it anywhere and run ant build.xml. It has no sideffects, so should be safe. It'll just attempt to resolve the .jar via normal ant conventions and error out.

Then, if you want, put a copy of ant-contrib.jar in a bin directory relative to the file and replace the taskdef with the 2nd snippet, it should pick it up statically.

@MikeMcQuaid

This comment has been minimized.

Member

MikeMcQuaid commented Jul 8, 2015

Ok, thanks. Where do you/ant consider to be the correct directory?

@atrauzzi

This comment has been minimized.

atrauzzi commented Jul 8, 2015

That's actually a good question. I'm not entirely certain on that one, although the ubuntu package is here: http://packages.ubuntu.com/vivid/all/ant-contrib/filelist

It lists the path as /usr/share/ant/lib/ant-contrib.jar, we'd have to determine some equivalent that the build of ant for homebrew uses.

@DomT4

This comment has been minimized.

Contributor

DomT4 commented Jul 15, 2015

Closed via #41514.

@DomT4 DomT4 closed this Jul 15, 2015

@ghost

This comment has been minimized.

ghost commented Aug 3, 2015

Is this really fixed, because I find I'm getting

  [taskdef] Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found.

with the latest homebrew.

@MikeMcQuaid

This comment has been minimized.

Member

MikeMcQuaid commented Aug 3, 2015

@rleigh-dundee If it isn't: please provide a reproducible test case and, ideally, a PR.

@ghost

This comment has been minimized.

ghost commented Aug 3, 2015

The testcase is pretty much what @atrauzzi described:

cat build.xml
<project name="test">
  <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
  <taskdef resource="net/sf/antcontrib/antlib.xml"/>
</project>
% ant
Buildfile: /private/tmp/build.xml
  [taskdef] Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found.
  [taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.

BUILD SUCCESSFUL
Total time: 0 seconds
@MikeMcQuaid

This comment has been minimized.

Member

MikeMcQuaid commented Aug 3, 2015

Works here. Try to brew reinstall ant ant-contrib && brew test ant-contrib

@ghost

This comment has been minimized.

ghost commented Aug 3, 2015

Hmm, you're right. I'd already reinstalled ant, must have been something with ant-contrib. Sorry for the noise.

@Homebrew Homebrew locked and limited conversation to collaborators Jul 10, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.