Skip to content

Commit

Permalink
Merge pull request #1616 from lnash94/bal-build-master
Browse files Browse the repository at this point in the history
[master] Integrate Client generation for the Bal build command
  • Loading branch information
lnash94 authored Mar 13, 2024
2 parents b49a2fd + 213192e commit 386d379
Show file tree
Hide file tree
Showing 74 changed files with 1,663 additions and 567 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ext.netLingalaZip4jVersion = project.netLingalaZip4jVersion
ext.slf4jVersion = project.slf4jVersion
ext.commonsLang3Version = project.commonsLang3Version
ext.commonsIoVersion = project.commonsIoVersion
ext.commonsCodecVersion = project.commonsCodecVersion
ext.netLingalaZip4jVersion = project.netLingalaZip4jVersion
ext.stdlibIoVersion = project.stdlibIoVersion
ext.stdlibLogVersion = project.stdlibLogVersion
Expand Down
3 changes: 2 additions & 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.9.0-20240208-103300-0823dc95
ballerinaLangVersion=2201.9.0-20240229-103900-a949e6d4
testngVersion=7.6.1
slf4jVersion=1.7.30
org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8
Expand All @@ -13,6 +13,7 @@ netLingalaZip4jVersion=2.8.0
jacocoVersion=0.8.10
swaggerParserVersion=2.1.16
puppycrawlCheckstyleVersion = 10.12.1
commonsCodecVersion=1.16.0

# Stdlib Level 01
stdlibIoVersion=1.6.0
Expand Down
2 changes: 1 addition & 1 deletion gradle/javaProject.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies {
implementation "com.fasterxml.jackson.core:jackson-databind:2.15.3"
implementation "com.github.jknack:handlebars:4.2.0"
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation "info.picocli:picocli:4.0.1"
implementation "info.picocli:picocli:4.7.5"
implementation "io.swagger.core.v3:swagger-core:2.2.9"
implementation "io.swagger.core.v3:swagger-models:2.2.9"
implementation "io.swagger.parser.v3:swagger-parser:${swaggerParserVersion}"
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 @@ -61,8 +61,7 @@ def targetNativeJar = file("""$project.rootDir/${packageName}-validator/build/li
def targetOpenApiCommonJar = file("$project.rootDir/ballerina-to-openapi/build/libs/ballerina-to-openapi-${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 @@ -239,10 +238,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 @@ -339,6 +338,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
74 changes: 74 additions & 0 deletions openapi-bal-task-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2024, 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 = "OpenAPI Tooling - OpenAPI to Ballerina"

configurations.all {
resolutionStrategy.preferProjectModules()
}

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"
implementation "commons-codec:commons-codec:${commonsCodecVersion}"
testImplementation "org.testng:testng"
}

shadowJar {
configurations = [project.configurations.runtimeClasspath]
dependencies {
include(dependency("commons-codec:commons-codec:${commonsCodecVersion}"))
include(dependency('io.swagger.parser.v3:swagger-parser'))
exclude('META-INF/*.SF')
exclude('META-INF/*.DSA')
exclude('META-INF/*.RSA')
}
// Customize the JAR file name without the '-all' suffix
archiveFileName = "openapi-bal-task-plugin-${project.version}.jar"
}

compileJava {
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
]
classpath = files()
}
}
build.dependsOn shadowJar

// Disable the default 'jar' task
tasks.named('jar').configure {
enabled = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2024, 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";
public static final String CACHE_FILE = "openapi-cache.txt";

/**
* 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.ERROR),
WARNING_FOR_OTHER_GENERATION("OAS_CLIENT_07", "`%s` mode does not support for bal build code generation.",
DiagnosticSeverity.ERROR),
WARNING_FOR_UNSUPPORTED_CONTRACT("OAS_CLIENT_08", "unsupported contract type. please use .yml, " +
".yaml, or .json files for code generation.",
DiagnosticSeverity.ERROR),
INVALID_CONTRACT_PATH("OAS_CLIENT_09", "invalid openapi contract file path.",
DiagnosticSeverity.ERROR);

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 386d379

Please sign in to comment.