$ ./gradlew --version
------------------------------------------------------------
Gradle 7.2
------------------------------------------------------------
Build time: 2021-08-17 09:59:03 UTC
Revision: a773786b58bb28710e3dc96c4d1a7063628952ad
Kotlin: 1.5.21
Groovy: 3.0.8
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 17 (Amazon.com Inc. 17+35-LTS)
OS: Mac OS X 11.6 x86_64
$ swiftc --version
Apple Swift version 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1)
Target: x86_64-apple-darwin20.6.0
Following the official documentation (7.2) on swift project on tweaking compiler options, I expected that adding
withType<SwiftCompile>().configureEach {}
would work but it didn'tExpected Behavior
The configure all work as documented / expected.
Current Behavior
I noticed this on the
optimized
anddebuggable
flags in particular, turning them off (withfalse
) isn't applied:Notice the
-g
(debug symbols) and-O
(optimizations) flags.Context
When switching shell build scripts using a simpler commands like this
to gradle I noticed awkward code behavior due to optimization turned on.
Steps to Reproduce
This can be reproduced using the a simple gradle init (or via the linked project.zip)
``` Select type of project to generate: 1: basic 2: application 3: library 4: Gradle plugin Enter selection (default: basic) [1..4] 3 Select implementation language: 1: C++ 2: Groovy 3: Java 4: Kotlin 5: Scala 6: Swift Enter selection (default: Java) [1..6] 6 Select build script DSL: 1: Groovy 2: Kotlin Enter selection (default: Groovy) [1..2] 2 Project name (default: to-be-removed): > Task :init Get more help with your project: https://docs.gradle.org/7.2/samples/sample_building_swift_libraries.html BUILD SUCCESSFUL in 15s 2 actionable tasks: 2 executed ```gradle init
And adding this to
lib/build.gradle.kts
Then run
Eventually use the
outputs.upToDateWhen { false }
to force the compilation to re-run.Workaround
At this point the workaround is to define these flags on the specific variant tasks.
Your Environment
Build scan URL: https://scans.gradle.com/s/jlyikcvpo6rto