Add script for sample generation and adapt gradle and pom templates

This commit is contained in:
Silvio Heuberger 2016-01-22 14:11:03 +01:00
parent 886abda926
commit 7dcc1c839e
3 changed files with 56 additions and 12 deletions

View File

@ -0,0 +1,31 @@
#!/bin/sh
SCRIPT="$0"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-retrofit2.json -o samples/client/petstore/java/retrofit2rx -DuseRxJava=true"
java $JAVA_OPTS -jar $executable $ags

View File

@ -20,7 +20,7 @@ if(hasProperty('target') && target == 'android') {
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.github.dcendents.android-maven'
android { android {
compileSdkVersion 22 compileSdkVersion 22
buildToolsVersion '22.0.0' buildToolsVersion '22.0.0'
@ -32,7 +32,7 @@ if(hasProperty('target') && target == 'android') {
sourceCompatibility JavaVersion.VERSION_1_7 sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7
} }
// Rename the aar correctly // Rename the aar correctly
libraryVariants.all { variant -> libraryVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
@ -44,7 +44,7 @@ if(hasProperty('target') && target == 'android') {
} }
} }
} }
afterEvaluate { afterEvaluate {
android.libraryVariants.all { variant -> android.libraryVariants.all { variant ->
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
@ -56,12 +56,12 @@ if(hasProperty('target') && target == 'android') {
artifacts.add('archives', task); artifacts.add('archives', task);
} }
} }
task sourcesJar(type: Jar) { task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs from android.sourceSets.main.java.srcDirs
classifier = 'sources' classifier = 'sources'
} }
artifacts { artifacts {
archives sourcesJar archives sourcesJar
} }
@ -70,16 +70,16 @@ if(hasProperty('target') && target == 'android') {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven'
sourceCompatibility = JavaVersion.VERSION_1_7 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_8
install { install {
repositories.mavenInstaller { repositories.mavenInstaller {
pom.artifactId = '{{artifactId}}' pom.artifactId = '{{artifactId}}'
} }
} }
task execute(type:JavaExec) { task execute(type:JavaExec) {
main = System.getProperty('mainClass') main = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath classpath = sourceSets.main.runtimeClasspath

View File

@ -100,8 +100,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version> <version>2.3.2</version>
<configuration> <configuration>
<source>1.6</source> <source>1.8</source>
<target>1.6</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
@ -137,6 +137,18 @@
<artifactId>okhttp</artifactId> <artifactId>okhttp</artifactId>
<version>${okhttp-version}</version> <version>${okhttp-version}</version>
</dependency> </dependency>
{{#useRxJava}}
<dependency>
<groupId>io.reactivex</groupId>
<artifactId>rxjava</artifactId>
<version>${rxjava-version}</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit</groupId>
<artifactId>adapter-rxjava</artifactId>
<version>${retrofit-version}</version>
</dependency>
{{/useRxJava}}
<!-- test dependencies --> <!-- test dependencies -->
<dependency> <dependency>
@ -149,6 +161,7 @@
<properties> <properties>
<swagger-annotations-version>1.5.0</swagger-annotations-version> <swagger-annotations-version>1.5.0</swagger-annotations-version>
<retrofit-version>2.0.0-beta2</retrofit-version> <retrofit-version>2.0.0-beta2</retrofit-version>
{{#useRxJava}}<rxjava-version>1.0.15</rxjava-version>{{/useRxJava}}
<okhttp-version>2.5.0</okhttp-version> <okhttp-version>2.5.0</okhttp-version>
<gson-version>2.4</gson-version> <gson-version>2.4</gson-version>
<oltu-version>1.0.0</oltu-version> <oltu-version>1.0.0</oltu-version>