Skip to content

Commit

Permalink
Draft guide for OCI Kubernetes (#1175)
Browse files Browse the repository at this point in the history
* Switch to use Serde for the S3 Event guide (#1138)

* Switch to use Serde for the Discovery eureka guide (#1134)

* Switch to use Serde for the Oauth client credentials auth0 guide (#1133)

* Switch to use Serde for the Discovery consul guide (#1135)

* Use the correct version for the micronaut-data processor with SpringBoot (#1164)

We were using the version of Micronaut, which is incorrect

* Guide: Connect a Micronaut JMS Application to an AWS SQS Queue (#1160)

Max supported Java version by AWS SDK 1.x is 16 (https://github.com/aws/aws-sdk-java#maintenance-and-support-for-java-versions)

* add AWS SQS twitter card

* Remove references to postgres and use mysql consistently for guide (#1166)

closes #1161

* Switch to use Serde for the Mybatis data access guide (#1139)

* Switch to use Serde for the Mybatis data access guide

* Remove Creator, fix Kotlin warning

* Fixes missing section in trace guide (#1173)

* Fixes wrong callouts to WarehouseController endpoints (#1174)

* Draft guide for OCI Kubernetes

* Apply suggestions from code review

Co-authored-by: Bernard Horan <bernard.horan@oracle.com>

* Update guides to 3.7.5 (#1179)

* code review improvements add native image support

* code review improvements add native image support

* code review improvements

* code review improvements

* Build Guides with Micronaut 3.8.0 (#1157)

* Build Guides with Micronaut 3.8.0

This PR runs the guides with Micronaut 3.8.0-SNAPSHOT as a pre-release check

Removes the local localstack feature as this now exists in 3.8.0

* Add snapshot repo for snapshot versions of Micronaut

* Look up the version for the data processor

* version 3.8.0

Co-authored-by: Sergio del Amo <sergio.delamo@softamo.com>

* Remove ambiguity for Kotlin (#1182)

It couldn't work out which mathod to call as the closure had an implicit return value.

I'm not sure why this has only recently appeared...  Maybe a change to micrometer

* Fix inputs for guides with a base (#1183)

If we have a guide that declares a base project, ie:

https://github.com/micronaut-projects/micronaut-guides/blob/dd911994e0c54c068602389dbcbe08eac8bdf045/guides/micronaut-metrics-aws/metadata.json#L2

Then we were not taking the code from micronaut-metrics into account for the cache-key, so changes were not picked up when building micronaut-metrics-aws

This change adds the base directory as an input if it was set

* remove empty constructor (#1167)

* misc fixes and cleanup (#1186)

* Add R2DBC guide (#965)

* copy: change GraalVM version (#1187)

* change publication to 2023-01-04

* fix: category should be categories

* disable spring-boot-micronaut-data guide (#1185)

* Micronaut Framework 3.8.1 (#1195)

* Kotlin and Groovy versions of Micronaut Dependency Injection types (#1227)

Close #1082

* Add K8s AWS guide

* Add K8s AWS guide

* Kotlin version of JAX-RS guide (#1225)

Close #1221

* code review improvements

* Micronaut Framework 3.8.2 (#1229)

* fix java version typo (#1234)

* Mock Github Server to avoid rate limiting in HTTP Client Guide (#1236)

* build: Micronaut Framework 3.8.4

* X-API-KEY guide (#1237)

* add api key guide twitter card

* CORS guide (#1238)

* docker image guide (#1239)

* executable Jar guide to distribution category (#1240)

- enable every language. Use distributable-base

* create the http client lazyly (#1243)

* add lateinit and @field callouts (#1228)

* Custom constraint guide (#1244)

* custom constraint

* Update guides/micronaut-custom-validation-annotation/java/src/test/java/example/micronaut/ContactTest.java

* twitter card

* Fix curl command (#1248)

When copying the curl command, each new line is executed rather than waiting for the last command.

* build: Micronaut Framework 3.8.5(#1249)

* Guide: Using IntelliJ IDEA to develop Micronaut applications (#1241)

* 2023 copyright

* Micronaut Framework 3.8.6 (#1251)

* build: Micronaut Framework 3.8.7 (#1252)

* add awaitility version (#1253)

Close: #1074

* Fixes for MN Scope Types guide, mostly imports and annotations to ensure that the Tests work as intended. (#1254)

* [Error-handling Guide] Added missing dependency and a closing bracket for the BookController class. (#1260)

* Micronaut Framework 3.8.8 (#1261)

* move create your first graalvm guide to distribution category (#1256)

* Security Session Guide: Removed the extra dependency that could cause tests to fail (#1263)

* CRaC Cloud Run guide (#1259)

Close #1257

* Keycloak Guide (#586)

* add back common-google-cloud-platform.adoc snippet

accidentally deleted via #1259

* add image back

* use categories

* Micronaut Framework 3.8.9 (#1264)

* [Database JDBC Guides for AWS, Azure, and GCP] Fixed the environment variable names to be compatible with the sample JDBC application, and added explanations similar to the original JDBC guide. (#1270)

* build: Micronaut Framework 3.9.1 (#1267)

* build: Micronaut Build Plugin to 5.4.9 (#1273)

* 3.9.2 (#1280)

---------

Co-authored-by: Tim Yates <tim.yates@gmail.com>
Co-authored-by: Slavko <bodvanski.slavko@gmail.com>
Co-authored-by: sdelamo <sergio.delamo@softamo.com>
Co-authored-by: Dean Wette <wetted@objectcomputing.com>
Co-authored-by: Bernard Horan <bernard.horan@oracle.com>
Co-authored-by: Burt Beckwith <burt@burtbeckwith.com>
Co-authored-by: Graeme Rocher <graeme.rocher@gmail.com>
Co-authored-by: Alina Yurenko <alina.yurenko@oracle.com>
Co-authored-by: hartraft <hartraft@tutanota.com>
Co-authored-by: Long Pham <ptlitmipitu@gmail.com>
  • Loading branch information
11 people authored May 24, 2023
1 parent b21e2fb commit d438c6c
Show file tree
Hide file tree
Showing 547 changed files with 7,581 additions and 1,508 deletions.
8 changes: 7 additions & 1 deletion assets/stylesheets/guide.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,10 @@
left: 0;
width: 100%;
height: 100%;
}
}

.tableblock td {
border: 1px dotted #cccccc;
padding: 5px;
text-align: center;
}
2 changes: 1 addition & 1 deletion assets/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ <h1>@title@</h1>
<div id="text-5" class="widget widget_text">
<div class="textwidget">
<p>
<small>© 2022 MICRONAUT FOUNDATION. ALL RIGHTS RESERVED</small>
<small>© 2023 MICRONAUT FOUNDATION. ALL RIGHTS RESERVED</small>
</p>
</div>
</div>
Expand Down
14 changes: 7 additions & 7 deletions buildSrc/src/main/groovy/io/micronaut/guides/GitDiffUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class GitDiffUtils {
static boolean onlyImagesOrMarkdownOrAsciidocChanged(List<String> filesChanged) {
filesChanged.every { String filename ->
filename.endsWith('adoc') ||
filename.endsWith('markdown') ||
filename.endsWith('md') ||
filename.endsWith('png') ||
filename.endsWith('jpeg') ||
filename.endsWith('jpg') ||
filename.endsWith('svg') ||
filename.endsWith('gif')
filename.endsWith('markdown') ||
filename.endsWith('md') ||
filename.endsWith('png') ||
filename.endsWith('jpeg') ||
filename.endsWith('jpg') ||
filename.endsWith('svg') ||
filename.endsWith('gif')
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.gradle.api.GradleException

import java.nio.file.Paths
import java.util.Map.Entry
import java.util.regex.Matcher
import java.util.regex.Pattern

import static io.micronaut.starter.api.TestFramework.SPOCK
Expand All @@ -27,20 +28,23 @@ import static io.micronaut.starter.options.Language.GROOVY

@CompileStatic
class GuideAsciidocGenerator {

private static final String INCLUDE_COMMONDIR = 'common:'
private static final String CALLOUT = 'callout:'
private static final String EXTERNAL = 'external:'
private static final String EXTERNAL_PARAMETRIZED = 'external-template:'
private static final String COMMON_PARAMETRIZED = 'common-template:'
private static final Pattern GUIDE_LINK_REGEX = ~/(.*)guideLink:(.*)\[(.*)](.*)/

public static final int DEFAULT_MIN_JDK = 8
public static final String EXCLUDE_FOR_LANGUAGES = ':exclude-for-languages:'
public static final String EXCLUDE_FOR_JDK_LOWER_THAN = ':exclude-for-jdk-lower-than:'
public static final String EXCLUDE_FOR_BUILD = ':exclude-for-build:'
private static final String CLI_MESSAGING = 'create-messaging-app'
private static final String CLI_DEFAULT = 'create-app'
private static final String CLI_GRPC = 'create-grpc-app'
private static final String CLI_FUNCTION = 'create-function-app'
private static final String CLI_CLI = 'create-cli-app'

public static final int DEFAULT_MIN_JDK = 8
public static final String EXCLUDE_FOR_LANGUAGES = ':exclude-for-languages:'
public static final String EXCLUDE_FOR_JDK_LOWER_THAN = ':exclude-for-jdk-lower-than:'
public static final String EXCLUDE_FOR_BUILD = ':exclude-for-build:'
public static final String DEFAULT_APP_NAME = "default"

static void generate(GuideMetadata metadata, File inputDir,
Expand Down Expand Up @@ -252,7 +256,12 @@ class GuideAsciidocGenerator {
include rawLine, rawLines, projectDir, true
} else if (rawLine.startsWith(EXTERNAL) && rawLine.endsWith(']')) {
include rawLine, rawLines, projectDir, false
} else {
}else if (rawLine.startsWith(COMMON_PARAMETRIZED) && rawLine.endsWith(']')){
rawLines.addAll includeParametrized(rawLine, projectDir, true)
} else if (rawLine.startsWith(EXTERNAL_PARAMETRIZED) && rawLine.endsWith(']')){
rawLines.addAll includeParametrized(rawLine, projectDir, false)
}
else {
rawLines << rawLine
}
}
Expand Down Expand Up @@ -281,6 +290,56 @@ class GuideAsciidocGenerator {
line
}

private static List<String> includeParametrized(String rawLine, File projectDir, boolean snippet) {

String prefix = snippet ? COMMON_PARAMETRIZED : EXTERNAL_PARAMETRIZED

String relativePath = parseFileName(rawLine, prefix)
.orElseThrow(() -> new GradleException("could not parse filename from include line: " + rawLine))

if (snippet) {
relativePath = 'src/docs/common/snippets/common-' + relativePath
} else {
relativePath = 'guides/' + relativePath
}

File file = new File(projectDir, relativePath)

List<String> newLines = commonLines(file, projectDir)

String pattern = "(\\{(\\d+)(:?([UL])?)})"

// Create a Pattern object
Pattern r = Pattern.compile(pattern)

for (int i = 0; i < newLines.size(); i++) {
String line = newLines[i]
Matcher m = r.matcher(line)
while (m.find()) {
def replaceString = m.group(1)
def argNum = m.group(2)
String value = extractFromParametersLine(rawLine, "arg" + argNum)
def letter = m.group(4)
if (value) {
switch (letter) {
case 'U':
line = line.replace(replaceString, value.toUpperCase())
break
case 'L':
line = line.replace(replaceString, value.toUpperCase())
break
default:
line = line.replace(replaceString, value)
break
}
newLines[i] = line
}
}
}

newLines
}

private static void include(String rawLine, List<String> rawLines, File projectDir,
boolean snippet) {

Expand Down Expand Up @@ -399,7 +458,7 @@ class GuideAsciidocGenerator {
String indent = extractIndent(line)

String sourcePath = testFramework ? testPath(appName, name, testFramework) : mainPath(appName, name)
String normalizedSourcePath = (Paths.get(sourcePath)).normalize().toString();
String normalizedSourcePath = (Paths.get(sourcePath)).normalize()
List<String> lines = [
'[source,@lang@]',
'.' + normalizedSourcePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.Zip

import java.util.concurrent.atomic.AtomicBoolean
import java.util.function.Predicate
import java.util.stream.Collectors

Expand Down Expand Up @@ -368,6 +367,9 @@ class GuidesPlugin implements Plugin<Project> {
it.guidesGenerator = projectGenerator
it.slug.set(metadata.slug)
it.inputDirectory.set(guidesDir.dir(metadata.slug))
if (metadata.base != null) {
it.baseInputDirectory.set(guidesDir.dir(metadata.base))
}
it.outputDir.set(codeDir.map(s -> s.dir(metadata.slug)))
it.guidesGenerator = projectGenerator
it.metadata = metadata
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package io.micronaut.guides;
package io.micronaut.guides

import groovy.transform.CompileStatic;

import java.util.List;
import groovy.transform.CompileStatic

@CompileStatic
public class GuidesSection {
class GuidesSection {
Object category
List<GuideMetadata> metadatas
}
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,14 @@ class IndexGenerator {
return 'https://micronaut.io/wp-content/uploads/2020/11/Misc.svg'
}

private static String category(Object cat) {
String html = "<div class='category'>"
html += '<div class="inner">'
html += '<img width="100" style="margin-bottom: 30px" src="' + imageForCategory(cat) + '"/>'
html += '<h1 class="title title_large first-word-bold first-word-break">' + cat + '</h1>'
html += '<div class="underline"></div>'
html += "</div>"
html += "</div>"
html
private static String category(cat) {
"<div class='category'>" +
'<div class="inner">' +
'<img width="100" style="margin-bottom: 30px" src="' + imageForCategory(cat) + '"/>' +
'<h1 class="title title_large first-word-bold first-word-break">' + cat + '</h1>' +
'<div class="underline"></div>' +
"</div>" +
"</div>"
}

static String generateGuidesJsonIndex(File guidesFolder, String metadataConfigName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ class OpenAPIGenerator {
generator.opts(clientOptInput)
generator.generate()
} catch (GeneratorNotFoundException e) {
throw new GradleException("OpenAPI couldn't find specified generator: \"" +
e.message + "\". Check 'generatorName' property. ")
throw new GradleException("""OpenAPI couldn't find specified generator: "$e.message". Check 'generatorName' property. """)
} catch(NoSuchMethodError e) {
throw new GradleException("OpenAPI generator failed with \"" + e.message + "\"")
throw new GradleException("""OpenAPI generator failed with "$e.message" """)
} catch (Exception e) {
throw new GradleException("OpenAPI generator failed with \"" + e.message + "\"")
throw new GradleException("""OpenAPI generator failed with "$e.message" """)
}
}

Expand All @@ -67,9 +66,9 @@ class OpenAPIGenerator {
BuildTool buildTool,
String destinationPackage) {
CodegenConfigurator configurator = new CodegenConfigurator()
configurator.setInputSpec(definitionFilePath.getPath())
configurator.setGeneratorName(config.generatorName)
configurator.setOutputDir(destination.getPath())
configurator.inputSpec = definitionFilePath.path
configurator.generatorName = config.generatorName
configurator.outputDir = destination.path
config.globalProperties?.each { k, v -> configurator.addGlobalProperty(k, v) }
configurationAdditionalProperties(config, testFramework, buildTool, destinationPackage).each { k, v ->
configurator.addAdditionalProperty(k, v)
Expand All @@ -88,17 +87,16 @@ class OpenAPIGenerator {
additionalProperties.put(PROPERTY_CONTROLLER_PACKAGE, destinationPackage + PACKAGE_CONTROLLER)
additionalProperties.put(PROPERTY_API_PACKAGE, destinationPackage + PACKAGE_API)
additionalProperties.put(PROPERTY_MODEL_PACKAGE, destinationPackage + PACKAGE_MODEL)
config.properties?.each {k, v ->
additionalProperties.put(k, v)
}
config.properties?.each {k, v -> additionalProperties.put(k, v)}
additionalProperties
}

@NonNull
private static Optional<String> buildProperty(@NonNull BuildTool buildTool) {
if (buildTool.isGradle()) {
return Optional.of(GRADLE.toString())
} else if (buildTool == MAVEN) {
}
if (buildTool == MAVEN) {
return Optional.of(MAVEN.toString())
}
Optional.empty()
Expand Down
19 changes: 7 additions & 12 deletions buildSrc/src/main/groovy/io/micronaut/guides/Tag.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import groovy.transform.Sortable
@Sortable(includes = ['title'])
@CompileStatic
class Tag {

String title
int ocurrence

Expand All @@ -16,24 +17,18 @@ class Tag {
}

String getSlug() {
if ( !title ) {
if (!title) {
return null
}
String str = title
str = str.toLowerCase()
for ( String regex : [' ', '\\[', ']', '\''] ) {
String str = title.toLowerCase()
for (String regex : [' ', '\\[', ']', '\'']) {
str = str.replaceAll(regex, '')
}
str = str.trim()
URLEncoder.encode(str, 'UTF-8')
URLEncoder.encode(str.trim(), 'UTF-8')
}


@Override
public String toString() {
return "Tag{" +
"title='" + title + '\'' +
", ocurrence=" + ocurrence +
'}';
String toString() {
"Tag{title='$title', ocurrence=$ocurrence"
}
}
12 changes: 5 additions & 7 deletions buildSrc/src/main/groovy/io/micronaut/guides/Utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import io.micronaut.starter.options.JdkVersion
import org.gradle.api.GradleException
import org.gradle.api.JavaVersion

import static io.micronaut.starter.options.JdkVersion.JDK_11

@CompileStatic
class Utils {

private static final String SYS_PROP_MICRONAUT_GUIDE = 'micronaut.guide'
private static final String ENV_JDK_VERSION = 'JDK_VERSION'
private static final JdkVersion DEFAULT_JAVA_VERSION = JdkVersion.JDK_11
private static final JdkVersion DEFAULT_JAVA_VERSION = JDK_11

static String singleGuide() {
System.getProperty(SYS_PROP_MICRONAUT_GUIDE)
Expand All @@ -37,12 +39,8 @@ class Utils {

static boolean skipBecauseOfJavaVersion(GuideMetadata metadata) {
int jdkVersion = parseJdkVersion().majorVersion()
if ((metadata.minimumJavaVersion != null && jdkVersion < metadata.minimumJavaVersion) ||
(metadata.maximumJavaVersion != null && jdkVersion > metadata.maximumJavaVersion)) {
return true
} else {
return false
}
return (metadata.minimumJavaVersion != null && jdkVersion < metadata.minimumJavaVersion) ||
(metadata.maximumJavaVersion != null && jdkVersion > metadata.maximumJavaVersion)
}

static JdkVersion parseJdkVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction

import static org.gradle.api.tasks.PathSensitivity.RELATIVE

@CompileStatic
@CacheableTask
abstract class AsciidocGenerationTask extends DefaultTask {
Expand All @@ -26,7 +27,7 @@ abstract class AsciidocGenerationTask extends DefaultTask {
abstract Property<String> getSlug()

@InputDirectory
@PathSensitive(PathSensitivity.RELATIVE)
@PathSensitive(RELATIVE)
abstract DirectoryProperty getInputDirectory()

@OutputDirectory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction

import static org.gradle.api.tasks.PathSensitivity.RELATIVE

@CompileStatic
@CacheableTask
abstract class GuidesIndexGradleTask extends DefaultTask {
Expand All @@ -22,7 +23,7 @@ abstract class GuidesIndexGradleTask extends DefaultTask {
GuideMetadata metadata

@InputFile
@PathSensitive(PathSensitivity.RELATIVE)
@PathSensitive(RELATIVE)
abstract RegularFileProperty getTemplate()

@OutputDirectory
Expand Down
Loading

0 comments on commit d438c6c

Please sign in to comment.