Hi Jörg,
This is excellent and worked a treat. Thank you so much, for future reference,
once the dependencies are declared with a <scope>, here is the correct plugin
configuration solution
<!-- Used to provide dynamic OpenIE toggling within service -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>provided</includeScope>
<outputDirectory>${output.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Really clean and very useful.
Thank you
Lewis
On 2018/02/23 23:05:42, Jörg Schaible <[email protected]> wrote:
> Hi,
>
> if you use the copy goal, you don't have to add them to your list of
> dependencies. Personally I would use the
> copy-dependencies goal and copy only the ones with scope provided (i.e. you
> don't have to specify each one
> again).
>
> Cheers,
> Jörg
>
>
> Am Fri, 23 Feb 2018 09:58:09 -0800 schrieb lewis john mcgibbney:
>
> > I should also say, that the workaround is to list each and every
> > transitive dependency in the dependency declaration with scope
> > 'provided', such that they are NOT on the normal runtime classpath but
> > ARE correctly copied into the target directory defined within the
> > maven-dependency-plugin configuration as shown above.
> > The only issue with this workaround is that it is extremely messy,
> > bloats my POM and is difficult to maintain as I have now introduced
> > around 50 or so additional dependencies which all have versions, etc.
> > Thanks again for any hints.
> > Lewis
> >
> > On Fri, Feb 23, 2018 at 9:55 AM, lewis john mcgibbney
> > <[email protected]> wrote:
> >
> >> Hello users@,
> >> I am looking to dynamically load JAR's during a program execution based
> >> upon a users input and therefore using the maven-dependency-plugin to
> >> do this.
> >> Specifically, the plugin configuration looks as follows
> >>
> >> <plugin>
> >> <groupId>org.apache.maven.plugins</groupId>
> >> <artifactId>maven-dependency-plugin</artifactId>
> >> <executions>
> >> <execution>
> >> <id>copy</id> <phase>prepare-package</phase>
> >> <goals>
> >> <goal>copy</goal>
> >> </goals>
> >> <configuration>
> >> <artifactItems>
> >> <artifactItem>
> >> <groupId>org.apache.any23.plugins</groupId>
> >> <artifactId>apache-any23-openie</artifactId>
> >> <version>${project.version}</version>
> >> <outputDirectory>${output.directory}</outputDirectory>
> >> </artifactItem>
> >> ...
> >> This works fine, however I have an issue with regards to these specific
> >> JARs being present on the classpath during the build and runtime
> >> depending on the </scope> I assign to them within the dependency
> >> definition.
> >> If I mark the scope as 'runtime', the dependencies are added to the
> >> normal classpath which I do not want, as the purpose here is dynamic
> >> classloading via user input.
> >> On the other hand, if I define the dependency scope as 'provided' then
> >> no transitive dependencies are acquired hence I encounter
> >> java.lang.NoClassDefFoundError as although the primary dependency is
> >> present, it's own dependencies are not.
> >>
> >> Does anyone have a way to get around this. Ideally I am looking for a
> >> solution to define a specific location I was dependencies (and the
> >> transitive dependencies) to reside such that I can load them
> >> dynamically at runtime.
> >> Thank you kindly in advance,
> >> Lewis
> >>
> >> --
> >> http://home.apache.org/~lewismc/
> >> http://people.apache.org/keys/committer/lewismc
> >>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]