Skip to content

Commit

Permalink
aws-java-sdk 1.11.28 (#21)
Browse files Browse the repository at this point in the history
Overhauls mixin generation to use an isolated classpath to get rid of a conflict with gradle's system classpath
Updates to gradle 3.0
Moves awsMixin gradle script into buildSrc
  • Loading branch information
cfieber authored and brharrington committed Aug 23, 2016
1 parent 6bd26eb commit 43f83ac
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 52 deletions.
19 changes: 4 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

buildscript {
repositories {
mavenLocal()
jcenter()
}
}

plugins {
id 'nebula.netflixoss' version '3.2.3'
id 'nebula.netflixoss' version '3.4.0'
}

// Establish version and status
Expand Down Expand Up @@ -38,26 +37,16 @@ subprojects {
}

dependencies {
compile 'com.amazonaws:aws-java-sdk:1.11.18'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.5'
compile 'com.amazonaws:aws-java-sdk:1.11.28'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.6'
testCompile 'junit:junit:4.10'
testCompile 'com.google.guava:guava:18.0'
testCompile 'io.github.benas:jpopulator:1.0.1'
}

task copyDepsToBuild << {
['compile', 'runtime', 'testCompile', 'testRuntime'].each { conf ->
delete "${buildDir}/dependencies/${conf}"
copy {
from configurations[conf]
into "${buildDir}/dependencies/${conf}"
}
}
}
}

project(':awsobjectmapper') {
apply from: file('../gradle/awsMixin.gradle')
apply plugin: AwsMixinGenerator

compileJava.dependsOn generateAwsMixins

Expand Down
11 changes: 11 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repositories {
jcenter()
}

apply plugin: 'groovy'

dependencies {
compile gradleApi()
compile localGroovy()
compile 'com.google.guava:guava:18.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,16 @@
* limitations under the License.
*/

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.amazonaws:aws-java-sdk:1.11.18'
classpath 'com.google.guava:guava:18.0'
}
}

apply plugin: AwsMixinGenerator

import com.amazonaws.services.autoscaling.AmazonAutoScaling
import com.amazonaws.services.cloudwatch.AmazonCloudWatch
import com.amazonaws.services.ec2.AmazonEC2
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancing
import com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduce
import com.amazonaws.services.route53.AmazonRoute53

import com.google.common.reflect.ClassPath
import java.io.File
import java.io.Writer
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task

import java.lang.reflect.Method
import java.util.HashSet
import java.util.Set
import java.util.regex.Matcher
import java.util.regex.Pattern


class AwsMixinGenerator implements Plugin<Project> {

private final Set<String> prohibited = new HashSet<String>([
Expand Down Expand Up @@ -130,14 +112,6 @@ class AwsMixinGenerator implements Plugin<Project> {
}
}

// Gradle or a core plugin has a dependency on aws-sdk 1.9.19 causing
// a problem for kms KeyMetadata. There isn't a clear way to override
// that dependency, so for now we manually patch the problem it causes.
if ("com.amazonaws.services.kms.model.KeyMetadata".equals(c.name)) {
anno.add("@JsonIgnore void setKeyState(com.amazonaws.services.kms.model.KeyState v);")
anno.add("@JsonProperty void setKeyState(String v);")
}

return anno
}

Expand Down Expand Up @@ -209,7 +183,6 @@ class AwsMixinGenerator implements Plugin<Project> {
void apply(Project project) {
Task task = project.task('generateAwsMixins')

task.getInputs().file("${project.getRootDir()}/gradle/awsMixin.gradle")
task.getOutputs().dir("${project.buildDir}/generated/com/netflix/awsobjectmapper")

task.doLast({
Expand All @@ -220,9 +193,11 @@ class AwsMixinGenerator implements Plugin<Project> {

List<String> overrides = new ArrayList<String>()

URL[] compileClasspath = project.configurations.getByName('compile').files.collect { it.toURI().toURL() }
ClassLoader cl = new URLClassLoader(compileClasspath)

new File(outputDir, "AmazonObjectMapper.java").withWriter { out ->
out.writeLine(mapperHeader)
ClassLoader cl = AmazonEC2.class.classLoader
String pkg = "com.amazonaws"
ClassPath.from(cl).getTopLevelClassesRecursive(pkg).each { cinfo ->
Matcher m = clientPattern.matcher(cinfo.simpleName)
Expand All @@ -232,9 +207,14 @@ class AwsMixinGenerator implements Plugin<Project> {
prefix = "V2$prefix"
else if (cinfo.name.contains("2012_03_15"))
prefix = "V2012_03_15$prefix"
println(cinfo.name)
createMixins(out, outputDir, prefix, cinfo.load())
overrides += collectOverrides(cinfo.load())
def clientClass = cinfo.load()
def jarLoc = { Class clazz ->
def path = clazz.protectionDomain?.codeSource?.location?.path ?: "unknown"
path.substring(path.lastIndexOf('/') + 1)
}
println clientClass.name + ": " + jarLoc(clientClass)
createMixins(out, outputDir, prefix, clientClass)
overrides += collectOverrides(clientClass)
}
}
out.writeLine(" }\n}\n")
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-2.13-bin.zip
distributionUrl=http\://services.gradle.org/distributions/gradle-3.0-bin.zip

0 comments on commit 43f83ac

Please sign in to comment.