Maven shade during build strips guava classes


(Alexander Reelsen) #1

Hi there,

I am struggling right now with a strange problem of missing classes of
google guava in elasticsearch, even though the non-shaded version
includes what I am searching for.

The concrete class is the
com.google.common.util.concurrent.AbstractScheduledService, which I
would like to use. However, it seems not to be available in
elasticsearch 0.19.10, and it is also not available when I am
searching for, after I build the jar myself from the current github
master.
I could not find anything obvious about excluding it on the pom.xml,
however I've never really worked with the shade plugin, so there might
be some setting I just have overlooked.

The only thing I could imagine is, that it is missing because there is
a different relocation happening for
org.elasticsearch.common.util.concurrent.jsr166y and
org.elasticsearch.common.util.concurrent.jsr166e packages.

Can anyone shed light on this?

Thanks and regards, Alexander

--


(Chris Male) #2

Hi,

Funny you raise this issue, a few similar situation tripped me up just
recently too.

What the shade plugin configuration is doing is basically picking a few
packages from Guava and 'shading' them into the ES jar until new package
names. The Guava dependency, including those packages not shaded, is then
not distributed along with ES. AbstractScheduledService is in a package
which is not shaded, which is why you cannot find it.

Are you creating a plugin or using ES in a client application? If so, you
can go ahead and include a Guava version in your application and because ES
has shaded its use of Guava to new packages, you won't have any classpath
collisions.

On Sunday, October 7, 2012 10:55:18 PM UTC+13, Alexander Reelsen wrote:

Hi there,

I am struggling right now with a strange problem of missing classes of
google guava in elasticsearch, even though the non-shaded version
includes what I am searching for.

The concrete class is the
com.google.common.util.concurrent.AbstractScheduledService, which I
would like to use. However, it seems not to be available in
elasticsearch 0.19.10, and it is also not available when I am
searching for, after I build the jar myself from the current github
master.
I could not find anything obvious about excluding it on the pom.xml,
however I've never really worked with the shade plugin, so there might
be some setting I just have overlooked.

The only thing I could imagine is, that it is missing because there is
a different relocation happening for
org.elasticsearch.common.util.concurrent.jsr166y and
org.elasticsearch.common.util.concurrent.jsr166e packages.

Can anyone shed light on this?

Thanks and regards, Alexander

--


(Jörg Prante) #3

The reason is the "minimize = true" option in the shading, this drops all
classes not used from the included jars.

Jörg

On Monday, October 8, 2012 5:37:27 AM UTC+2, Chris Male wrote:

Hi,

Funny you raise this issue, a few similar situation tripped me up just
recently too.

What the shade plugin configuration is doing is basically picking a few
packages from Guava and 'shading' them into the ES jar until new package
names. The Guava dependency, including those packages not shaded, is then
not distributed along with ES. AbstractScheduledService is in a package
which is not shaded, which is why you cannot find it.

Are you creating a plugin or using ES in a client application? If so, you
can go ahead and include a Guava version in your application and because ES
has shaded its use of Guava to new packages, you won't have any classpath
collisions.

On Sunday, October 7, 2012 10:55:18 PM UTC+13, Alexander Reelsen wrote:

Hi there,

I am struggling right now with a strange problem of missing classes of
google guava in elasticsearch, even though the non-shaded version
includes what I am searching for.

The concrete class is the
com.google.common.util.concurrent.AbstractScheduledService, which I
would like to use. However, it seems not to be available in
elasticsearch 0.19.10, and it is also not available when I am
searching for, after I build the jar myself from the current github
master.
I could not find anything obvious about excluding it on the pom.xml,
however I've never really worked with the shade plugin, so there might
be some setting I just have overlooked.

The only thing I could imagine is, that it is missing because there is
a different relocation happening for
org.elasticsearch.common.util.concurrent.jsr166y and
org.elasticsearch.common.util.concurrent.jsr166e packages.

Can anyone shed light on this?

Thanks and regards, Alexander

--


(Alexander Reelsen) #4

Hi

On Mon, Oct 8, 2012 at 10:21 AM, Jörg Prante joergprante@gmail.com wrote:

The reason is the "minimize = true" option in the shading, this drops all
classes not used from the included jars.
Damn, had overlooked that one. Thanks for pointing out!
Chris: I am writing a plugin, but it shouldnt be a problem as well to
include guava in it, as the package path is changed for the
elasticsearch specific part. However, moving in the whole dependency
just for the abstract service seems too much, I'll keep with threads
then...

Thanks for your help!

--Alexander

--


(system) #5