ElasticSearch + ProGuard


(Adam Warski) #1

Hello,

I'm trying to run ProGuard on one project that includes ElasticSearch.
However the process fails with a DuplicateZipEntry exception:

[error] {file:/Users/adamw/projects/...}.../*:proguard:
java.io.IOException: Can't write
[/Users/adamw/projects/.../target/scala-2.9.1/....min.jar] (Can't read
[/Users/adamw/.ivy2/cache/org.elasticsearch/elasticsearch/jars/elasticsearch-0.19.10.jar(;;;;!META-INF/MANIFEST.MF)]
(Duplicate zip entry
[elasticsearch-0.19.10.jar:org/apache/lucene/index/BufferedDeletesStream$1.class]))

When looking at the BufferedDeletesStream class, indeed it says:

// LUCENE MONITOR: We copied this class from Lucene, effectively overriding
it with our implementation
// if it comes first in the classpath, allowing for faster apply deletes
based on terms

which is the cause of the issue. Not sure if it will be a problem for
anyone else. Still looking for a solution using proguard configuration,
just letting you know :).

Adam

--


(Ivan Brusic) #2

ElasticSearch shadows the Lucene library, so one option would be to not to
include Lucene.

--
Ivan

On Fri, Oct 26, 2012 at 3:24 AM, Adam Warski adamwtw@gmail.com wrote:

Hello,

I'm trying to run ProGuard on one project that includes ElasticSearch.
However the process fails with a DuplicateZipEntry exception:

[error] {file:/Users/adamw/projects/...}.../*:proguard:
java.io.IOException: Can't write
[/Users/adamw/projects/.../target/scala-2.9.1/....min.jar] (Can't read
[/Users/adamw/.ivy2/cache/org.elasticsearch/elasticsearch/jars/elasticsearch-0.19.10.jar(;;;;!META-INF/MANIFEST.MF)]
(Duplicate zip entry
[elasticsearch-0.19.10.jar:org/apache/lucene/index/BufferedDeletesStream$1.class]))

When looking at the BufferedDeletesStream class, indeed it says:

// LUCENE MONITOR: We copied this class from Lucene, effectively
overriding it with our implementation
// if it comes first in the classpath, allowing for faster apply deletes
based on terms

which is the cause of the issue. Not sure if it will be a problem for
anyone else. Still looking for a solution using proguard configuration,
just letting you know :).

Adam

--

--


(Adam Warski-2) #3

Well it shadows only this one particular class.

I found a solution, basically you need to exclude that class from proguard. If you're using xsbt-proguarg-pluing, you need to set this setting:

val proguardFileFilter = (file: String) => {
if (file.contains("lucene-core"))
"!META-INF/MANIFEST.MF,!org/apache/lucene/index/BufferedDeletesStream*.class"
else {
"!META-INF/MANIFEST.MF"
}
}

// From ProguardPlugin.proguardSettings
makeInJarFilter := proguardFileFilter

Adam

On Oct 26, 2012, at 6:09 PM, Ivan Brusic ivan@brusic.com wrote:

ElasticSearch shadows the Lucene library, so one option would be to not to include Lucene.

--
Ivan

On Fri, Oct 26, 2012 at 3:24 AM, Adam Warski adamwtw@gmail.com wrote:
Hello,

I'm trying to run ProGuard on one project that includes ElasticSearch. However the process fails with a DuplicateZipEntry exception:

[error] {file:/Users/adamw/projects/...}.../*:proguard: java.io.IOException: Can't write [/Users/adamw/projects/.../target/scala-2.9.1/....min.jar] (Can't read [/Users/adamw/.ivy2/cache/org.elasticsearch/elasticsearch/jars/elasticsearch-0.19.10.jar(;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [elasticsearch-0.19.10.jar:org/apache/lucene/index/BufferedDeletesStream$1.class]))

When looking at the BufferedDeletesStream class, indeed it says:

// LUCENE MONITOR: We copied this class from Lucene, effectively overriding it with our implementation
// if it comes first in the classpath, allowing for faster apply deletes based on terms

which is the cause of the issue. Not sure if it will be a problem for anyone else. Still looking for a solution using proguard configuration, just letting you know :).

Adam

--

--

--
Adam Warski

http://twitter.com/#!/adamwarski


--


(system) #4