I had the same need on a prior product, needed two jars to test the
processing.

After trying to find built-in Maven features/plugins to solve, including
Embedder and other "Maven runners" I found with Google, I found the
clearest and simplest approach was to make a nearly empty pom for each jar
in separate subdirectories in src/test/resources (along with the needed
files) and run Maven for each pom at test startup to install into local
repo.
I found the easiest way to run Maven was
final Runtime runtime = Runtime.getRuntime();
runtime.exec(mvnCommand, envp, dir);

* Creating mvnCommand required and used Maven home env var, detected which
OS for the script (to run mvn or mvn.cmd), and included "clean install".
* envp was null.
* dir was the respective pom.xml directory.

HTH


On Thu, Aug 18, 2016 at 8:47 PM, Christopher <ctubb...@apache.org> wrote:

> If this were a personal project, I'd probably do that... but this is for an
> ASF project, and I don't want to put us in a position where we are
> releasing with binaries in the source artifact.
>
> On Thu, Aug 18, 2016 at 9:39 PM jieryn <jie...@gmail.com> wrote:
>
> > Create the jar and then put it under src/test/resources/my.jar and
> > then refer to that my.jar in your testcase. It seems like an awful lot
> > of trouble to dynamically create this test artifact, when you could
> > just create it once and then add it to your repository. Yes, adding
> > jars to your scm is generally bad, but this seems like a perfect
> > exception.
> >
> > On Thu, Aug 18, 2016 at 9:36 PM, Christopher <ctubb...@apache.org>
> wrote:
> > > Hi Maven Users list,
> > >
> > > What's the best way to create a jar during a build without attaching
> it?
> > >
> > > Currently, our pom is configured to use the maven-jar-plugin to create
> > it,
> > > but that plugin attaches an artifact, which gets deployed. We don't
> want
> > > that. That doesn't seem to be configurable.
> > >
> > > We could create a mini project and use maven-invoker-plugin to package
> > it,
> > > but that's a lot of overhead (configuration and processing time) for a
> > very
> > > small test jar containing a single file (used to test a classloader).
> > >
> > > We've also considered just using maven-exec-plugin to execute the jar
> > > command-line tool, but that's tricky to get right, accounting for
> > > JAVA_HOME, toolchains, etc.
> > >
> > > Any suggestions, or is maven-invoker-plugin the best option?
> > >
> > > I think the maven-assembly-plugin might be able to do it, and it has an
> > > <attach>false</attach> option, but I've never used it like this before.
> > If
> > > that's the best option, does anybody have any examples of that kind of
> > > thing?
> > >
> > > Thanks.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> > For additional commands, e-mail: users-h...@maven.apache.org
> >
> >
>

Reply via email to