/** * Copyright (C) 2016 Perforce Software. All rights reserved. * * Please see README-LICENSE.txt in top-level folder of this distribution. */ apply plugin: 'application' apply plugin: 'java' sourceCompatibility = 1.8 targetCompatibility = 1.8 repositories { mavenCentral() } mainClassName = 'io.swagger.codegen.SwaggerCodegen' configurations { tools } dependencies { compile "org.antlr:stringtemplate:4.0.2" compile "io.swagger:swagger-codegen:2.1.6" tools "io.swagger:swagger-codegen-cli:2.1.6" } task copyToLib(type: Copy) { into 'build/libs' from configurations.tools } // Generate[ AsciiDoc ] -------------------------------------------------------- task generateAsciiDoc(type: JavaExec) { dependsOn(copyToLib) description 'Create asciidoc fragments from current Swagger definition' classpath = sourceSets.main.runtimeClasspath main = 'com.perforce.hws.swagger.asciidoc.GenerateAsciidoc' args file('../perforce.yaml').canonicalPath, file('../generated/ascii-doc').canonicalPath } build.dependsOn(generateAsciiDoc) // Generate[ Spark stubs ] ----------------------------------------------------- task generateSpark(type: JavaExec) { dependsOn(copyToLib) description 'Generate the java Spark stubs' classpath = fileTree(dir: 'build/libs', include: '*.jar', exclude: '*-sources.jar') main 'io.swagger.codegen.SwaggerCodegen' args 'generate', '-i', file('../perforce.yaml').canonicalPath, '-l', 'spark', '-o', file('../src/main/generated').canonicalPath } build.dependsOn(generateSpark) // Generate[ Java SDK ] -------------------------------------------------------- task generateJavaSDK(type: JavaExec) { dependsOn(copyToLib) description 'Generate the java client SDK' classpath = fileTree(dir: 'build/libs', include: '*.jar', exclude: '*-sources.jar') main 'io.swagger.codegen.SwaggerCodegen' args 'generate', '-i', file('../perforce.yaml').canonicalPath, '-l', 'java', '-o', file('../generated/java-sdk').canonicalPath, '-c', file('config/java_config.json').canonicalPath, '-t', file('templates/java').canonicalPath } build.dependsOn(generateJavaSDK) // Generate[ Ruby SDK ] -------------------------------------------------------- task generateRubySDK(type: JavaExec) { dependsOn(copyToLib) description 'Generate the Ruby client SDK' classpath = fileTree(dir: 'build/libs', include: '*.jar', exclude: '*-sources.jar') main 'io.swagger.codegen.SwaggerCodegen' args 'generate', '-i', file('../perforce.yaml').canonicalPath, '-l', 'ruby', '-o', file('../generated/ruby-sdk').canonicalPath, '-c', file('config/ruby_config.json').canonicalPath, '-t', file('templates/ruby').canonicalPath } build.dependsOn(generateRubySDK) // Generate[ PHP SDK ] --------------------------------------------------------- task generatePhpSDK(type: JavaExec) { dependsOn(copyToLib) description 'Generate the PHP client SDK' classpath = fileTree(dir: 'build/libs', include: '*.jar', exclude: '*-sources.jar') main 'io.swagger.codegen.SwaggerCodegen' args 'generate', '-i', file('../perforce.yaml').canonicalPath, '-l', 'php', '-o', file('../generated/php-sdk').canonicalPath, '-c', file('config/php_config.json').canonicalPath, '-t', file('templates/php').canonicalPath } build.dependsOn(generatePhpSDK) // Generate[ Python SDK ] ------------------------------------------------------ task generatePythonSDK(type: JavaExec) { dependsOn(copyToLib) description 'Generate the Python client SDK' classpath = fileTree(dir: 'build/libs', include: '*.jar', exclude: '*-sources.jar') main 'io.swagger.codegen.SwaggerCodegen' args 'generate', '-i', file('../perforce.yaml').canonicalPath, '-l', 'python', '-o', file('../generated/python-sdk').canonicalPath, '-c', file('config/python_config.json').canonicalPath, '-t', file('templates/python').canonicalPath } build.dependsOn(generatePythonSDK) clean { delete file('../generated').canonicalPath delete file('../src/main/generated').canonicalPath }