Skip to content

Commit

Permalink
added language switch to code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Frisch12 committed Aug 26, 2023
1 parent 3ab89fb commit 41ebda2
Show file tree
Hide file tree
Showing 12 changed files with 291 additions and 87 deletions.
8 changes: 8 additions & 0 deletions documentation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ plugins {
id 'io.freefair.javadoc-links'
}

configurations {
asciidoctorExt
}

asciidoctor {
baseDirFollowsSourceDir()

attributes gradle_version: gradle.gradleVersion

configurations 'asciidoctorExt'

inputs.dir("src/docs/asciidoc")
}

Expand All @@ -22,6 +28,8 @@ dependencies {
javadocClasspath "org.jacoco:org.jacoco.ant:${org.gradle.testing.jacoco.plugins.JacocoPlugin.DEFAULT_JACOCO_VERSION}"
javadocClasspath "org.apache.maven.plugins:maven-plugin-plugin:3.9.0"
javadocClasspath 'net.sourceforge.plantuml:plantuml:1.2023.10'

asciidoctorExt "io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch:0.6.2"
}

tasks.register("docsZip", Zip) {
Expand Down
73 changes: 49 additions & 24 deletions documentation/src/docs/asciidoc/_aspectj.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,59 +33,67 @@ This plugin adds AspectJ support to the project, by adding a `aspectj` directory

Source contained in the `src/main/aspectj` directory will be compiled with `ajc` by the `compileAspectj` task.

[source,groovy]
====
[source, groovy, role="primary"]
.Groovy
----
dependencies {
implementation "org.aspectj:aspectjrt:1.9.8.RC3"
}
----

[source,kotlin]
[source, kotlin, role="secondary"]
.Kotlin
----
dependencies {
implementation("org.aspectj:aspectjrt:1.9.8.RC3")
}
----
====

TIP: This is follows the same principles as the `groovy` and `scala` plugins.

Additional advices (the `-aspectpath`) can be declared as dependencies of the `aspect` configuration:

[source,groovy]
====
[source, groovy, role="primary"]
.Groovy
----
dependencies {
aspect project(":my-aspect")
testAspect "com.example.foo:bar-aspect:1.0.0"
}
----

[source,kotlin]
[source, kotlin, role="secondary"]
.Kotlin
----
dependencies {
aspect(project(":my-aspect"))
testAspect("com.example.foo:bar-aspect:1.0.0")
}
----

====

Additional jars/classes which should be woven and added to the output as well (the `-inpath`)
can be declared as dependencies fo the `inpath` configuration:

[source,groovy]
====
[source, groovy, role="primary"]
.Groovy
----
dependencies {
inpath project(":my-lib")
testInpath "com.example.foo:bar-lib:1.0.0"
}
----

[source,kotlin]
[source, kotlin, role="secondary"]
.Kotlin
----
dependencies {
inpath(project(":my-lib"))
testInpath("com.example.foo:bar-lib:1.0.0")
}
----
====

=== `io.freefair.aspectj.post-compile-weaving`

Expand All @@ -94,62 +102,75 @@ with an additional `ajc` action in order to perform post-compile-weaving.

The output of the compilation (`javac`, etc.) becomes the `-inpath` for `ajc`.

[source,groovy]
====
[source, groovy, role="primary"]
.Groovy
----
dependencies {
implementation "org.aspectj:aspectjrt:1.9.8.RC3"
}
----
[source,kotlin]
[source, kotlin, role="secondary"]
.Kotlin
----
dependencies {
implementation("org.aspectj:aspectjrt:1.9.8.RC3")
}
----
====

Additional advices (the `-aspectpath`) can be declared as dependencies of the `aspect` configuration:

[source,groovy]
====
[source, groovy, role="primary"]
.Groovy
----
dependencies {
aspect project(":my-aspect")
testAspect "com.example.foo:bar-aspect:1.0.0"
}
----
[source,kotlin]
[source, kotlin, role="secondary"]
.Kotlin
----
dependencies {
aspect(project(":my-aspect"))
testAspect("com.example.foo:bar-aspect:1.0.0")
}
----
====

Additional jars/classes which should be woven and added to the output as well (the `-inpath`)
can be declared as dependencies fo the `inpath` configuration:

[source,groovy]
====
[source, groovy, role="primary"]
.Groovy
----
dependencies {
inpath project(":my-lib")
testInpath "com.example.foo:bar-lib:1.0.0"
}
----

[source,kotlin]
[source, kotlin, role="secondary"]
.Kotlin
----
dependencies {
inpath(project(":my-lib"))
testInpath("com.example.foo:bar-lib:1.0.0")
}
----
====

The `-classpath`, `-source` and `-target`
arguments of `ajc` are set automatically to the corresponding values taken from the compile task.
Additional `ajc` arguments can be configured using the `ajc.options.compilerArgs` property as shown below.

The following things are configurable:

[source,groovy]
====
[source, groovy, role="primary"]
.Groovy
----
compileJava {
ajc {
Expand All @@ -172,8 +193,8 @@ compileTestJava {
}
}
----

[source,kotlin]
[source, kotlin, role="secondary"]
.Kotlin
----
tasks.compileJava {
configure<AjcAction> {
Expand All @@ -196,6 +217,7 @@ tasks.compileTestJava {
}
}
----
====
<1> Specifies if ajc should run at all. Defaults to `true`
<2> The classpath containing ajc itself (`aspectjtools.jar`). Inferred from the compile/runtime classpaths by default.
<3> The classpath containing additional advices to weave. This directly maps to the `-aspectpath` argument of ajc.
Expand All @@ -212,7 +234,9 @@ https://docs.gradle.org/{gradle_version}/javadoc/org/gradle/api/tasks/compile/Ab
task can be used to run
https://www.eclipse.org/aspectj/doc/released/devguide/ajc-ref.html[`ajc`].

[source,groovy]
====
[source, groovy, role="primary"]
.Groovy
----
task myAjcTask(type: io.freefair.gradle.plugins.aspectj.AspectjCompile) {
aspectjClasspath.setFrom configurations.aspectj
Expand All @@ -222,8 +246,8 @@ task myAjcTask(type: io.freefair.gradle.plugins.aspectj.AspectjCompile) {
}
}
----

[source,kotlin]
[source, kotlin, role="secondary"]
.Kotlin
----
tasks.register<AspectjCompile>("myAjcTask") {
aspectjClasspath.setFrom(configurations.aspectj)
Expand All @@ -232,4 +256,5 @@ tasks.register<AspectjCompile>("myAjcTask") {
aspectpath = files()
}
}
----
----
====
Loading

0 comments on commit 41ebda2

Please sign in to comment.