-
Notifications
You must be signed in to change notification settings - Fork 1
Tempproject #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cb-shishiryadav
wants to merge
10
commits into
main
Choose a base branch
from
tempproject
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Tempproject #49
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a10a57a
recentcommit
cb-shishiryadav e5631e7
Readmecommit
cb-shishiryadav ad580ae
todayscommit
cb-shishiryadav a9d94bb
newcommit
cb-shishiryadav e3b5eae
newcommit
cb-shishiryadav 02f8389
todaycommit
cb-shishiryadav d340f06
todaycommit
cb-shishiryadav 48e7c75
initialcommit
cb-shishiryadav e6f1c26
finalcommit
cb-shishiryadav b1a1cff
finalcommit
cb-shishiryadav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,3 +128,56 @@ Tax provider capabilities for new tax providers will be validated against a cons | |
| 6. After PR is approved and merged | ||
| 7. Raise PR from release/0.0.9 to dev. Once PR is merged it will auto release the 0.0.9 version of SPI for dev code base | ||
| 8. After that raise PR from release/0.0.9 to main. Once PR is merged it will auto release the 0.0.9 version of SPI for prod codebase | ||
|
|
||
|
|
||
| ## Steps to generate a spring boot project for given spec using gradle | ||
|
|
||
| Prerequisites: | ||
| Use Java11 or higher version with gradle version greater than or equal to 7. | ||
| For gradle version less than 7 use Java8. | ||
|
|
||
| 1. Clone repository in local | ||
| ```shell | ||
| git clone [email protected]:chargebee/cb-provider-spi.git | ||
| ``` | ||
|
|
||
| 2. Navigate to the repository | ||
| ```shell | ||
| cd cb-provider-spi | ||
| ``` | ||
|
|
||
| 3. (a) Generate the Gradle project structure with default configurations: | ||
| ```shell | ||
| gradle -b meta-generator.gradle generateGradleProject | ||
| ``` | ||
|
|
||
| 3. (b) Generate the gradle project with custom configurations use below commands. (Custom params if not provided, it will pick it from generator.config file) | ||
| ```shell | ||
| gradle -b meta-generator.gradle generateGradleProject \ | ||
| -PspringBootVersion=2.7.1 \ | ||
| -PopenApiGeneratorVersion=7.0.1 \ | ||
| -PjavaVersion=11 \ | ||
| -PgroupId=com.adapter \ | ||
| -PbasePackage=com.adapter.api \ | ||
| -PoutputDir=../adapter | ||
| ``` | ||
|
|
||
| 4. After generating the Gradle project, you can navigate to the output directory and run: | ||
| ```shell | ||
| gradle openApiGenerateFullProject | ||
| ``` | ||
|
|
||
| ## Generating Spring boot project using shell script | ||
|
|
||
| 1. Perform the steps 1 and 2 as mentioned in above section. | ||
|
|
||
| 2. Execute the script file setup_spring_boot.sh using below command: | ||
| ```shell | ||
| chmod +x setup_spring_boot.sh | ||
| ``` | ||
| 3. Run the script: | ||
| ```shell | ||
| ./setup_spring_boot.sh | ||
| ``` | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| outputDir: ../adapter | ||
| springBootVersion: 2.7.0 | ||
| springDependencyManagementVersion: 1.0.11.RELEASE | ||
| openApiGeneratorVersion: 7.0.1 | ||
| javaVersion: 11 | ||
| groupId: com.adapter | ||
| basePackage: com.adapter | ||
| specs: | ||
| - openapi_location_validation.yml | ||
| - openapi_tax.yml | ||
| - openapi_trn.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| buildscript { | ||
| repositories { | ||
| mavenCentral() | ||
| } | ||
| dependencies { | ||
| classpath 'org.yaml:snakeyaml:1.30' | ||
| } | ||
| } | ||
|
|
||
| import org.yaml.snakeyaml.Yaml | ||
|
|
||
| def configFile = file('generator.config') | ||
| def config = new Yaml().load(configFile.text) | ||
|
|
||
| // Define command-line options | ||
| def cliOptions = [ | ||
| 'springBootVersion', | ||
| 'springDependencyManagementVersion', | ||
| 'openApiGeneratorVersion', | ||
| 'javaVersion', | ||
| 'groupId', | ||
| 'version', | ||
| 'basePackage', | ||
| 'outputDir' | ||
| ] | ||
|
|
||
| // Override config with command-line arguments if provided | ||
| cliOptions.each { option -> | ||
| if (project.hasProperty(option)) { | ||
| config[option] = project.property(option) | ||
| } | ||
| } | ||
|
|
||
| def outputDir = file(config.outputDir ?: '../adapter') | ||
|
|
||
| task generateGradleProject { | ||
| doLast { | ||
| // Create the output directory if it doesn't exist | ||
| outputDir.mkdirs() | ||
|
|
||
| // Create build.gradle | ||
| def buildGradleFile = new File(outputDir, 'build.gradle') | ||
| buildGradleFile.text = """ | ||
| plugins { | ||
| id 'org.springframework.boot' version '${config.springBootVersion}' | ||
| id 'io.spring.dependency-management' version '${config.springDependencyManagementVersion}' | ||
| id 'java' | ||
| id 'org.openapi.generator' version '${config.openApiGeneratorVersion}' | ||
| } | ||
|
|
||
| group = '${config.groupId}' | ||
| version = '${config.version}' | ||
| sourceCompatibility = '${config.javaVersion}' | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation 'org.springframework.boot:spring-boot-starter-web' | ||
| testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
| } | ||
|
|
||
| def specDir = '${projectDir}/../cb-provider-spi/spec/spi' | ||
| def specs = ${config.specs.inspect()} | ||
|
|
||
| specs.each { spec -> | ||
| def taskName = "generate\${spec.replace('.yml', '').capitalize()}" | ||
| tasks.register(taskName, org.openapitools.generator.gradle.plugin.tasks.GenerateTask) { | ||
| generatorName = 'spring' | ||
| inputSpec = "\$specDir/\$spec" | ||
| outputDir = "\$projectDir/src/main/java" | ||
| apiPackage = "${config.basePackage}.api.\${spec.replace('.yml', '').replace('_', '')}" | ||
| modelPackage = "${config.basePackage}.model.\${spec.replace('.yml', '').replace('_', '')}" | ||
| configOptions = [ | ||
| dateLibrary: 'java8', | ||
| interfaceOnly: 'true', | ||
| useSpringBoot3: 'true', | ||
| groupBy: 'tags' | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| tasks.named('openApiGenerate').configure { | ||
| enabled = false | ||
| } | ||
|
|
||
| tasks.register('openApiGenerateFullProject') { | ||
| dependsOn tasks.withType(org.openapitools.generator.gradle.plugin.tasks.GenerateTask) | ||
| } | ||
|
|
||
| sourceSets { | ||
| main { | ||
| java { | ||
| srcDir "src/main/java" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| compileJava.dependsOn tasks.openApiGenerateFullProject | ||
| """ | ||
|
|
||
| // Create settings.gradle | ||
| def settingsGradleFile = new File(outputDir, 'settings.gradle') | ||
| settingsGradleFile.text = """ | ||
| rootProject.name = '${config.groupId.tokenize('.').last()}' | ||
| """ | ||
|
|
||
| // Create gradle.properties | ||
| def gradlePropertiesFile = new File(outputDir, 'gradle.properties') | ||
| gradlePropertiesFile.text = """ | ||
| org.gradle.parallel=true | ||
| org.gradle.caching=true | ||
| """ | ||
|
|
||
| // Create main application class | ||
| def mainClassDir = new File(outputDir, "src/main/java/${config.basePackage.replace('.', '/')}") | ||
| mainClassDir.mkdirs() | ||
| def mainClassFile = new File(mainClassDir, "Application.java") | ||
| mainClassFile.text = """ | ||
| package ${config.basePackage}; | ||
|
|
||
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
|
||
| @SpringBootApplication | ||
| public class Application { | ||
| public static void main(String[] args) { | ||
| SpringApplication.run(Application.class, args); | ||
| } | ||
| } | ||
| """ | ||
|
|
||
| // Create src directory structure | ||
| new File(outputDir, 'src/main/resources').mkdirs() | ||
| new File(outputDir, 'src/test/java').mkdirs() | ||
| new File(outputDir, 'src/test/resources').mkdirs() | ||
|
|
||
| println "Generated Gradle project structure at ${outputDir.absolutePath}" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Function to log messages | ||
| log() { | ||
| echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | ||
| } | ||
|
|
||
| # Function to run a command and log its output | ||
| run_command() { | ||
| log "Running command: $1" | ||
| eval $1 | ||
| if [ $? -ne 0 ]; then | ||
| log "Error: Command failed" | ||
| exit 1 | ||
| fi | ||
| log "Command completed successfully" | ||
| } | ||
|
|
||
| # Step 1: Generate Gradle project | ||
| log "Step 1: Generating Gradle project" | ||
| run_command "gradle -b meta-generator.gradle generateGradleProject" | ||
|
|
||
| # Step 2: Generate OpenAPI code | ||
| log "Step 2: Generating OpenAPI code" | ||
| run_command "cd ../adapter && gradle openApiGenerateFullProject" | ||
|
|
||
| # Step 3: Run Spring Boot application | ||
| log "Step 3: Running Spring Boot application" | ||
| run_command "cd ../adapter && gradle bootRun" | ||
|
|
||
| log "Script completed successfully" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setup_adapter_spring_boot_project.sh <output_directory> <package_name>
Share with an example
sh setup_adapter_spring_boot_project.sh java8 ~/work/ com.org
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done