This commit is contained in:
Tony Tam 2015-05-20 22:12:37 -07:00
commit e58f8db9aa
5 changed files with 84 additions and 6 deletions

View File

@ -13,6 +13,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
protected String artifactVersion = "1.0.0";
protected String projectFolder = "src/main";
protected String sourceFolder = projectFolder + "/java";
protected Boolean useAndroidMavenGradlePlugin = true;
public CodegenType getTag() {
return CodegenType.CLIENT;
@ -52,6 +53,9 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
additionalProperties.put("useAndroidMavenGradlePlugin", useAndroidMavenGradlePlugin);
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle"));
supportingFiles.add(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml"));
supportingFiles.add(new SupportingFile("apiInvoker.mustache",

View File

@ -1,9 +1,17 @@
{{#useAndroidMavenGradlePlugin}}
group = '{{groupId}}'
project.version = '{{artifactVersion}}'
{{/useAndroidMavenGradlePlugin}}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
{{#useAndroidMavenGradlePlugin}}
classpath 'com.github.dcendents:android-maven-plugin:1.2'
{{/useAndroidMavenGradlePlugin}}
}
}
@ -13,7 +21,11 @@ allprojects {
}
}
apply plugin: 'com.android.library'
{{#useAndroidMavenGradlePlugin}}
apply plugin: 'com.github.dcendents.android-maven'
{{/useAndroidMavenGradlePlugin}}
android {
compileSdkVersion 22
@ -22,6 +34,17 @@ android {
minSdkVersion 14
targetSdkVersion 22
}
// Rename the aar correctly
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
@ -37,7 +60,12 @@ dependencies {
compile "com.google.code.gson:gson:$gson_version"
compile "org.apache.httpcomponents:httpcore:$httpclient_version"
compile "org.apache.httpcomponents:httpclient:$httpclient_version"
compile "org.apache.httpcomponents:httpmime:$httpclient_version"
compile ("org.apache.httpcomponents:httpcore:$httpcore_version") {
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
}
compile ("org.apache.httpcomponents:httpmime:$httpmime_version") {
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
}
testCompile "junit:junit:$junit_version"
}
@ -48,7 +76,18 @@ afterEvaluate {
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}.jar"
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
artifacts.add('archives', task);
}
}
}
{{#useAndroidMavenGradlePlugin}}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts {
archives sourcesJar
}
{{/useAndroidMavenGradlePlugin}}

View File

@ -0,0 +1 @@
rootProject.name = "{{artifactId}}"

View File

@ -1,9 +1,15 @@
group = 'io.swagger'
project.version = '1.0.0'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
}
}
@ -13,7 +19,9 @@ allprojects {
}
}
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
android {
compileSdkVersion 22
@ -22,6 +30,17 @@ android {
minSdkVersion 14
targetSdkVersion 22
}
// Rename the aar correctly
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
@ -37,7 +56,12 @@ dependencies {
compile "com.google.code.gson:gson:$gson_version"
compile "org.apache.httpcomponents:httpcore:$httpclient_version"
compile "org.apache.httpcomponents:httpclient:$httpclient_version"
compile "org.apache.httpcomponents:httpmime:$httpclient_version"
compile ("org.apache.httpcomponents:httpcore:$httpcore_version") {
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
}
compile ("org.apache.httpcomponents:httpmime:$httpmime_version") {
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
}
testCompile "junit:junit:$junit_version"
}
@ -48,7 +72,16 @@ afterEvaluate {
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}.jar"
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
artifacts.add('archives', task);
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts {
archives sourcesJar
}

View File

@ -0,0 +1 @@
rootProject.name = "swagger-android-client"