-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
.idea/**/artifacts | ||
|
||
# Generated files | ||
.idea/**/contentModel.xml | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# CMake | ||
cmake-build-*/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
build/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
|
||
# Android studio 3.1+ serialized cache file | ||
.idea/caches/build_file_checksums.ser | ||
/store-api/application.pid | ||
|
||
.gradle/ | ||
logs | ||
cache | ||
gradle-local.properties | ||
local.env | ||
.idea/codeStyles |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Tag Project | ||
|
||
## Run script | ||
|
||
### Tag new project version | ||
|
||
Note that this is a multi-module repository that means that the tag will be the same for all the modules. | ||
It uses gradle, so we have implemented a gradle task to tag your version. | ||
|
||
You need to be in the root folder of the project and run the following command: | ||
``` | ||
./gradlew version --tag=[version] | ||
``` | ||
|
||
### Push changes | ||
|
||
Don't forget to push commit and tag: | ||
|
||
```shell | ||
git push | ||
git push --tags | ||
``` | ||
|
||
### Examples | ||
|
||
Assuming your current version is `1.2.3` | ||
|
||
|command | result | | ||
|---|---| | ||
|`./gradlew version --tag=1.2.3` |`v1.2.3` | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changelog | ||
|
||
## Unreleased | ||
|
||
* [TASK-ID](https://makeitapp.atlassian.net/browse/task-id): description... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Ktor Template walkthrough | ||
|
||
[![Build Status][github-actions-svg]][github-actions] | ||
|
||
This walkthrough will explain you how to correctly create a microservice from a Ktor Template using our DevOps Console. | ||
|
||
## Create a microservice | ||
|
||
In order to do so, access to [Mia-Platform DevOps Console](https://console.cloud.mia-platform.eu/login), create a new project and go to the **Design** area. | ||
From the Design area of your project select _Microservices_ and then create a new one, you have now reached [Mia-Platform Marketplace](https://docs.mia-platform.eu/development_suite/api-console/api-design/marketplace/)! | ||
In the marketplace you will see a set of Examples and Templates that can be used to set-up microservices with a predefined and tested function. | ||
|
||
For this walkthrough select the following example: **Ktor Template**. | ||
Give your microservice the name you prefer, in this walkthrough we'll refer to it with the following name: **my-ktor-service-name**. Then, fill the other required fields and confirm that you want to create a microservice. | ||
A more detailed description on how to create a Microservice can be found in [Microservice from template - Get started](https://docs.mia-platform.eu/development_suite/api-console/api-design/custom_microservice_get_started/#2-service-creation) section of Mia-Platform documentation. | ||
|
||
## Remove status probes | ||
|
||
In order to run this example correctly, it is necessary to remove the default probes of your microservice. To do so, go to the table *Microservice configuration* of the newly created microservice *my-ktor-service-name* in the section *Probes*. Once here, delete both the default readiness and liveness paths. | ||
|
||
## Expose an endpoint to your microservice | ||
|
||
In order to access to your new microservice it is necessary to create an endpoint that targets it. | ||
In particular, in this walkthrough you will create an endpoint to your microservice *my-ktor-service-name*. To do so, from the Design area of your project select _Endpoints_ and then create a new endpoint. | ||
Now you need to choose a path for your endpoint and to connect this endpoint to your microservice. Give to your endpoint the following path: **/ktor-template**. Then, specify that you want to connect your endpoint to a microservice and, finally, select *my-ktor-service-name*. | ||
Step 3 of [Microservice from template - Get started](https://docs.mia-platform.eu/development_suite/api-console/api-design/custom_microservice_get_started/#3-creating-the-endpoint) section of Mia-Platform documentation will explain in detail how to create an endpoint from the DevOps Console. | ||
|
||
## Save your changes | ||
|
||
After having created an endpoint to your microservice you should save the changes that you have done to your project in the DevOps console. | ||
Remember to choose a meaningful title for your commit (e.g "created service my_ktor_service_name"). After some seconds you will be prompted with a popup message which confirms that you have successfully saved all your changes. | ||
Step 4 of [Microservice from template - Get started](https://docs.mia-platform.eu/development_suite/api-console/api-design/custom_microservice_get_started/#4-save-the-project) section of Mia-Platform documentation will explain how to correctly save the changes you have made on your project in the DevOps console. | ||
|
||
## Deploy | ||
|
||
Once all the changes that you have made are saved, you should deploy your project through the DevOps Console. Go to the **Deploy** area of the DevOps Console. | ||
Once here select the environment and the branch you have worked on and confirm your choices clicking on the *deploy* button. When the deploy process is finished you will receveive a pop-up message that will inform you. | ||
Step 5 of [Microservice from template - Get started](https://docs.mia-platform.eu/development_suite/api-console/api-design/custom_microservice_get_started/#5-deploy-the-project-through-the-api-console) section of Mia-Platform documentation will explain in detail how to correctly deploy your project. | ||
|
||
## Try it | ||
|
||
Now, if you launch the following command on your terminal (remember to replace `<YOUR_PROJECT_HOST>` with the real host of your project): | ||
|
||
```shell | ||
curl <YOUR_PROJECT_HOST>/hello | ||
``` | ||
|
||
you should see the following message: | ||
|
||
```json | ||
{"helloWorld":"Hello world!"} | ||
``` | ||
|
||
Congratulations! You have successfully learnt how to use our Ktor multi module _Hello World_ Example on the DevOps Console! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
plugins { | ||
id 'java' | ||
id 'org.jetbrains.kotlin.jvm' version '1.3.72' | ||
} | ||
|
||
allprojects { | ||
|
||
group 'eu.miaplatform' | ||
version '1.0.0' | ||
|
||
repositories { | ||
mavenCentral() | ||
jcenter() | ||
maven { url 'https://www.jitpack.io' } | ||
} | ||
|
||
|
||
apply plugin: 'java' | ||
apply plugin: 'kotlin' | ||
apply plugin: 'org.jetbrains.kotlin.jvm' | ||
|
||
sourceCompatibility = 1.8 | ||
|
||
compileKotlin { | ||
kotlinOptions.jvmTarget = "1.8" | ||
} | ||
compileTestKotlin { | ||
kotlinOptions.jvmTarget = "1.8" | ||
} | ||
|
||
dependencies { | ||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8" | ||
|
||
testCompile group: 'junit', name: 'junit', version: '4.12' | ||
testCompile "org.junit.jupiter:junit-jupiter-api:5.4.2" | ||
testCompile "org.junit.jupiter:junit-jupiter-params:5.4.2" | ||
testCompile group: 'com.squareup.okhttp', name: 'mockwebserver', version: '2.7.5' | ||
testCompile "io.ktor:ktor-server-tests:$ktor_version" | ||
testCompile "com.squareup.retrofit2:retrofit-mock:2.2.0" | ||
testCompile "org.powermock:powermock-module-junit4:2.0.2" | ||
testCompile "org.powermock:powermock-api-mockito2:2.0.2" | ||
testCompile 'org.mock-server:mockserver-netty:5.5.4' | ||
} | ||
} | ||
|
||
class UpdateVersion extends DefaultTask { | ||
private String tag | ||
|
||
@Option(option = "tag", description = "Updates the project version with specified tag (when supplying the tag do not include the initial v).") | ||
void setTag(String tag) { | ||
this.tag = tag | ||
} | ||
|
||
@Input | ||
String getTag() { | ||
return tag | ||
} | ||
|
||
@TaskAction | ||
void print() { | ||
getLogger().quiet("Updating files to version $tag") | ||
String oldTag = project.version | ||
|
||
getLogger().quiet("Updating build.gradle file") | ||
String updatedBuildGradle = project.buildFile.getText().replaceFirst("version '$oldTag'", "version '$tag'") | ||
project.buildFile.setText(updatedBuildGradle) | ||
|
||
getLogger().quiet("Updating Changelog and Dockerfile") | ||
runCommand("./scripts/update-changelog.sh", tag) | ||
|
||
getLogger().quiet("Commit and tag creation on local repository") | ||
String tagName = "v${tag}" | ||
runCommand("git", "commit", "-a", "-m", tagName) | ||
runCommand("git", "tag", tagName) | ||
} | ||
|
||
static String runCommand(String... commands) { | ||
Process process = new ProcessBuilder(commands).redirectErrorStream(true).start() | ||
process.waitFor() | ||
String result = '' | ||
process.inputStream.eachLine { result += it + '\n' } | ||
boolean error = process.exitValue() != 0 | ||
if (error) { | ||
println(result) | ||
} | ||
return result | ||
} | ||
} | ||
//to execute the task: ./gradlew version --tag=[version] | ||
task version(type: UpdateVersion) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" | ||
|
||
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' | ||
compile group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '6.0' | ||
|
||
compile 'com.google.guava:guava:28.0-jre' | ||
|
||
compile "com.squareup.retrofit2:retrofit:2.8.1" | ||
compile 'com.squareup.retrofit2:converter-jackson:2.8.1' | ||
compile 'com.squareup.okhttp3:logging-interceptor:4.5.0' | ||
|
||
compile "io.ktor:ktor-server-netty:$ktor_version" | ||
compile "io.ktor:ktor-server-core:$ktor_version" | ||
compile "io.ktor:ktor-client-core-jvm:$ktor_version" | ||
compile "io.ktor:ktor-jackson:$ktor_version" | ||
|
||
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1" | ||
|
||
compile 'com.fasterxml.jackson.core:jackson-databind:2.10.3' | ||
compile 'com.fasterxml.jackson.module:jackson-module-kotlin:2.10.3' | ||
} | ||
|
||
def generatedVersionDir = "${buildDir}/generated-version" | ||
|
||
sourceSets { | ||
main { | ||
output.dir(generatedVersionDir, builtBy: 'generateVersionProperties') | ||
} | ||
} | ||
|
||
task generateVersionProperties { | ||
doLast { | ||
def propsFile = file "$generatedVersionDir/version.properties" | ||
propsFile.parentFile.mkdirs() | ||
def props = new Properties() | ||
print(rootProject.version.toString()) | ||
props.setProperty("version", rootProject.version.toString()) | ||
propsFile.withWriter { props.store(it, null) } | ||
} | ||
} | ||
processResources.dependsOn generateVersionProperties | ||
build.dependsOn generateVersionProperties | ||
|