Don't get me wrong, I would chose gradle over ant any time for
building a conventional project. But a tool like what I have in mind
"sells" best when it is small and has minimal dependencies.
The biggest problem I see right now with your approach are duplicate
and heavy dependencies. So when somebody writes a tiny shell tool in
Groovy and creates a jar for that depending on Groovy, I would not
want a package installer to download an individual copy of Groovy for
each such tiny application. A hello world Groovy 1KB script becomes a
6MB tar by including groovy-all. That's no way to make JVM languages
popular with the *nix crowd. Not even talking about Spring-based
applications and similar. Downloading groovy-all to .gradle and using
it from there is fine, even having multiple versions of groovy there,
I think that is quite acceptable.
installing duplicate jars in general is still a viable approach given
disk space is cheap, but if it is reasonably possible to avoid the
duplicate download of the same jar, that should be the preferred way,
I think.
That being said I still like your idea for hacking together a
prototype quickly. And maybe the gradle people have an idea for how to
reuse their launcher script generator with shared jars downloaded to a
local gradle/ivy/aether repository. (And again, the other high-level
building frameworks maven, sbt, ... have similar plugins, gradle is
not that special in that respect). I also think about just depending
on the respective classes from within gradle, and bundling those
classes with my app.
Regarding the mainClassName, many jars are already executable by
having a mainClass defined in their META-INF/MANIFEST.MF. By using
that, without any action by maintainers, I'd get thousands of working
applications already (like jftp). And maintainers would not be tied to
my application, they could just follow age-old Java standards.
For more ambitious projects delivering more than one executable in a
single jar, that sadly does not work, similar as other ideas like
manpages and bash completion, so for such things another metadata
format would be required, as far as I can see. Even then I would not
want specs written for gradle as target framework, but rather a
declarative format that can easily be mapped to any tool, and in
particlar one that allows easy generation of deb files and such as
well (two birds, one stone).
I agree that search over all jars on maven central is less useful than
searching just within the jars that are executable, but that is
something that can be solved later on one way or the other. Also while
it is not my main concern right now, it is possible to extend my idea
to 'install' library jars (without executables) to have them in a
classpath, possibly similar to virtualenv. Just like grape install
does (without the classpath bit). Not sure where that would lead, but
it is something lurking at the back of my mind.
However all my reservations do not mean that for your internal
solution, I would have done differently. For that, your approach seems
fine to me.
Post by Dylan CaliSome replies inline
Post by Thibault KruseHi Dylan,
I see. I had not understood before. Actually I did not notice you
posted twice, so I did not read your two messages in context. Sorry.
No problem
Post by Thibault KruseWhat your gradle spec approach solves then is the lookup of a
dependency on a remote repository, the installation to a local folder,
and the creation of a launchable script given a jar and a main class
name. Organizing these build results would remain to be done.
Well like I mentioned, I think that's easy. Just default to
$HOME/.java-apps or something as the application plugin install dir,
and symlink into a common bin ($HOME/.java-apps/bin) the user can put
on their path (Windows would be a little trickier, but hey everything
on windows is trickier...)
Post by Thibault KruseI would like to avoid hosting anything, but your approach can also
work with jcenter() to some degree, one can get the mainClassName from
a manifest, and run gradle locally.
That would not be quite as powerful, though one can imagine shipping
such a gradle spec file on maven central as well.
I think the advantage of a spec based approach is that you don't have
to do complicated gymnastics to figure out stuff like the main class
name (by querying jcenter or whatever). Just save it in the spec for
each app and then there's no guessing.
Post by Thibault KruseI have to think some more about it. I do not like to depend on gradle
(I was rather looking for ways to eventually only depend on Java + Ivy
or Java + Aether), but I can see that the application plugin of gradle
does a useful job of bundling distribution files in a folder and
creating a laauncher script.
I don't think depending on gradle should be considered a bad thing...
reusing gradle's functionality and plugin ecosystem I think is a very
good thing.
Post by Thibault KrusePossibly other JVM build tools have similar / better capabilities of
creating launcher scripts, that would have to be investigated. If ant
had something similar, that would propbably be nicer.
I'd have a hard time being convinced that an ant based approach would
be nicer :) Although if ant did have some killer task there was no
equivalent gradle plugin for you can after all call ant tasks from
gradle.
Post by Thibault KruseIt's worth trying that out in my gpi project as a branch. My search
function based on Maven central search already works, and that part is
something that gradle could not solve anyway.
Another advantage of a spec based approach I think is it makes search
easy. If every spec name corresponds to the app name (jftp.gradle),
then search could be a simple "is there a spec with this name?" And
that includes using regexes to find matching spec names.
A downside would be if there's no spec for an app, then it's like the
app doesn't exist. But maybe this is also an upside since it would
promote following a common app distribution pattern, which the jvm
doesn't really have right now. Also for projects that don't currently
host their projects on maven central or jcenter, it would force them
to join that ecosystem (make them "embeddable first" to use Cedric's
term).
Once a gradle build spec is loaded it's just groovy after all, so it
should make other things easy like adding hooks for descriptions.
Full disclosure: I've been having to do a ton of Gradle programming
of late (writing plugins and whatnot), so that's probably why my brain
is hot on Gradle right now... but frankly it's been an awesome
experience and has been a huge force multiplier for my team. And at
least based on my recent experience the functionality we're discussing
here would be very naturally done as a Gradle plugin (or plugins).
Cheers,
Dylan
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email