├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── README.md ├── plugin ├── build.gradle.kts ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ ├── groovy │ └── org │ │ └── jlleitschuh │ │ └── gradle │ │ └── aspectj │ │ └── AspectjTask.groovy │ ├── kotlin │ └── org │ │ └── jlleitschuh │ │ └── gradle │ │ └── aspectj │ │ └── AspectjPlugin.kt │ └── resources │ └── META-INF │ └── gradle-plugins │ └── org.jlleitschuh.gradle.kotlin-aspectj.properties └── samples ├── README.md ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── java-only ├── java-only.gradle.kts └── src │ ├── main │ └── java │ │ └── example │ │ ├── JavaTestAspect.java │ │ ├── MyApp.java │ │ └── StaticStateVariable.java │ └── test │ └── java │ └── example │ └── MyAppTest.java ├── kotlin ├── kotlin.gradle.kts ├── out │ └── production │ │ └── classes │ │ └── META-INF │ │ └── kotlin.kotlin_module └── src │ ├── main │ ├── java │ │ └── example │ │ │ └── KotlinTestAspect.java │ └── kotlin │ │ └── example │ │ └── Main.kt │ └── test │ └── kotlin │ └── example │ └── MyAppTest.kt ├── samples.gradle.kts ├── samples.iml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/eclipse,gradle,intellij,vim,java 3 | 4 | ### Eclipse ### 5 | 6 | .metadata 7 | bin/ 8 | tmp/ 9 | *.tmp 10 | *.bak 11 | *.swp 12 | *~.nib 13 | local.properties 14 | .settings/ 15 | .loadpath 16 | .recommenders 17 | 18 | # Eclipse Core 19 | .project 20 | 21 | # External tool builders 22 | .externalToolBuilders/ 23 | 24 | # Locally stored "Eclipse launch configurations" 25 | *.launch 26 | 27 | # PyDev specific (Python IDE for Eclipse) 28 | *.pydevproject 29 | 30 | # CDT-specific (C/C++ Development Tooling) 31 | .cproject 32 | 33 | # JDT-specific (Eclipse Java Development Tools) 34 | .classpath 35 | 36 | # Java annotation processor (APT) 37 | .factorypath 38 | 39 | # PDT-specific (PHP Development Tools) 40 | .buildpath 41 | 42 | # sbteclipse plugin 43 | .target 44 | 45 | # Tern plugin 46 | .tern-project 47 | 48 | # TeXlipse plugin 49 | .texlipse 50 | 51 | # STS (Spring Tool Suite) 52 | .springBeans 53 | 54 | # Code Recommenders 55 | .recommenders/ 56 | 57 | ### Intellij ### 58 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 59 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 60 | 61 | # User-specific stuff: 62 | .idea/**/workspace.xml 63 | .idea/**/tasks.xml 64 | 65 | # Sensitive or high-churn files: 66 | .idea/**/dataSources/ 67 | .idea/**/dataSources.ids 68 | .idea/**/dataSources.xml 69 | .idea/**/dataSources.local.xml 70 | .idea/**/sqlDataSources.xml 71 | .idea/**/dynamic.xml 72 | .idea/**/uiDesigner.xml 73 | 74 | # Gradle: 75 | .idea/**/gradle.xml 76 | .idea/**/libraries 77 | 78 | # Mongo Explorer plugin: 79 | .idea/**/mongoSettings.xml 80 | 81 | ## File-based project format: 82 | *.iws 83 | 84 | ## Plugin-specific files: 85 | 86 | # IntelliJ 87 | /out/ 88 | 89 | # mpeltonen/sbt-idea plugin 90 | .idea_modules/ 91 | 92 | # JIRA plugin 93 | atlassian-ide-plugin.xml 94 | 95 | # Crashlytics plugin (for Android Studio and IntelliJ) 96 | com_crashlytics_export_strings.xml 97 | crashlytics.properties 98 | crashlytics-build.properties 99 | fabric.properties 100 | 101 | ### Intellij Patch ### 102 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 103 | .idea/ 104 | 105 | ### Java ### 106 | # Compiled class file 107 | *.class 108 | 109 | # Log file 110 | *.log 111 | 112 | # BlueJ files 113 | *.ctxt 114 | 115 | # Mobile Tools for Java (J2ME) 116 | .mtj.tmp/ 117 | 118 | # Package Files # 119 | *.jar 120 | *.war 121 | *.ear 122 | *.zip 123 | *.tar.gz 124 | *.rar 125 | 126 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 127 | hs_err_pid* 128 | 129 | ### Vim ### 130 | # swap 131 | [._]*.s[a-v][a-z] 132 | [._]*.sw[a-p] 133 | [._]s[a-v][a-z] 134 | [._]sw[a-p] 135 | # session 136 | Session.vim 137 | # temporary 138 | .netrwhist 139 | *~ 140 | # auto-generated tag files 141 | tags 142 | 143 | ### Gradle ### 144 | .gradle 145 | build/ 146 | 147 | # Ignore Gradle GUI config 148 | gradle-app.setting 149 | 150 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 151 | !gradle-wrapper.jar 152 | 153 | # Cache of project 154 | .gradletasknamecache 155 | 156 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 157 | # gradle/wrapper/gradle-wrapper.properties 158 | 159 | # End of https://www.gitignore.io/api/eclipse,gradle,intellij,vim,java 160 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | matrix: 4 | fast_finish: true 5 | include: 6 | - os: linux 7 | jdk: oraclejdk8 8 | - os: osx 9 | osx_image: xcode8 10 | 11 | script: ./samples/gradlew build --no-daemon --stacktrace --console=plain 12 | 13 | before_cache: 14 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 15 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 16 | cache: 17 | directories: 18 | - $HOME/.gradle/caches/ 19 | - $HOME/.gradle/wrapper/ 20 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Jonathan Leitschuh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kotlin AspectJ Weaver Gradle Plugin 2 | 3 | [![Build Status](https://travis-ci.org/JLLeitschuh/gradle-kotlin-aspectj-weaver.svg?branch=master)](https://travis-ci.org/JLLeitschuh/gradle-kotlin-aspectj-weaver) 4 | 5 | A Gradle plugin that allows you to weave Java and Kotlin files with AspectJ 6 | using class time weaving instead of compile time weaving. 7 | 8 | A project loosely based upon the 9 | [eveoh/gradle-aspectj](https://github.com/eveoh/gradle-aspectj) 10 | project. 11 | This project supports weaving just Java classes or both Java and Kotlin code. 12 | 13 | This plugin could theoretically be adapted to weave other JVM languages but 14 | currently only supports Java. 15 | 16 | ## Release Status 17 | 18 | If someone has a serious interest in having this plugin used in their builds, I'll be hapy to publish a release. 19 | I haven't done so yet because I don't have a use for this project anymore. 20 | Please open an issue requesting a release of the plugin if you are actually interested in using it. 21 | 22 | ## Building Code 23 | 24 | This build uses Gradle's new 25 | [composite build](https://docs.gradle.org/4.1/userguide/composite_builds.html) 26 | feature to integration test several subprojects under the `samples` directory. 27 | 28 | If you want to run the samples and develop the plugin iteratively, then 29 | import the `samples/settings.gradle` file into ItelliJ. 30 | IntelliJ will figure out the rest. 31 | -------------------------------------------------------------------------------- /plugin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.gradle.api.tasks.compile.GroovyCompile 2 | import org.gradle.api.tasks.wrapper.Wrapper 3 | import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile 4 | 5 | plugins { 6 | id("org.jetbrains.kotlin.jvm") version "1.1.1" 7 | id("com.gradle.plugin-publish") version "0.9.7" 8 | } 9 | apply { 10 | plugin("groovy") 11 | } 12 | 13 | group = "org.jlleitschuh.aspectj" 14 | version = "0.0.1" 15 | 16 | repositories { 17 | mavenCentral() 18 | } 19 | 20 | dependencies { 21 | compileOnly(gradleApi()) 22 | compileOnly(gradleKotlinDsl()) 23 | compileOnly(kotlin("gradle-plugin", "1.1.1")) 24 | } 25 | 26 | // Allows us to use groovy code in kotlin 27 | // https://discuss.gradle.org/t/kotlin-groovy-and-java-compilation/14903/10?u=jlleitschuh 28 | val compileGroovy : GroovyCompile by tasks 29 | val compileJava by tasks 30 | compileGroovy.setDependsOn(compileGroovy.taskDependencies.getDependencies(compileGroovy) - compileJava) 31 | val compileKotlin : AbstractKotlinCompile<*> by tasks 32 | compileKotlin.dependsOn(compileGroovy) 33 | compileKotlin.classpath += files(compileGroovy.destinationDir!!) 34 | tasks.getByName("classes").dependsOn(compileKotlin) 35 | 36 | 37 | task("wrapper") { 38 | gradleVersion = "4.2" 39 | distributionType = Wrapper.DistributionType.ALL 40 | } -------------------------------------------------------------------------------- /plugin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JLLeitschuh/gradle-kotlin-aspectj-weaver/0c504c477b0993509823735654fdfb801f10495d/plugin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /plugin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Oct 11 18:42:20 EDT 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip 7 | -------------------------------------------------------------------------------- /plugin/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn ( ) { 37 | echo "$*" 38 | } 39 | 40 | die ( ) { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | for s in "${@}" ; do 159 | s=\"$s\" 160 | APP_ARGS=$APP_ARGS" "$s 161 | done 162 | 163 | # Collect all arguments for the java command, following the shell quoting and substitution rules 164 | eval set -- "$DEFAULT_JVM_OPTS" "$JAVA_OPTS" "$GRADLE_OPTS" "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 165 | 166 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 167 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 168 | cd "$(dirname "$0")" 169 | fi 170 | 171 | exec "$JAVACMD" "$@" 172 | -------------------------------------------------------------------------------- /plugin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /plugin/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'kotlin-aspectj-weaver' 2 | -------------------------------------------------------------------------------- /plugin/src/main/groovy/org/jlleitschuh/gradle/aspectj/AspectjTask.groovy: -------------------------------------------------------------------------------- 1 | package org.jlleitschuh.gradle.aspectj 2 | 3 | import org.gradle.api.DefaultTask 4 | import org.gradle.api.artifacts.Configuration 5 | import org.gradle.api.file.FileCollection 6 | import org.gradle.api.tasks.Input 7 | import org.gradle.api.tasks.InputFiles 8 | import org.gradle.api.tasks.OutputDirectory 9 | import org.gradle.api.tasks.TaskAction 10 | 11 | class AspectjTask extends DefaultTask { 12 | 13 | @InputFiles 14 | FileCollection classpath 15 | @InputFiles 16 | FileCollection aspectPath 17 | @Input 18 | Configuration ajcConfiguration 19 | @InputFiles 20 | FileCollection inpath 21 | 22 | @OutputDirectory 23 | File destDir 24 | 25 | @TaskAction 26 | void compile() { 27 | // This task is out of date. We don't know if classes have been removed so remove them all. 28 | project.delete(destDir.listFiles()) 29 | 30 | ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", 31 | classpath: ajcConfiguration.asPath) 32 | 33 | ant.iajc( 34 | maxmem: "1024m", fork: "true", Xlint: "ignore", 35 | destDir: destDir.absolutePath, 36 | aspectPath: aspectPath.asPath, 37 | inpath: inpath.asPath, 38 | classpath: classpath.asPath, 39 | source: project.sourceCompatibility, 40 | target: project.targetCompatibility 41 | ) 42 | } 43 | } -------------------------------------------------------------------------------- /plugin/src/main/kotlin/org/jlleitschuh/gradle/aspectj/AspectjPlugin.kt: -------------------------------------------------------------------------------- 1 | package org.jlleitschuh.gradle.aspectj 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | import org.gradle.api.Task 6 | import org.gradle.api.plugins.JavaPlugin 7 | import org.gradle.api.plugins.JavaPluginConvention 8 | import org.gradle.api.tasks.compile.AbstractCompile 9 | import org.gradle.api.tasks.compile.JavaCompile 10 | 11 | /** 12 | * Allows us to compile code with the normal gradle compilers. 13 | * Then applies the aspectj compiler to do class time weaving to the classes. 14 | */ 15 | open class AspectjPlugin : Plugin { 16 | override fun apply(project: Project) { 17 | project.plugins.apply(JavaPlugin::class.java) 18 | val ajcConfiguration = project.configurations.maybeCreate("ajc") 19 | val preWeaveJavaDir = project.file("${project.buildDir}/classes/java/preWeave") 20 | val preWeaveKotlinDir = project.file("${project.buildDir}/classes/kotlin/preWeave") 21 | 22 | val compileJava = (project.tasks.getByName("compileJava") as JavaCompile) 23 | val oldCompileJavaDestinationDir = compileJava.destinationDir 24 | compileJava.apply { 25 | destinationDir = preWeaveJavaDir 26 | } 27 | 28 | val sourceSets = project.convention.findPlugin(JavaPluginConvention::class.java)!!.sourceSets 29 | val mainSourceSet = sourceSets.getByName("main") 30 | val testSourceSet = sourceSets.getByName("test") 31 | // val integTestSourceSet = sourceSets.findByName("integTest") 32 | /* 33 | * This is a workaround for this: 34 | * https://youtrack.jetbrains.com/issue/KT-17035 35 | */ 36 | // In unit tests, link against the classes that haven't been weaved yet 37 | // testSourceSet.compileClasspath -= project.files(mainSourceSet.output.classesDirs) 38 | // testSourceSet.compileClasspath += project.files(preWeaveJavaDir) 39 | /* 40 | * In the integration tests we want to make sure that we are using the aspectj weaved classes. 41 | * We need to undo what we just did for integTestSourceSet because the above configuration is inherited. 42 | */ 43 | // integTestSourceSet?.apply { compileClasspath -= project.files(preWeaveJavaDir) } 44 | // integTestSourceSet?.apply { compileClasspath += project.files(mainSourceSet.output.classesDir) } 45 | project.afterEvaluate { 46 | val compileKotlin = (project.tasks.findByName("compileKotlin") as? AbstractCompile) 47 | compileKotlin?.apply { 48 | destinationDir = preWeaveKotlinDir 49 | } 50 | 51 | val aspectConfiguration = project.configurations.maybeCreate("aspects") 52 | 53 | val compileAspect = project.taskHelper("compileAspect") { 54 | inpath = project.files(preWeaveJavaDir, preWeaveKotlinDir) 55 | this.ajcConfiguration = ajcConfiguration 56 | aspectPath = aspectConfiguration.asFileTree 57 | classpath = mainSourceSet.compileClasspath 58 | destDir = oldCompileJavaDestinationDir 59 | dependsOn(setOf(compileJava, compileKotlin).filterNotNull()) 60 | } 61 | 62 | val classesTask = project.tasks.getByName("classes") 63 | classesTask.dependsOn(compileAspect) 64 | } 65 | } 66 | 67 | 68 | inline private fun Project.taskHelper(name: String, noinline configuration: T.() -> Unit): T { 69 | return this.tasks.create(name, T::class.java, configuration)!! 70 | } 71 | } -------------------------------------------------------------------------------- /plugin/src/main/resources/META-INF/gradle-plugins/org.jlleitschuh.gradle.kotlin-aspectj.properties: -------------------------------------------------------------------------------- 1 | implementation-class=org.jlleitschuh.gradle.aspectj.AspectjPlugin -------------------------------------------------------------------------------- /samples/README.md: -------------------------------------------------------------------------------- 1 | Contains an example project that uses the plugin. 2 | -------------------------------------------------------------------------------- /samples/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JLLeitschuh/gradle-kotlin-aspectj-weaver/0c504c477b0993509823735654fdfb801f10495d/samples/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /samples/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-all.zip 6 | -------------------------------------------------------------------------------- /samples/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /samples/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /samples/java-only/java-only.gradle.kts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JLLeitschuh/gradle-kotlin-aspectj-weaver/0c504c477b0993509823735654fdfb801f10495d/samples/java-only/java-only.gradle.kts -------------------------------------------------------------------------------- /samples/java-only/src/main/java/example/JavaTestAspect.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | import org.aspectj.lang.annotation.Around; 5 | import org.aspectj.lang.annotation.Aspect; 6 | import org.aspectj.lang.annotation.Pointcut; 7 | 8 | @Aspect 9 | public class JavaTestAspect { 10 | 11 | @Around("pointcutSayMessage()") 12 | public Object adviceSayMessage(final ProceedingJoinPoint call) throws Throwable { 13 | System.out.println("Test"); 14 | StaticStateVariable.wasAspectCalled = true; 15 | return call.proceed(); 16 | } 17 | 18 | @Pointcut("execution(static void MyApp.sayHi*(..))") 19 | public void pointcutSayMessage() { 20 | // No code required here 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/java-only/src/main/java/example/MyApp.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class MyApp { 4 | 5 | public static void sayHi() { 6 | System.out.println("Hello World!"); 7 | } 8 | 9 | public static void main(final String... args) { 10 | sayHi(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples/java-only/src/main/java/example/StaticStateVariable.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class StaticStateVariable { 4 | static boolean wasAspectCalled = false; 5 | } 6 | -------------------------------------------------------------------------------- /samples/java-only/src/test/java/example/MyAppTest.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import org.junit.Test; 6 | 7 | public class MyAppTest { 8 | 9 | @Test 10 | public void testThatAspectIsCalled() { 11 | MyApp.sayHi(); 12 | assertTrue("The aspect was not called", StaticStateVariable.wasAspectCalled); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/kotlin/kotlin.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") 3 | } 4 | 5 | dependencies { 6 | compile(kotlin("stdlib")) 7 | } -------------------------------------------------------------------------------- /samples/kotlin/out/production/classes/META-INF/kotlin.kotlin_module: -------------------------------------------------------------------------------- 1 |  2 |  3 | exampleMainKt -------------------------------------------------------------------------------- /samples/kotlin/src/main/java/example/KotlinTestAspect.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | import org.aspectj.lang.annotation.Around; 5 | import org.aspectj.lang.annotation.Aspect; 6 | import org.aspectj.lang.annotation.Pointcut; 7 | 8 | @Aspect 9 | public class KotlinTestAspect { 10 | 11 | @Around("pointcutSayMessage()") 12 | public Object adviceSayMessage(final ProceedingJoinPoint call) throws Throwable { 13 | System.out.println("Test"); 14 | StaticStateVariable.INSTANCE.setWasSayHiAspectCalled(true); 15 | final Object returned = call.proceed(); 16 | return returned; 17 | } 18 | 19 | @Pointcut("execution(static String MyApp.sayHi*(..))") 20 | public void pointcutSayMessage() { 21 | // No code required here 22 | } 23 | 24 | @Around("pointcutReturnNothing()") 25 | public Object adviceReturnNothing(final ProceedingJoinPoint call) throws Throwable { 26 | StaticStateVariable.INSTANCE.setWasReturnNothingAspectCalled(true); 27 | return call.proceed(); 28 | } 29 | 30 | @Pointcut("execution(static void MyApp.returnNothing*(..))") 31 | public void pointcutReturnNothing() { 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /samples/kotlin/src/main/kotlin/example/Main.kt: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | object StaticStateVariable { 4 | var wasSayHiAspectCalled = false 5 | var wasReturnNothingAspectCalled = false 6 | } 7 | 8 | object MyApp { 9 | @JvmStatic 10 | fun sayHi() : String { 11 | println("Well hello there!") 12 | return "Hi!" 13 | } 14 | 15 | @JvmStatic 16 | fun returnNothing() { 17 | // Do nothing here either 18 | } 19 | } 20 | 21 | fun main(vararg args : String) { 22 | MyApp.sayHi() 23 | println("Hello World") 24 | } -------------------------------------------------------------------------------- /samples/kotlin/src/test/kotlin/example/MyAppTest.kt: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import junit.framework.Assert.assertTrue 4 | import org.junit.Test 5 | 6 | class MyAppTest { 7 | @Test 8 | fun `test that aspect is called`() { 9 | MyApp.sayHi() 10 | assertTrue(StaticStateVariable.wasSayHiAspectCalled) 11 | } 12 | 13 | @Test 14 | fun `test that return nothing aspect is called`() { 15 | MyApp.returnNothing() 16 | assertTrue(StaticStateVariable.wasReturnNothingAspectCalled) 17 | } 18 | } -------------------------------------------------------------------------------- /samples/samples.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.gradle.api.tasks.testing.logging.TestExceptionFormat 2 | 3 | buildscript { 4 | dependencies { 5 | classpath("org.jlleitschuh.aspectj:kotlin-aspectj-weaver:+") 6 | } 7 | } 8 | 9 | allprojects { 10 | repositories { 11 | mavenCentral() 12 | } 13 | } 14 | 15 | subprojects { 16 | apply { 17 | plugin("org.jlleitschuh.gradle.kotlin-aspectj") 18 | plugin("java") 19 | } 20 | val aspectJversion = "1.8.10" 21 | 22 | dependencies { 23 | "ajc"(create(group = "org.aspectj", name = "aspectjtools", version = aspectJversion)) 24 | "compile"(create(group = "org.aspectj", name = "aspectjweaver", version = aspectJversion)) 25 | "testCompile"(create(group = "junit", name = "junit", version = "4.12")) 26 | } 27 | 28 | tasks.withType { 29 | testLogging { 30 | exceptionFormat = TestExceptionFormat.FULL 31 | } 32 | } 33 | } 34 | 35 | task("wrapper") { 36 | gradleVersion = "4.2" 37 | distributionType = Wrapper.DistributionType.ALL 38 | } 39 | 40 | -------------------------------------------------------------------------------- /samples/samples.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/settings.gradle: -------------------------------------------------------------------------------- 1 | include ":java-only" 2 | include ":kotlin" 3 | 4 | includeBuild("../plugin") 5 | 6 | void configureBuildFileName(ProjectDescriptor project) { 7 | /* 8 | * Instead of every file being named build.gradle.kts we instead use the name ${project.name}.gradle.kts. 9 | * This is much nicer for searching for the file in your IDE. 10 | */ 11 | final String groovyName = "${project.name}.gradle" 12 | final String kotlinName = "${project.name}.gradle.kts" 13 | project.buildFileName = groovyName 14 | if (!project.buildFile.isFile()) { 15 | project.buildFileName = kotlinName 16 | } 17 | assert project.buildFile.isFile() : "File named $groovyName or $kotlinName must exist." 18 | project.children.each { configureBuildFileName(it) } 19 | } 20 | configureBuildFileName(rootProject) 21 | 22 | 23 | --------------------------------------------------------------------------------