adding ability for gradle to create eclipse project files and classpaths

This commit is contained in:
Paul_Loy 2011-05-23 15:14:22 +01:00 committed by kimchy
parent 1d8b545854
commit 6a60bbba1d
17 changed files with 181 additions and 0 deletions

9
.gitignore vendored
View File

@ -24,3 +24,12 @@ plugins/river/twitter/build
plugins/river/wikipedia/build
plugins/transport/memcached/build
plugins/transport/thrift/build
## eclipse ignores (use 'gradle eclipse' to build eclipse projects)
.project
.classpath
.settings
*/.project
*/.classpath
*/.settings
*/eclipse-build

View File

@ -2,6 +2,7 @@ dependsOn(':test-testng')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "$project.archivesBaseName"
@ -125,3 +126,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -1,6 +1,7 @@
dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'eclipse'
archivesBaseName = "$rootProject.archivesBaseName-$project.archivesBaseName"
@ -14,3 +15,8 @@ sourceSets.test.resources.srcDirs 'src/test/java'
dependencies {
compile project(':elasticsearch')
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -1,4 +1,5 @@
apply plugin: 'java'
apply plugin: 'eclipse'
archivesBaseName = "$rootProject.archivesBaseName-$project.archivesBaseName"
@ -13,3 +14,7 @@ dependencies {
compile('org.testng:testng:5.10:jdk15') { transitive = false }
compile('log4j:log4j:1.2.15') { transitive = false }
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -2,6 +2,7 @@ dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "elasticsearch-analysis-icu"
@ -127,3 +128,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -2,6 +2,7 @@ dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "elasticsearch-cloud-aws"
@ -133,3 +134,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -0,0 +1,96 @@
package org.elasticsearch.cloud.aws.network;
import java.io.IOException;
import java.net.InetAddress;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
import org.elasticsearch.common.network.NetworkService.CustomNameResolver;
/**
* Resolves certain ec2 related 'meta' hostnames into an actual hostname
* obtained from ec2 meta-data.
* <p />
* Valid config values for {@link Ec2HostnameType}s are -
* <ul>
* <li>_ec2 - maps to privateIpv4</li>
* <li>_ec2:privateIp_ - maps to privateIpv4</li>
* <li>_ec2:privateIpv4_</li>
* <li>_ec2:privateDns_</li>
* <li>_ec2:publicIp_ - maps to publicIpv4</li>
* <li>_ec2:publicIpv4_</li>
* <li>_ec2:publicDns_</li>
* </ul>
* @author Paul_Loy (keteracel)
*/
public class Ec2NameResolver implements CustomNameResolver {
// enum that can be added to over time with more meta-data types (such as ipv6 when this is available)
private static enum Ec2HostnameType {
PRIVATE_IPv4("_ec2:privateIpv4_", "local-ipv4"),
PRIVATE_DNS ("_ec2:privateDns_", "local-hostname"),
PUBLIC_IPv4 ("_ec2:publicIpv4_", "public-ipv4"),
PUBLIC_DNS ("_ec2:publicDns_", "public-hostname"),
PUBLIC_IP ("_ec2:publicIp_", PUBLIC_IPv4.ec2Name),
PRIVATE_IP ("_ec2:privateIp_", PRIVATE_IPv4.ec2Name),
DEFAULT ("_ec2", PRIVATE_IPv4.ec2Name);
final String configName;
final String ec2Name;
private Ec2HostnameType(String configName, String ec2Name) {
this.configName = configName;
this.ec2Name = ec2Name;
}
}
private static final String EC2_METADATA_URL = "http://169.254.169.254/latest/meta-data/";
private final Ec2HostnameType type;
/**
* Construct a {@link CustomNameResolver} with the given {@link Ec2HostnameType}
* address type.
*
* @param addressType the type of ec2 host to bind to.
*/
public Ec2NameResolver(Ec2HostnameType addressType) {
this.type = addressType;
}
/**
* @return the appropriate host resolved from ec2 meta-data.
* @throws IOException if ec2 meta-data cannot be obtained.
*
* @see CustomNameResolver#resolve()
*/
@Override
public InetAddress resolve() throws IOException {
String ec2Url = EC2_METADATA_URL + this.type.ec2Name;
GetMethod ec2MetadataRequest = new GetMethod(ec2Url);
int status = new HttpClient().executeMethod(ec2MetadataRequest);
if (status != 200) {
throw new HttpException(MessageFormat.format("unable to retrieve ec2 metadata from {0}. Response: {1} {2}", ec2Url, status, HttpStatus.getStatusText(status)));
}
String metadataResult = ec2MetadataRequest.getResponseBodyAsString();
return InetAddress.getByName(metadataResult);
}
public static Map<String, CustomNameResolver> resolvers() {
Map<String, CustomNameResolver> resolvers = new HashMap<String, CustomNameResolver>();
for (Ec2HostnameType type : Ec2HostnameType.values()) {
resolvers.put(type.configName, new Ec2NameResolver(type));
}
return resolvers;
}
}

View File

@ -2,6 +2,7 @@ dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "elasticsearch-hadoop"
@ -131,3 +132,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -2,6 +2,7 @@ dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "elasticsearch-lang-javascript"
@ -131,3 +132,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -2,6 +2,7 @@ dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "elasticsearch-lang-python"
@ -131,3 +132,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -2,6 +2,7 @@ dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "elasticsearch-mapper-attachments"
@ -125,3 +126,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -2,6 +2,7 @@ dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "elasticsearch-river-couchdb"
@ -122,3 +123,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -2,6 +2,7 @@ dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "elasticsearch-river-rabbitmq"
@ -127,3 +128,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -2,6 +2,7 @@ dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "elasticsearch-river-twitter"
@ -125,3 +126,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -2,6 +2,7 @@ dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "elasticsearch-river-wikipedia"
@ -122,3 +123,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -2,6 +2,7 @@ dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "elasticsearch-transport-memcached"
@ -130,3 +131,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}

View File

@ -2,6 +2,7 @@ dependsOn(':elasticsearch')
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
archivesBaseName = "elasticsearch-transport-thrift"
@ -133,3 +134,7 @@ uploadArchives {
}
}
}
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}