Skip to content

Commit b12af68

Browse files
authored
Add example to test transitive compile-time dependencies in Gradle (#279)
* Add example to test transitive compile-time dependencies in Gradle This adds an example that show that the Gradle Metadata published for Log4j has the desired effect on the compile classpath when Log4j is used in Gradle builds. This changes the "Android test pipeline" to a "Gradle test pipeline" to run all Gradle-based tests. Which are at the moment the "Android test" and this newly added test. Signed-off-by: Jendrik Johannes <[email protected]> * Downgrade Android plugin to a supported version --------- Signed-off-by: Jendrik Johannes <[email protected]>
1 parent 49b33ae commit b12af68

File tree

16 files changed

+171
-15
lines changed

16 files changed

+171
-15
lines changed

.github/workflows/android-reusable-test.yaml renamed to .github/workflows/gradle-reusable-test.yaml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ permissions: read-all
3838

3939
jobs:
4040

41-
android-test:
41+
gradle-test:
4242

4343
runs-on: ubuntu-latest
4444

@@ -64,6 +64,17 @@ jobs:
6464
develocity-url: https://develocity.apache.org
6565
develocity-plugin-version: 3.18.2
6666

67+
- name: Test log4j-samples-gradle-metadata
68+
id: build
69+
shell: bash
70+
env:
71+
LOG4J_VERSION: ${{ inputs.log4j-version }}
72+
LOG4J_REPOSITORY_URL: ${{ inputs.log4j-repository-url }}
73+
run: |
74+
./gradlew \
75+
-Plog4j.version=$LOG4J_VERSION \
76+
-Plog4j.repository.url=$LOG4J_REPOSITORY_URL \
77+
:app:build :app:connectedCheck
6778
6879
- name: Enable KVM
6980
run: |
@@ -112,18 +123,17 @@ jobs:
112123
sleep 1
113124
done
114125
115-
- name: Build
126+
- name: Test log4j-samples-android
116127
id: build
117128
shell: bash
118129
env:
119130
LOG4J_VERSION: ${{ inputs.log4j-version }}
120131
LOG4J_REPOSITORY_URL: ${{ inputs.log4j-repository-url }}
121132
run: |
122-
log4j-samples-android/gradlew -p log4j-samples-android \
123-
--console plain \
133+
./gradlew \
124134
-Plog4j.version=$LOG4J_VERSION \
125135
-Plog4j.repository.url=$LOG4J_REPOSITORY_URL \
126-
build connectedCheck
136+
:app:build :app:connectedCheck
127137
128138
- name: Remove AVD Device
129139
if: ${{ always() && env.EMULATOR_STARTED == 'true' }}

.github/workflows/integration-test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ jobs:
6565
ref: ${{ inputs.samples-ref }}
6666
test-report-suffix: '-it'
6767

68-
android-test:
69-
uses: apache/logging-log4j-samples/.github/workflows/android-reusable-test.yaml@main
68+
gradle-test:
69+
uses: apache/logging-log4j-samples/.github/workflows/gradle-reusable-test.yaml@main
7070
with:
7171
log4j-version: ${{ inputs.log4j-version }}
7272
log4j-repository-url: ${{ inputs.log4j-repository-url }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ target/
1818
.flattened-pom.xml
1919
/.mvn/wrapper/maven-wrapper.jar
2020
/.mvn/extensions.xml
21+
# Gradle
22+
.gradle/
23+
build/
2124
# IDEA
2225
.idea/
2326
*.iml

README.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Explains how to send logs to https://flume.apache.org[Apache Flume].
3333
xref:log4j-samples-graalvm/README.adoc[`log4j-samples-graalvm`]::
3434
Explains how to use Log4j API and its implementation to create native GraalVM images.
3535
36+
xref:log4j-samples-gradle-metadata/README.adoc[`log4j-samples-gradle-metadata`]::
37+
Shows how strict compile classpath or module path checking can be enabled for compilation in Gradle when Log4j is used and that all required annotation libraries are available.
38+
3639
xref:log4j-samples-jlink/README.adoc[`log4j-samples-jlink`]::
3740
An example of JLink custom JRE.
3841

log4j-samples-android/gradle.properties renamed to gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
# limitations under the License.
1616
#
1717
##
18+
19+
# Enable assertions
20+
org.gradle.jvmargs=-ea
21+
1822
# Required by AndroidX dependencies
1923
android.useAndroidX = true
2024

File renamed without changes.
File renamed without changes.

log4j-samples-android/README.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ To build the project, run:
2525
2626
[source,shell]
2727
----
28-
./gradlew build
28+
./gradlew :app:build
2929
----
3030
31-
inside this directory.
31+
in the samples repository root.
3232
3333
Since version `2.25.0` this application is part of the integration tests for a Log4j release.
3434

0 commit comments

Comments
 (0)