jarjar netty as well, so it won't be exposed to users using elasticsearch embedded

This commit is contained in:
kimchy 2010-05-13 14:41:50 +03:00
parent 7ba1ad2d7b
commit f6777f1e03
8 changed files with 83 additions and 38 deletions

View File

@ -53,6 +53,7 @@ dependencies {
}
task explodedDist(dependsOn: [configurations.distLib], description: 'Builds a minimal distribution image') << {
ant.delete(dir: explodedDistDir) // clean the exploded dir
[explodedDistDir, explodedDistLibDir, explodedDistBinDir, explodedDistConfigDir]*.mkdirs()
// remove old elasticsearch files
ant.delete { fileset(dir: explodedDistLibDir, includes: "$archivesBaseName-*.jar") }
@ -81,6 +82,7 @@ task explodedDist(dependsOn: [configurations.distLib], description: 'Builds a mi
ant.delete { fileset(dir: explodedDistLibDir, includes: "joda-*.jar") } // no need joda, we jarjar it
ant.delete { fileset(dir: explodedDistLibDir, includes: "snakeyaml-*.jar") } // no need snakeyaml, we jarjar it
ant.delete { fileset(dir: explodedDistLibDir, includes: "sigar-*.jar") } // no need sigar directly under lib...
ant.delete { fileset(dir: explodedDistLibDir, includes: "netty-*.jar") } // no need sigar directly under lib...
ant.chmod(dir: "$explodedDistDir/bin", perm: "ugo+rx", includes: "**/*")
}

View File

@ -17,8 +17,6 @@ processResources.doLast {
}
}
manifest.mainAttributes("Implementation-Title": "ElasticSearch", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
// no need to use the resource dir
sourceSets.main.resources.srcDirs 'src/main/java', rootProject.file('config')
sourceSets.test.resources.srcDirs 'src/test/java'
@ -58,10 +56,12 @@ dependencies {
tools "com.google.code:jarjar:1.0"
}
// add the source files to the dist jar
//jar {
jar {
// from sourceSets.main.allJava
//}
manifest {
attributes("Implementation-Title": "ElasticSearch", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
}
}
jar << {
jarjarArchivePath = new File(jar.archivePath.absolutePath + ".jarjar.jar")
@ -70,7 +70,7 @@ jar << {
jarjar(jarfile: jarjarArchivePath) {
zipfileset(src: jar.archivePath)
configurations.compile.files.findAll {file ->
['jackson', 'joda', 'snakeyaml'].any { file.name.contains(it) }
['jackson', 'joda', 'snakeyaml', 'netty'].any { file.name.contains(it) }
}.each { jarjarFile ->
zipfileset(src: jarjarFile) {
exclude(name: "META-INF/**")
@ -79,10 +79,22 @@ jar << {
rule pattern: "org.codehaus.jackson.**", result: "org.elasticsearch.util.jackson.@1"
rule pattern: "org.joda.**", result: "org.elasticsearch.util.joda.@1"
rule pattern: "org.yaml.**", result: "org.elasticsearch.util.yaml.@1"
rule pattern: "org.jboss.netty.**", result: "org.elasticsearch.util.netty.@1"
}
delete(file: jar.archivePath)
copy(file: jarjarArchivePath, tofile: jar.archivePath)
delete(file: jarjarArchivePath)
// seems like empty dirst still exists, unjar and clean them
unjar(src: jar.archivePath, dest: "build/tmp/extracted")
delete(dir: "build/tmp/extracted/org/codehaus")
delete(dir: "build/tmp/extracted/org/joda")
delete(dir: "build/tmp/extracted/org/yaml")
delete(dir: "build/tmp/extracted/org/jboss")
delete(file: jar.archivePath)
jar(destfile: jar.archivePath, basedir: "build/tmp/extracted")
delete(dir: "build/tmp/extracted")
}
}
@ -149,8 +161,7 @@ uploadArchives {
pom.dependencies = pom.dependencies.findAll {dep -> !dep.artifactId.contains('jackson') }
pom.dependencies = pom.dependencies.findAll {dep -> !dep.artifactId.contains('joda') }
pom.dependencies = pom.dependencies.findAll {dep -> !dep.artifactId.contains('snakeyaml') }
// keep netty required for simpler usage
// pom.dependencies.findAll {dep -> dep.groupId == 'org.jboss.netty' }*.scope = 'runtime'
pom.dependencies = pom.dependencies.findAll {dep -> !dep.artifactId.contains('netty') }
}
}
}

View File

@ -7,8 +7,6 @@ archivesBaseName = "elasticsearch-client-groovy"
explodedDistDir = new File(distsDir, 'exploded')
manifest.mainAttributes("Implementation-Title": "ElasticSearch::Plugins::Client::Groovy", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
configurations.compile.transitive = true
configurations.testCompile.transitive = true
@ -99,6 +97,14 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
}
jar {
// from sourceSets.main.allJava
manifest {
attributes("Implementation-Title": "ElasticSearch", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
}
}
artifacts {
archives sourcesJar
archives javadocJar

View File

@ -7,8 +7,6 @@ archivesBaseName = "elasticsearch-cloud"
explodedDistDir = new File(distsDir, 'exploded')
manifest.mainAttributes("Implementation-Title": "ElasticSearch::Plugins::Cloud", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
configurations.compile.transitive = true
configurations.testCompile.transitive = true
@ -125,6 +123,13 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
}
jar {
// from sourceSets.main.allJava
manifest {
attributes("Implementation-Title": "ElasticSearch", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
}
}
artifacts {
archives sourcesJar
archives javadocJar

View File

@ -7,8 +7,6 @@ archivesBaseName = "elasticsearch-discovery-jgroups"
explodedDistDir = new File(distsDir, 'exploded')
manifest.mainAttributes("Implementation-Title": "ElasticSearch::Plugins::Discovery::Jgrorups", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
configurations.compile.transitive = true
configurations.testCompile.transitive = true
@ -16,10 +14,12 @@ configurations.testCompile.transitive = true
sourceSets.main.resources.srcDirs 'src/main/java'
sourceSets.test.resources.srcDirs 'src/test/java'
// add the source files to the dist jar
//jar {
jar {
// from sourceSets.main.allJava
//}
manifest {
attributes("Implementation-Title": "ElasticSearch", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
}
}
configurations {
dists

View File

@ -7,8 +7,6 @@ archivesBaseName = "elasticsearch-mapper-attachments"
explodedDistDir = new File(distsDir, 'exploded')
manifest.mainAttributes("Implementation-Title": "ElasticSearch::Plugins::Mapper::Attachments", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
configurations.compile.transitive = true
configurations.testCompile.transitive = true
@ -16,10 +14,12 @@ configurations.testCompile.transitive = true
sourceSets.main.resources.srcDirs 'src/main/java'
sourceSets.test.resources.srcDirs 'src/test/java'
// add the source files to the dist jar
//jar {
jar {
// from sourceSets.main.allJava
//}
manifest {
attributes("Implementation-Title": "ElasticSearch", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
}
}
configurations {
dists

View File

@ -7,8 +7,6 @@ archivesBaseName = "elasticsearch-transport-memcached"
explodedDistDir = new File(distsDir, 'exploded')
manifest.mainAttributes("Implementation-Title": "ElasticSearch::Plugins::Transport::Memcached", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
configurations.compile.transitive = true
configurations.testCompile.transitive = true
@ -16,10 +14,12 @@ configurations.testCompile.transitive = true
sourceSets.main.resources.srcDirs 'src/main/java'
sourceSets.test.resources.srcDirs 'src/test/java'
// add the source files to the dist jar
//jar {
jar {
// from sourceSets.main.allJava
//}
manifest {
attributes("Implementation-Title": "ElasticSearch", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
}
}
configurations {
dists
@ -84,10 +84,12 @@ task release(dependsOn: [zip]) << {
configurations {
deployerJars
tools
}
dependencies {
deployerJars "org.apache.maven.wagon:wagon-http:1.0-beta-2"
tools "com.google.code:jarjar:1.0"
}
task sourcesJar(type: Jar, dependsOn: classes) {
@ -105,6 +107,36 @@ artifacts {
archives javadocJar
}
jar << {
jarjarArchivePath = new File(jar.archivePath.absolutePath + ".jarjar.jar")
project.ant {
taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask", classpath: configurations.tools.asPath
jarjar(jarfile: jarjarArchivePath) {
zipfileset(src: jar.archivePath)
configurations.compile.files.findAll {file ->
['netty'].any { file.name.contains(it) }
}.each { jarjarFile ->
zipfileset(src: jarjarFile) {
exclude(name: "META-INF/**")
}
}
rule pattern: "org.jboss.netty.**", result: "org.elasticsearch.util.netty.@1"
}
delete(file: jar.archivePath)
copy(file: jarjarArchivePath, tofile: jar.archivePath)
delete(file: jarjarArchivePath)
// hack, we want to reuse the jarjar of elasticsearch into util.netty, but don't want it to be in memcached jar
unjar(src: jar.archivePath, dest: "build/tmp/extracted")
delete(dir: "build/tmp/extracted/org/elasticsearch/util/netty")
delete(dir: "build/tmp/extracted/org/jboss")
delete(file: jar.archivePath)
jar(destfile: jar.archivePath, basedir: "build/tmp/extracted", manifest: "build/tmp/extracted/META-INF/MANIFEST.MF")
delete(dir: "build/tmp/extracted")
}
}
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deployerJars

View File

@ -24,7 +24,6 @@ import org.elasticsearch.http.BindHttpException;
import org.elasticsearch.memcached.MemcachedServerTransport;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.transport.BindTransportException;
import org.elasticsearch.transport.netty.NettyInternalESLoggerFactory;
import org.elasticsearch.util.SizeValue;
import org.elasticsearch.util.component.AbstractLifecycleComponent;
import org.elasticsearch.util.inject.Inject;
@ -40,8 +39,6 @@ import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import java.io.IOException;
import java.net.InetAddress;
@ -56,14 +53,6 @@ import static org.elasticsearch.util.concurrent.DynamicExecutors.*;
*/
public class NettyMemcachedServerTransport extends AbstractLifecycleComponent<MemcachedServerTransport> implements MemcachedServerTransport {
static {
InternalLoggerFactory.setDefaultFactory(new NettyInternalESLoggerFactory() {
@Override public InternalLogger newInstance(String name) {
return super.newInstance(name.replace("org.jboss.netty.", "netty."));
}
});
}
private final RestController restController;
private final NetworkService networkService;