From 950c53016153deac73dc1fecb21946accdafbc6a Mon Sep 17 00:00:00 2001 From: Eric Wendelin Date: Thu, 28 Feb 2019 16:56:49 -0700 Subject: [PATCH 1/2] Bootstrap use of common Gradle docs infrastructure This change introduces Asciidoctor, Asciidoctor extensions, and Exemplar to generate a docs/ site with a mini-guide for each sample. --- build.gradle.kts | 43 ++++++++++++++++++++++++++++++++++++++ cpp/application/index.adoc | 19 +++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 cpp/application/index.adoc diff --git a/build.gradle.kts b/build.gradle.kts index 014efb56..8607d32c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,47 @@ +import org.asciidoctor.gradle.AsciidoctorTask + // This root project is simply a container of sample builds plugins { + `java-library` + `kotlin-dsl` + id("org.asciidoctor.convert") version "1.5.3" id("org.gradle.samples.wrapper") } + +repositories { + jcenter() + maven { url = uri("https://repo.gradle.org/gradle/libs-releases") } +} + +dependencies { + testImplementation("org.gradle:sample-check:0.7.0") + testImplementation(gradleTestKit()) + asciidoctor("org.gradle:docs-asciidoctor-extensions:0.6.0") +} + +tasks { + getByName("asciidoctor") { + inputs.dir("cpp/application") + sourceDir = file("cpp/application") + outputDir = file("docs") + backends("html5") + + attributes( + mapOf("source-highlighter" to "prettify", + "imagesdir" to "images", + "stylesheet" to null, + "linkcss" to true, + "docinfodir" to ".", + "docinfo1" to "", + "nofooter" to true, + "icons" to "font", + "sectanchors" to true, + "sectlinks" to true, + "linkattrs" to true, + "encoding" to "utf-8", + "idprefix" to "", + "toc" to "auto", + "toclevels" to 1) + ) + } +} diff --git a/cpp/application/index.adoc b/cpp/application/index.adoc new file mode 100644 index 00000000..1569d8ea --- /dev/null +++ b/cpp/application/index.adoc @@ -0,0 +1,19 @@ += C++ Application +:description: A description of the sample + +.Assembling and running the C++ application +==== +[.testable-sample,dir="cpp/application"] +===== +[.sample-command,allow-additional-output=true] +---- +$ ./gradlew assemble +---- + +[.sample-command] +---- +$ ./build/install/main/debug/app +Hello, World! +---- +===== +==== From f0991bc94e95f459ae2d2c91b54ea501b0052212 Mon Sep 17 00:00:00 2001 From: Eric Wendelin Date: Thu, 28 Feb 2019 17:00:22 -0700 Subject: [PATCH 2/2] Add Exemplar test for embedded samples --- .../EmbeddedSamplesRunnerIntegrationTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/test/java/org/gradle/samples/EmbeddedSamplesRunnerIntegrationTest.java diff --git a/src/test/java/org/gradle/samples/EmbeddedSamplesRunnerIntegrationTest.java b/src/test/java/org/gradle/samples/EmbeddedSamplesRunnerIntegrationTest.java new file mode 100644 index 00000000..078c0221 --- /dev/null +++ b/src/test/java/org/gradle/samples/EmbeddedSamplesRunnerIntegrationTest.java @@ -0,0 +1,25 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed 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 org.gradle.samples; + +import org.gradle.samples.test.runner.GradleEmbeddedSamplesRunner; +import org.gradle.samples.test.runner.SamplesRoot; +import org.junit.runner.RunWith; + +@RunWith(GradleEmbeddedSamplesRunner.class) +@SamplesRoot("cpp/application") +public class EmbeddedSamplesRunnerIntegrationTest { +}