Skip to content

Commit

Permalink
Merge pull request #1569 from lnash94/client-bal-task
Browse files Browse the repository at this point in the history
[bal-build-task]Integrate OpenAPI Client generation to Ballerina package build
  • Loading branch information
lnash94 authored Jan 10, 2024
2 parents df28350 + 65cded7 commit 0220f30
Show file tree
Hide file tree
Showing 60 changed files with 812 additions and 184 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ group=io.ballerina
version=1.9.0-SNAPSHOT

#dependency
ballerinaLangVersion=2201.8.0
ballerinaLangVersion=2201.9.0-20231120-094700-aa87313f
testngVersion=7.6.1
slf4jVersion=1.7.30
org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8
Expand Down
14 changes: 7 additions & 7 deletions module-ballerina-openapi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
implementation project(':openapi-validator')
implementation project(':openapi-core')
implementation project(':openapi-cli')
// implementation project(':openapi-client-idl-plugin')
implementation project(':openapi-bal-task-plugin')
implementation project(':openapi-ls-extension')
implementation project(':openapi-extension')
}
Expand Down Expand Up @@ -59,8 +59,7 @@ def targetNativeJar = file("""$project.rootDir/${packageName}-validator/build/li
def targetOpenApiCommonJar = file("$project.rootDir/openapi-bal-service/build/libs/openapi-bal-service-${project.version}.jar")
def targetOpenApiCoreJar = file("$project.rootDir/openapi-core/build/libs/openapi-core-${project.version}.jar")
def targetOpenApiCliJar = file("$project.rootDir/openapi-cli/build/libs/openapi-cli-${project.version}.jar")
//def targetOpenApiClientIDLJar = file("$project.rootDir/openapi-client-idl-plugin" +
// "/build/libs/openapi-client-idl-plugin-${project.version}.jar")
def targetOpenApiBalTaskJar = file("$project.rootDir/openapi-bal-task-plugin/build/libs/openapi-bal-task-plugin-${project.version}.jar")
def targetOpenApiBuiltInExtensionJar = file("$project.rootDir/openapi-extension/build/libs/openapi-extension-${project.version}.jar")
def targetOpenApiBuildExtensionJar = file("$project.rootDir/openapi-build-extension/build/libs/openapi-build-extension-${project.version}.jar")
def targetOpenApiLSJar = file("$project.rootDir/openapi-ls-extension/build/libs/openapi-ls-extension-${project.version}.jar")
Expand Down Expand Up @@ -237,10 +236,10 @@ task ballerinaBuild {
into file("$artifactLibParent/libs")
}

// copy {
// from targetOpenApiClientIDLJar
// into file("$artifactLibParent/libs")
// }
copy {
from targetOpenApiBalTaskJar
into file("$artifactLibParent/libs")
}

copy {
from targetOpenApiLSJar
Expand Down Expand Up @@ -337,6 +336,7 @@ ballerinaBuild.dependsOn ":${packageName}-ls-extension:build"
ballerinaBuild.dependsOn ":${packageName}-validator:build"
ballerinaBuild.dependsOn ":${packageName}-extension:build"
ballerinaBuild.dependsOn ":${packageName}-build-extension:build"
ballerinaBuild.dependsOn ":${packageName}-bal-task-plugin:build"
ballerinaBuild.dependsOn updateCompilerTomlFile
ballerinaBuild.dependsOn initializeVariables
ballerinaBuild.dependsOn generatePomFileForMavenJavaPublication
Expand Down
50 changes: 50 additions & 0 deletions openapi-bal-task-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/


apply from: "$rootDir/gradle/javaProject.gradle"
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "java-library"

description = "Ballerina - OpenAPI Tooling - OpenAPI to Ballerina"

dependencies {
implementation project(':openapi-core')
implementation("io.swagger.parser.v3:swagger-parser:${swaggerParserVersion}") {
exclude group: "io.swagger", module: "swagger-compat-spec-parser"
exclude group: "org.slf4j", module: "slf4j-ext"
exclude group: "javax.validation", module: "validation-api"
}
implementation "org.ballerinalang:ballerina-lang"
implementation "org.ballerinalang:ballerina-parser"
implementation "org.ballerinalang:formatter-core"
implementation "org.ballerinalang:ballerina-cli"
implementation "org.ballerinalang:ballerina-tools-api"
implementation "org.ballerinalang:toml-parser:${ballerinaLangVersion}"
implementation "com.google.code.findbugs:jsr305"
testImplementation "org.testng:testng"
}

compileJava {
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
]
classpath = files()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.ballerina.openapi.bal.tool;

import io.ballerina.tools.diagnostics.DiagnosticSeverity;

/**
* This class includes constants for ballerina package build generator.
*
* @since 1.9.0
*/
public class Constants {
public static final String TAGS = "tags";
public static final String OPERATIONS = "operations";
public static final String NULLABLE = "nullable";
public static final String CLIENT_METHODS = "clientMethods";
public static final String LICENSE = "license";
public static final String TRUE = "true";
public static final String MODE = "mode";
public static final String CLIENT = "client";

/**
* Enum class for containing diagnostic messages.
*/
public enum DiagnosticMessages {
LICENSE_PATH_BLANK("OAS_CLIENT_01", "given license file path is an empty string.",
DiagnosticSeverity.WARNING),
ERROR_WHILE_READING_LICENSE_FILE("OAS_CLIENT_02", "unexpected error occurred while reading the license",
DiagnosticSeverity.ERROR),
ERROR_WHILE_GENERATING_CLIENT("OAS_CLIENT_03", "unexpected error occurred while generating the client",
DiagnosticSeverity.ERROR),
PARSER_ERROR("OAS_CLIENT_04", "", DiagnosticSeverity.ERROR),
UNEXPECTED_EXCEPTIONS("OAS_CLIENT_05", "unexpected error occurred while reading the contract",
DiagnosticSeverity.ERROR),
EMPTY_CONTRACT_PATH("OAS_CLIENT_06", "given OpenAPI contract file path is an empty string.",
DiagnosticSeverity.WARNING),
WARNING_FOR_OTHER_GENERATION("OAS_CLIENT_07", "`%s` mode does not support for bal build code generation.",
DiagnosticSeverity.WARNING),
WARNING_FOR_UNSUPPORTED_CONTRACT("OAS_CLIENT_08", "unsupported contract type. please use .yml, " +
".yaml, or .json files for code generation.",
DiagnosticSeverity.WARNING);

private final String code;
private final String description;
private final DiagnosticSeverity severity;

DiagnosticMessages(String code, String description, DiagnosticSeverity severity) {
this.code = code;
this.description = description;
this.severity = severity;
}

public String getCode() {
return code;
}

public String getDescription() {
return description;
}

public DiagnosticSeverity getSeverity() {
return severity;
}
}
}
Loading

0 comments on commit 0220f30

Please sign in to comment.