Hi,
To me this feels like a legitimate question. But it also feels like a
really hard one that should be solved with caution to avoid fragmentation
like in the famous "standards" xkcd https://xkcd.com/927/ . So perhaps the
first thing to do is to gather as many ideas as possible from other
languages/platforms. And not rush to get this in maven 4.

Personally it makes me think of python or ruby where you can install system
packages (e.g. apt in debian) to make you python scripts work like when you
install binaries to make your shell scripts work.. this has drawbacks
(system wide versioning, manual installs, package manager specific,
probably more..) which in turn call out for even more solutions (venv, self
installing scripts, using the language package manager instead of the
system one).

The person giving this talk https://youtu.be/04wFgshWMdA seems to have
knowledge and ideas about this problem.

Just like jbang mentionned in the talk, in python they are looking into
comments ( https://peps.python.org/pep-0723/ ) to include the metadata in
the script. The pep explains in details what alternatives to comments were
explored and why comments were chosen.

 I personnally use the technique from
https://stackoverflow.com/questions/71101377/jshell-use-external-dependency-from-maven-repository
with "build-classpath - Dmdep.outputFile=/dev/stdout" or equivalent to
include the librairies in the classpath, it's not very nice but has the
advantage of not depending on yet another tool. Also using comments for
this like in jbang to me feels wrong, like the lsb "init info"
required-start comments in the sysvinit bash scripts to declare order used
by upstart which is now widely considered as a bad idea..

But maybe jbang will be the pragmatic solution with its tradeoffs that are
more adapted for one-off scripts?

Give the complexity, the number of different avenues to explore in search
of a solution, i'm not surprised no consensus has been found (yet?)

Chers,
Jon

Le
lun. 22 déc. 2025, 08:42, Romain Manni-Bucau <[email protected]> a
écrit :

> Hi,
>
> Yes this is the one.
>
> As mentionned, it had been done in plugins but it is never integrated to
> IDE so totally useless cause you miss complétion on the right classpath so
> moving it from plugins to core can make it and encourage the adoption way
> more IMHO.
>
>
> Romain Manni-Bucau
> @rmannibucau <https://x.com/rmannibucau> | .NET Blog
> <https://dotnetbirdie.github.io/> | Blog <https://rmannibucau.github.io/>
> | Old
> Blog <http://rmannibucau.wordpress.com> | Github
> <https://github.com/rmannibucau> | LinkedIn
> <https://www.linkedin.com/in/rmannibucau> | Book
> <
> https://www.packtpub.com/en-us/product/java-ee-8-high-performance-9781788473064
> >
> Javaccino founder (Java/.NET service - contact via linkedin)
>
> Le lun. 22 déc. 2025, 07:42, Gerd Aschemann <[email protected]> a écrit :
>
> > I just crafted a short proposal on the problem and a possible solution
> > (see below).
> >
> > @Romain: Does it cover your problem/solution?
> > @Elliotte: Is this kind of the one pager you were thinking of?
> > @Martin: Wrt. your performance considerations, could the solution do some
> > caching to make it more lightweight (after first execution)?
> >
> >
> > # Proposal: mvn --execute for Java Scripts with Dependencies
> >
> > ## Problem
> >
> > JDK 25 finalizes Compact Source Files (JEP 512) for simple Java programs
> > without class declarations.
> > However, dependency management remains unsolved for single-file scripts.
> > Using pom.xml + exec-maven-plugin is too heavy, and JBang introduces a
> > separate ecosystem.
> >
> > ## Proposal
> >
> > Add `mvn --execute`  (or `mvn -E`) that:
> >
> > 1. Parses //MVN comments for dependency declarations
> > 2. Resolves dependencies using Maven Resolver (respects
> ~/.m2/settings.xml)
> > 3. Executes the script with the resolved classpath
> >
> > ## Example
> >
> > File: analyze.java
> >
> > ```
> > #!/usr/bin/env mvn --execute
> > //MVN com.google.guava:guava:33.0.0-jre
> > //MVN org.slf4j:slf4j-simple:2.0.9
> >
> > import com.google.common.collect.ImmutableList;
> > import org.slf4j.Logger;
> > import org.slf4j.LoggerFactory;
> >
> > void main() {
> >     Logger log = LoggerFactory.getLogger("analyze");
> >     var items = ImmutableList.of("alpha", "beta", "gamma");
> >     log.info("Processing {} items", items.size());
> >     items.forEach(item -> println("  - " + item));
> > }
> > ```
> >
> > Run: `chmod +x analyze.java && ./analyze.java`
> >
> > Or: `mvn --execute analyze.java`
> >
> > ## Performance
> >
> > Cache resolved classpath next to script, recompute only when dependencies
> > change.
> >
> >
> > > On 22. Dec 2025, at 01:10, Martin Desruisseaux via dev <
> > [email protected]> wrote:
> > >
> > > Le 21/12/2025 à 21:11, Romain Manni-Bucau a écrit :
> > >
> > >> I just want to run a "java -cp xxxx foo.java" with xxx being filled
> > portably accross machines.
> > >>
> > > But using Maven for launching an application is heavy. Could it be
> > instead a plugin or command which generates the `java` options in a file?
> > The content of that file may be specific to each machine, but we can
> handle
> > that as a cache. A shell script can invoke a Maven plugin for generating
> > that file if it does not exist, otherwise just invoke `java @the-file`.
> > >
> > >     Martin
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [email protected]
> > > For additional commands, e-mail: [email protected]
> > >
> >
> > --
> > Gerd Aschemann --- Veröffentlichen heißt Verändern (Carmen Thomas)
> > +49/173/3264070 -- [email protected] -- http://www.aschemann.net
> >
> >
>
Jon

Reply via email to