You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ji...@apache.org on 2022/05/19 13:33:40 UTC

[openwhisk] branch master updated: Use a template for swagger code generating (#5238)

This is an automated email from the ASF dual-hosted git repository.

jiangpengcheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new d88a7d2be Use a template for swagger code generating (#5238)
d88a7d2be is described below

commit d88a7d2be8399bea7e55910ed225777d90d8fb9f
Author: jiangpch <ji...@navercorp.com>
AuthorDate: Thu May 19 21:33:33 2022 +0800

    Use a template for swagger code generating (#5238)
---
 build.gradle                                       |   1 -
 tests/build.gradle                                 |   1 +
 .../test/resources/templates/build.gradle.mustache | 103 +++++++++++++++++++++
 3 files changed, 104 insertions(+), 1 deletion(-)

diff --git a/build.gradle b/build.gradle
index f904e7820..522862591 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,7 +17,6 @@
 
 buildscript {
     repositories {
-        google()
         jcenter()
     }
     dependencies {
diff --git a/tests/build.gradle b/tests/build.gradle
index 9502cf16b..bb07b3968 100644
--- a/tests/build.gradle
+++ b/tests/build.gradle
@@ -400,6 +400,7 @@ swaggerSources {
         code {
             language = 'java'
             configFile = file('src/test/resources/swagger-config.json')
+            templateDir = file('src/test/resources/templates')
             dependsOn validation
         }
     }
diff --git a/tests/src/test/resources/templates/build.gradle.mustache b/tests/src/test/resources/templates/build.gradle.mustache
new file mode 100644
index 000000000..99a5a6396
--- /dev/null
+++ b/tests/src/test/resources/templates/build.gradle.mustache
@@ -0,0 +1,103 @@
+apply plugin: 'idea'
+apply plugin: 'eclipse'
+
+group = 'io.swagger'
+version = '1.0.0'
+
+buildscript {
+    repositories {
+        mavenCentral()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:2.3.+'
+        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
+    }
+}
+
+repositories {
+    mavenCentral()
+}
+
+
+if(hasProperty('target') && target == 'android') {
+
+    apply plugin: 'com.android.library'
+    apply plugin: 'com.github.dcendents.android-maven'
+
+    android {
+        compileSdkVersion 25
+        buildToolsVersion '25.0.2'
+        defaultConfig {
+            minSdkVersion 14
+            targetSdkVersion 25
+        }
+        compileOptions {
+            sourceCompatibility JavaVersion.VERSION_1_8
+            targetCompatibility JavaVersion.VERSION_1_8
+        }
+
+        // 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)
+                }
+            }
+        }
+
+        dependencies {
+            provided 'javax.annotation:jsr250-api:1.0'
+        }
+    }
+
+    afterEvaluate {
+        android.libraryVariants.all { variant ->
+            def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
+            task.description = "Create jar artifact for ${variant.name}"
+            task.dependsOn variant.javaCompile
+            task.from variant.javaCompile.destinationDir
+            task.destinationDir = project.file("${project.buildDir}/outputs/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
+    }
+
+} else {
+
+    apply plugin: 'java'
+    apply plugin: 'maven'
+
+    sourceCompatibility = JavaVersion.VERSION_1_8
+    targetCompatibility = JavaVersion.VERSION_1_8
+
+    install {
+        repositories.mavenInstaller {
+            pom.artifactId = 'swagger-java-client'
+        }
+    }
+
+    task execute(type:JavaExec) {
+       main = System.getProperty('mainClass')
+       classpath = sourceSets.main.runtimeClasspath
+    }
+}
+
+dependencies {
+    compile 'io.swagger:swagger-annotations:1.5.17'
+    compile 'com.squareup.okhttp:okhttp:2.7.5'
+    compile 'com.squareup.okhttp:logging-interceptor:2.7.5'
+    compile 'com.google.code.gson:gson:2.8.1'
+    compile 'io.gsonfire:gson-fire:1.8.0'
+    testCompile 'junit:junit:4.12'
+}