Skip to content

Commit 5b2dc62

Browse files
committed
Change templates and test code so that the sample is 1.7 compatible
Alas.
1 parent ef4306e commit 5b2dc62

File tree

9 files changed

+302
-141
lines changed

9 files changed

+302
-141
lines changed

modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ if(hasProperty('target') && target == 'android') {
7171
apply plugin: 'java'
7272
apply plugin: 'maven'
7373
74-
sourceCompatibility = JavaVersion.VERSION_1_8
75-
targetCompatibility = JavaVersion.VERSION_1_8
74+
sourceCompatibility = JavaVersion.VERSION_1_7
75+
targetCompatibility = JavaVersion.VERSION_1_7
7676
7777
install {
7878
repositories.mavenInstaller {

modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
<artifactId>maven-compiler-plugin</artifactId>
101101
<version>2.3.2</version>
102102
<configuration>
103-
<source>1.8</source>
104-
<target>1.8</target>
103+
<source>1.7</source>
104+
<target>1.7</target>
105105
</configuration>
106106
</plugin>
107107
</plugins>

samples/client/petstore/java/retrofit2rx/build.gradle

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,76 @@ repositories {
1515
jcenter()
1616
}
1717

18-
allprojects {
19-
apply plugin: 'java'
20-
apply plugin: 'maven'
2118

22-
sourceCompatibility = 1.8
23-
targetCompatibility = 1.8
24-
}
19+
if(hasProperty('target') && target == 'android') {
20+
21+
apply plugin: 'com.android.library'
22+
apply plugin: 'com.github.dcendents.android-maven'
23+
24+
android {
25+
compileSdkVersion 22
26+
buildToolsVersion '22.0.0'
27+
defaultConfig {
28+
minSdkVersion 14
29+
targetSdkVersion 22
30+
}
31+
compileOptions {
32+
sourceCompatibility JavaVersion.VERSION_1_7
33+
targetCompatibility JavaVersion.VERSION_1_7
34+
}
2535

26-
install {
27-
repositories.mavenInstaller {
28-
pom.artifactId = 'swagger-petstore-retrofit2'
36+
// Rename the aar correctly
37+
libraryVariants.all { variant ->
38+
variant.outputs.each { output ->
39+
def outputFile = output.outputFile
40+
if (outputFile != null && outputFile.name.endsWith('.aar')) {
41+
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
42+
output.outputFile = new File(outputFile.parent, fileName)
43+
}
44+
}
45+
}
2946
}
30-
}
3147

32-
task execute(type:JavaExec) {
33-
main = System.getProperty('mainClass')
34-
classpath = sourceSets.main.runtimeClasspath
35-
}
48+
afterEvaluate {
49+
android.libraryVariants.all { variant ->
50+
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
51+
task.description = "Create jar artifact for ${variant.name}"
52+
task.dependsOn variant.javaCompile
53+
task.from variant.javaCompile.destinationDir
54+
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
55+
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
56+
artifacts.add('archives', task);
57+
}
58+
}
59+
60+
task sourcesJar(type: Jar) {
61+
from android.sourceSets.main.java.srcDirs
62+
classifier = 'sources'
63+
}
64+
65+
artifacts {
66+
archives sourcesJar
67+
}
68+
69+
} else {
70+
71+
apply plugin: 'java'
72+
apply plugin: 'maven'
3673

74+
sourceCompatibility = JavaVersion.VERSION_1_7
75+
targetCompatibility = JavaVersion.VERSION_1_7
76+
77+
install {
78+
repositories.mavenInstaller {
79+
pom.artifactId = 'swagger-petstore-retrofit2'
80+
}
81+
}
82+
83+
task execute(type:JavaExec) {
84+
main = System.getProperty('mainClass')
85+
classpath = sourceSets.main.runtimeClasspath
86+
}
87+
}
3788

3889
ext {
3990
okhttp_version = "2.5.0"
@@ -43,6 +94,7 @@ ext {
4394
swagger_annotations_version = "1.5.0"
4495
junit_version = "4.12"
4596
rx_java_version = "1.0.15"
97+
4698
}
4799

48100
dependencies {

samples/client/petstore/java/retrofit2rx/pom.xml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
<artifactId>maven-compiler-plugin</artifactId>
101101
<version>2.3.2</version>
102102
<configuration>
103-
<source>1.8</source>
104-
<target>1.8</target>
103+
<source>1.7</source>
104+
<target>1.7</target>
105105
</configuration>
106106
</plugin>
107107
</plugins>
@@ -137,16 +137,18 @@
137137
<artifactId>okhttp</artifactId>
138138
<version>${okhttp-version}</version>
139139
</dependency>
140-
<dependency>
141-
<groupId>io.reactivex</groupId>
142-
<artifactId>rxjava</artifactId>
143-
<version>${rxjava-version}</version>
144-
</dependency>
145-
<dependency>
146-
<groupId>com.squareup.retrofit</groupId>
147-
<artifactId>adapter-rxjava</artifactId>
148-
<version>${retrofit-version}</version>
149-
</dependency>
140+
141+
<dependency>
142+
<groupId>io.reactivex</groupId>
143+
<artifactId>rxjava</artifactId>
144+
<version>${rxjava-version}</version>
145+
</dependency>
146+
<dependency>
147+
<groupId>com.squareup.retrofit</groupId>
148+
<artifactId>adapter-rxjava</artifactId>
149+
<version>${retrofit-version}</version>
150+
</dependency>
151+
150152

151153
<!-- test dependencies -->
152154
<dependency>

samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.swagger.client;
22

3-
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-21T16:52:39.577+01:00")
3+
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-22T16:44:03.093+01:00")
44
public class StringUtil {
55
/**
66
* Check if the given array contains the given value (with case-insensitive comparison).

0 commit comments

Comments
 (0)