├── .editorconfig ├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ ├── build.yml │ ├── release.yml │ └── verify.yml ├── .gitignore ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── encodings.xml ├── inspectionProfiles │ ├── GantSign.xml │ └── profiles_settings.xml ├── kotlinc.xml ├── misc.xml ├── saveactions_settings.xml └── vcs.xml ├── .lift.toml ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── LICENSE ├── README.md ├── kotlin-maven-plugin-tools ├── pom.xml └── src │ ├── it │ └── basic │ │ ├── pom.xml │ │ ├── postbuild.groovy │ │ └── src │ │ └── main │ │ └── kotlin │ │ └── com │ │ └── example │ │ └── ExampleMojo.kt │ ├── main │ └── kotlin │ │ └── com │ │ └── github │ │ └── gantsign │ │ └── maven │ │ └── tools │ │ └── plugin │ │ └── extractor │ │ └── kotlin │ │ ├── KotlinMojoDescriptorExtractor.kt │ │ └── internal │ │ ├── AnnotationScanner.kt │ │ ├── SourceScanner.kt │ │ ├── kotlinc │ │ ├── KotlinModelConversion.kt │ │ ├── KotlinSourceScanner.kt │ │ └── MavenMessageCollector.kt │ │ ├── model │ │ ├── ClassDoc.kt │ │ ├── DocTag.kt │ │ ├── PropertyDoc.kt │ │ └── SourceScanRequest.kt │ │ └── qdox │ │ ├── QDoxModelConversion.kt │ │ └── QDoxSourceScanner.kt │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── maven │ │ └── tools │ │ └── plugin │ │ └── extractor │ │ └── annotations │ │ └── examples │ │ ├── ExtendsExternalMojo.java │ │ ├── ExtendsLocalMojo.java │ │ ├── LocalMojo.java │ │ └── MinimalMojo.java │ ├── kotlin │ └── com │ │ └── github │ │ └── gantsign │ │ └── maven │ │ └── tools │ │ └── plugin │ │ └── extractor │ │ └── kotlin │ │ ├── DescriptorExtractorTest.kt │ │ ├── examples │ │ ├── KotlinExtendsLocalMojo.kt │ │ └── KotlinMojo.kt │ │ └── internal │ │ └── kotlinc │ │ └── MavenMessageCollectorTest.kt │ └── resources │ └── pom.xml ├── mvnw ├── mvnw.cmd └── pom.xml /.editorconfig: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # kotlin-maven-plugin-tools 4 | # %% 5 | # Copyright (C) 2018 GantSign Ltd. 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | # EditorConfig: http://EditorConfig.org 21 | 22 | # Top-most EditorConfig file 23 | root = true 24 | 25 | # Defaults for all editor files 26 | [*] 27 | insert_final_newline = true 28 | indent_style = space 29 | indent_size = 4 30 | continuation_indent_size = 8 31 | trim_trailing_whitespace = true 32 | max_line_length=120 33 | 34 | # YAML is fussy about indenting and charset 35 | [*.yml] 36 | indent_style = space 37 | indent_size = 2 38 | continuation_indent_size = unset 39 | charset = utf-8 40 | 41 | # YAML is fussy about indenting 42 | [*.md] 43 | indent_style = space 44 | indent_size = 4 45 | trim_trailing_whitespaces = false 46 | 47 | # Follow Kotlin Coding Conventions 48 | [*.{kt,kts}] 49 | indent_size=4 50 | continuation_indent_size=4 51 | charset = utf-8 52 | ij_kotlin_imports_layout = * 53 | 54 | # Files with a smaller indent 55 | [*.{java,xml}] 56 | indent_size = 2 57 | continuation_indent_size = 4 58 | 59 | # Java file encoding 60 | [*.java] 61 | charset = utf-8 62 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # kotlin-maven-plugin-tools 4 | # %% 5 | # Copyright (C) 2018 GantSign Ltd. 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | # Set the default behavior, in case people don't have core.autocrlf set. 21 | * text=auto 22 | 23 | # Explicitly declare text files you want to always be normalized and converted 24 | # to native line endings on checkout. 25 | .gitignore text 26 | .gitattributes text 27 | *.xml text 28 | *.yml text 29 | *.yaml text 30 | *.json text 31 | *.toml text 32 | *.txt text 33 | *.md text 34 | *.htm text 35 | *.html text 36 | *.xhtml text 37 | *.js text 38 | *.css text 39 | *.java text 40 | *.kt text 41 | *.kts text 42 | *.properties text 43 | 44 | # Declare files that will always have CRLF line endings on checkout. 45 | *.bat text eol=crlf 46 | *.cmd text eol=crlf 47 | 48 | # Declare files that will always have LF line endings on checkout. 49 | *.sh text eol=lf 50 | 51 | # Denote all files that are truly binary and should not be modified. 52 | *.png binary 53 | *.jpg binary 54 | *.jpeg binary 55 | *.gif binary 56 | *.jar binary 57 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: maven 4 | directory: "/" 5 | schedule: 6 | interval: weekly 7 | day: saturday 8 | open-pull-requests-limit: 10 9 | - package-ecosystem: github-actions 10 | directory: "/" 11 | schedule: 12 | interval: weekly 13 | day: saturday 14 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: 3 | push: 4 | branches: 5 | - main 6 | 7 | jobs: 8 | build: 9 | name: Build 10 | uses: gantsign/workflows/.github/workflows/maven-build.yml@v1 11 | with: 12 | java-version: '11' 13 | 14 | deploy: 15 | name: Deploy 16 | needs: build 17 | if: github.repository == 'gantsign/kotlin-maven-plugin-tools' 18 | uses: gantsign/workflows/.github/workflows/maven-deploy.yml@v1 19 | with: 20 | java-version: '11' 21 | secrets: inherit 22 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | release: 4 | types: 5 | - published 6 | 7 | jobs: 8 | build: 9 | name: Build 10 | uses: gantsign/workflows/.github/workflows/maven-build.yml@v1 11 | with: 12 | java-version: '11' 13 | 14 | deploy: 15 | name: Deploy 16 | needs: build 17 | if: github.repository == 'gantsign/kotlin-maven-plugin-tools' 18 | uses: gantsign/workflows/.github/workflows/maven-deploy.yml@v1 19 | with: 20 | java-version: '11' 21 | secrets: inherit 22 | -------------------------------------------------------------------------------- /.github/workflows/verify.yml: -------------------------------------------------------------------------------- 1 | name: Verify 2 | 3 | on: 4 | pull_request: {} 5 | 6 | jobs: 7 | build: 8 | name: Build 9 | uses: gantsign/workflows/.github/workflows/maven-build.yml@v1 10 | with: 11 | java-version: '11' 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/windows,linux,osx,vim,emacs,visualstudiocode,intellij,eclipse,netbeans,maven,java 2 | # Edit at https://www.gitignore.io/?templates=windows,linux,osx,vim,emacs,visualstudiocode,intellij,eclipse,netbeans,maven,java 3 | 4 | ### Eclipse ### 5 | .metadata 6 | bin/ 7 | tmp/ 8 | *.tmp 9 | *.bak 10 | *.swp 11 | *~.nib 12 | local.properties 13 | .settings/ 14 | .loadpath 15 | .recommenders 16 | 17 | # External tool builders 18 | .externalToolBuilders/ 19 | 20 | # Locally stored "Eclipse launch configurations" 21 | *.launch 22 | 23 | # PyDev specific (Python IDE for Eclipse) 24 | *.pydevproject 25 | 26 | # CDT-specific (C/C++ Development Tooling) 27 | .cproject 28 | 29 | # CDT- autotools 30 | .autotools 31 | 32 | # Java annotation processor (APT) 33 | .factorypath 34 | 35 | # PDT-specific (PHP Development Tools) 36 | .buildpath 37 | 38 | # sbteclipse plugin 39 | .target 40 | 41 | # Tern plugin 42 | .tern-project 43 | 44 | # TeXlipse plugin 45 | .texlipse 46 | 47 | # STS (Spring Tool Suite) 48 | .springBeans 49 | 50 | # Code Recommenders 51 | .recommenders/ 52 | 53 | # Annotation Processing 54 | .apt_generated/ 55 | .apt_generated_test/ 56 | 57 | # Scala IDE specific (Scala & Java development for Eclipse) 58 | .cache-main 59 | .scala_dependencies 60 | .worksheet 61 | 62 | # Uncomment this line if you wish to ignore the project description file. 63 | # Typically, this file would be tracked if it contains build/dependency configurations: 64 | #.project 65 | 66 | ### Eclipse Patch ### 67 | # Spring Boot Tooling 68 | .sts4-cache/ 69 | 70 | ### Emacs ### 71 | # -*- mode: gitignore; -*- 72 | *~ 73 | \#*\# 74 | /.emacs.desktop 75 | /.emacs.desktop.lock 76 | *.elc 77 | auto-save-list 78 | tramp 79 | .\#* 80 | 81 | # Org-mode 82 | .org-id-locations 83 | *_archive 84 | 85 | # flymake-mode 86 | *_flymake.* 87 | 88 | # eshell files 89 | /eshell/history 90 | /eshell/lastdir 91 | 92 | # elpa packages 93 | /elpa/ 94 | 95 | # reftex files 96 | *.rel 97 | 98 | # AUCTeX auto folder 99 | /auto/ 100 | 101 | # cask packages 102 | .cask/ 103 | dist/ 104 | 105 | # Flycheck 106 | flycheck_*.el 107 | 108 | # server auth directory 109 | /server/ 110 | 111 | # projectiles files 112 | .projectile 113 | 114 | # directory configuration 115 | .dir-locals.el 116 | 117 | # network security 118 | /network-security.data 119 | 120 | 121 | ### Intellij ### 122 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 123 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 124 | 125 | # User-specific stuff 126 | .idea/**/workspace.xml 127 | .idea/**/tasks.xml 128 | .idea/**/usage.statistics.xml 129 | .idea/**/dictionaries 130 | .idea/**/shelf 131 | 132 | # AWS User-specific 133 | .idea/**/aws.xml 134 | 135 | # Generated files 136 | .idea/**/contentModel.xml 137 | 138 | # Sensitive or high-churn files 139 | .idea/**/dataSources/ 140 | .idea/**/dataSources.ids 141 | .idea/**/dataSources.local.xml 142 | .idea/**/sqlDataSources.xml 143 | .idea/**/dynamic.xml 144 | .idea/**/uiDesigner.xml 145 | .idea/**/dbnavigator.xml 146 | 147 | # Gradle 148 | .idea/**/gradle.xml 149 | .idea/**/libraries 150 | 151 | # Gradle and Maven with auto-import 152 | # When using Gradle or Maven with auto-import, you should exclude module files, 153 | # since they will be recreated, and may cause churn. Uncomment if using 154 | # auto-import. 155 | # .idea/artifacts 156 | # .idea/compiler.xml 157 | # .idea/jarRepositories.xml 158 | # .idea/modules.xml 159 | # .idea/*.iml 160 | # .idea/modules 161 | # *.iml 162 | # *.ipr 163 | 164 | # CMake 165 | cmake-build-*/ 166 | 167 | # Mongo Explorer plugin 168 | .idea/**/mongoSettings.xml 169 | 170 | # File-based project format 171 | *.iws 172 | 173 | # IntelliJ 174 | out/ 175 | 176 | # mpeltonen/sbt-idea plugin 177 | .idea_modules/ 178 | 179 | # JIRA plugin 180 | atlassian-ide-plugin.xml 181 | 182 | # Cursive Clojure plugin 183 | .idea/replstate.xml 184 | 185 | # SonarLint plugin 186 | .idea/sonarlint/ 187 | 188 | # Crashlytics plugin (for Android Studio and IntelliJ) 189 | com_crashlytics_export_strings.xml 190 | crashlytics.properties 191 | crashlytics-build.properties 192 | fabric.properties 193 | 194 | # Editor-based Rest Client 195 | .idea/httpRequests 196 | 197 | # Android studio 3.1+ serialized cache file 198 | .idea/caches/build_file_checksums.ser 199 | 200 | ### Intellij Patch ### 201 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 202 | 203 | # *.iml 204 | # modules.xml 205 | # .idea/misc.xml 206 | # *.ipr 207 | 208 | # Sonarlint plugin 209 | # https://plugins.jetbrains.com/plugin/7973-sonarlint 210 | .idea/**/sonarlint/ 211 | 212 | # SonarQube Plugin 213 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin 214 | .idea/**/sonarIssues.xml 215 | 216 | # Markdown Navigator plugin 217 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced 218 | .idea/**/markdown-navigator.xml 219 | .idea/**/markdown-navigator-enh.xml 220 | .idea/**/markdown-navigator/ 221 | 222 | # Cache file creation bug 223 | # See https://youtrack.jetbrains.com/issue/JBR-2257 224 | .idea/$CACHE_FILE$ 225 | 226 | # CodeStream plugin 227 | # https://plugins.jetbrains.com/plugin/12206-codestream 228 | .idea/codestream.xml 229 | 230 | # Azure Toolkit for IntelliJ plugin 231 | # https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij 232 | .idea/**/azureSettings.xml 233 | 234 | ### Java ### 235 | # Compiled class file 236 | *.class 237 | 238 | # Log file 239 | *.log 240 | 241 | # BlueJ files 242 | *.ctxt 243 | 244 | # Mobile Tools for Java (J2ME) 245 | .mtj.tmp/ 246 | 247 | # Package Files # 248 | *.jar 249 | *.war 250 | *.nar 251 | *.ear 252 | *.zip 253 | *.tar.gz 254 | *.rar 255 | 256 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 257 | hs_err_pid* 258 | replay_pid* 259 | 260 | ### Linux ### 261 | 262 | # temporary files which can be created if a process still has a handle open of a deleted file 263 | .fuse_hidden* 264 | 265 | # KDE directory preferences 266 | .directory 267 | 268 | # Linux trash folder which might appear on any partition or disk 269 | .Trash-* 270 | 271 | # .nfs files are created when an open file is removed but is still being accessed 272 | .nfs* 273 | 274 | ### Maven ### 275 | target/ 276 | pom.xml.tag 277 | pom.xml.releaseBackup 278 | pom.xml.versionsBackup 279 | pom.xml.next 280 | release.properties 281 | dependency-reduced-pom.xml 282 | buildNumber.properties 283 | .mvn/timing.properties 284 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar 285 | .mvn/wrapper/maven-wrapper.jar 286 | 287 | # Eclipse m2e generated files 288 | # Eclipse Core 289 | .project 290 | # JDT-specific (Eclipse Java Development Tools) 291 | .classpath 292 | 293 | ### NetBeans ### 294 | **/nbproject/private/ 295 | **/nbproject/Makefile-*.mk 296 | **/nbproject/Package-*.bash 297 | build/ 298 | nbbuild/ 299 | nbdist/ 300 | .nb-gradle/ 301 | 302 | ### OSX ### 303 | # General 304 | .DS_Store 305 | .AppleDouble 306 | .LSOverride 307 | 308 | # Icon must end with two \r 309 | Icon 310 | 311 | 312 | # Thumbnails 313 | ._* 314 | 315 | # Files that might appear in the root of a volume 316 | .DocumentRevisions-V100 317 | .fseventsd 318 | .Spotlight-V100 319 | .TemporaryItems 320 | .Trashes 321 | .VolumeIcon.icns 322 | .com.apple.timemachine.donotpresent 323 | 324 | # Directories potentially created on remote AFP share 325 | .AppleDB 326 | .AppleDesktop 327 | Network Trash Folder 328 | Temporary Items 329 | .apdisk 330 | 331 | ### Vim ### 332 | # Swap 333 | [._]*.s[a-v][a-z] 334 | !*.svg # comment out if you don't need vector files 335 | [._]*.sw[a-p] 336 | [._]s[a-rt-v][a-z] 337 | [._]ss[a-gi-z] 338 | [._]sw[a-p] 339 | 340 | # Session 341 | Session.vim 342 | Sessionx.vim 343 | 344 | # Temporary 345 | .netrwhist 346 | # Auto-generated tag files 347 | tags 348 | # Persistent undo 349 | [._]*.un~ 350 | 351 | ### VisualStudioCode ### 352 | .vscode/* 353 | !.vscode/settings.json 354 | !.vscode/tasks.json 355 | !.vscode/launch.json 356 | !.vscode/extensions.json 357 | !.vscode/*.code-snippets 358 | 359 | # Local History for Visual Studio Code 360 | .history/ 361 | 362 | # Built Visual Studio Code Extensions 363 | *.vsix 364 | 365 | ### VisualStudioCode Patch ### 366 | # Ignore all local history of files 367 | .history 368 | .ionide 369 | 370 | # Support for Project snippet scope 371 | .vscode/*.code-snippets 372 | 373 | # Ignore code-workspaces 374 | *.code-workspace 375 | 376 | ### Windows ### 377 | # Windows thumbnail cache files 378 | Thumbs.db 379 | Thumbs.db:encryptable 380 | ehthumbs.db 381 | ehthumbs_vista.db 382 | 383 | # Dump file 384 | *.stackdump 385 | 386 | # Folder config file 387 | [Dd]esktop.ini 388 | 389 | # Recycle Bin used on file shares 390 | $RECYCLE.BIN/ 391 | 392 | # Windows Installer files 393 | *.cab 394 | *.msi 395 | *.msix 396 | *.msm 397 | *.msp 398 | 399 | # Windows shortcuts 400 | *.lnk 401 | 402 | # End of https://www.gitignore.io/api/windows,linux,osx,vim,emacs,visualstudiocode,intellij,eclipse,netbeans,maven,java 403 | 404 | ### Project additions ### 405 | 406 | # Gradle and Maven with auto-import 407 | # When using Gradle or Maven with auto-import, you should exclude module files, 408 | # since they will be recreated, and may cause churn. Uncomment if using 409 | # auto-import. 410 | .idea/artifacts 411 | .idea/compiler.xml 412 | .idea/jarRepositories.xml 413 | .idea/modules.xml 414 | .idea/*.iml 415 | .idea/modules 416 | *.iml 417 | *.ipr 418 | 419 | # Flattened POM 420 | .flattened-pom.xml 421 | 422 | # Non-Java project 423 | /.idea/checkstyle-idea.xml 424 | /.idea/google-java-format.xml 425 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 538 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /.idea/saveactions_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 26 | 27 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.lift.toml: -------------------------------------------------------------------------------- 1 | build = "mvn" 2 | jdkVersion = "11" 3 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gantsign/kotlin-maven-plugin-tools/03d9e30a55548c9c03bfca3e75f12121fe21cb90/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip 18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kotlin Maven Plugin Tools 2 | 3 | [![Release](https://github.com/gantsign/kotlin-maven-plugin-tools/workflows/Build/badge.svg)](https://github.com/gantsign/kotlin-maven-plugin-tools/actions?query=workflow%3ABuild) 4 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.gantsign.maven.plugin-tools/kotlin-maven-plugin-tools/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.gantsign.maven.plugin-tools/kotlin-maven-plugin-tools) 5 | [![codecov](https://codecov.io/gh/gantsign/kotlin-maven-plugin-tools/branch/main/graph/badge.svg)](https://codecov.io/gh/gantsign/kotlin-maven-plugin-tools) 6 | [![Known Vulnerabilities](https://snyk.io/test/github/gantsign/kotlin-maven-plugin-tools/badge.svg)](https://snyk.io/test/github/gantsign/kotlin-maven-plugin-tools) 7 | 8 | Maven plugin metadata extractor for plugins written in Kotlin. 9 | 10 | **This project is still a little new, so please help by reporting any issues you find.** 11 | 12 | ## Maven plugin support for Kotlin 13 | 14 | The [Java5 annotation metadata extractor](https://maven.apache.org/plugin-tools/maven-plugin-tools-annotations/index.html) 15 | partially works for Kotlin files. It's able to pull all the information from the 16 | annotations; the problem is the descriptions, deprecation messages and since 17 | version information, is still extracted from the JavaDoc, and this doesn't work 18 | for Kotlin files; the generated web site and the command line help are far less 19 | useful without descriptions. 20 | 21 | This project provides a Kotlin metadata extractor using the Kotlin compiler to 22 | give the same support for Kotlin files, as the Java5 annotation extractor does 23 | for Java files (including support for descriptions and since version 24 | information from KDoc, and deprecation messages from `@kotlin.Deprecated`). 25 | 26 | ## Writing a Maven Plugin in Kotlin 27 | 28 | Writing a Maven plugin in Kotlin (using this extractor) is much the same as it 29 | normally is in Java; you extend `org.apache.maven.plugin.AbstractMojo`, annotate 30 | the class and properties, and add descriptions in API code comments. However as 31 | Kotlin has nullability constraints in the type system, you need to declare 32 | whether properties can be `null` or not; you can use `lateinit` for the non-null 33 | properties. 34 | 35 | It's important that the nullability of the properties matches the value of 36 | the `required` attribute of the 37 | `org.apache.maven.plugins.annotations.Parameter` annotation, or you may get 38 | unfriendly errors at runtime. 39 | 40 | ```kotlin 41 | package com.example 42 | 43 | import org.apache.maven.plugin.AbstractMojo 44 | import org.apache.maven.plugins.annotations.Mojo 45 | import org.apache.maven.plugins.annotations.Parameter 46 | 47 | /** 48 | * Example description. 49 | */ 50 | @Mojo(name = "example") 51 | class ExampleMojo : AbstractMojo() { 52 | 53 | /** 54 | * Optional parameter description. 55 | */ 56 | @Deprecated("Example optional parameter deprecated message.") 57 | @Parameter(name = "optionalParameter") 58 | var optionalParameter: String? = null 59 | 60 | /** 61 | * Required parameter description. 62 | * 63 | * @since 1.1 64 | */ 65 | @Parameter(name = "requiredParameter", required = true) 66 | lateinit var requiredParameter: String 67 | 68 | override fun execute() { 69 | // Perform plugin action here 70 | } 71 | } 72 | ``` 73 | 74 | Your POM will include the following: 75 | 76 | ```xml 77 | 78 | 81 | 4.0.0 82 | 83 | com.example 84 | example-maven-plugin 85 | 1.0.0-SNAPSHOT 86 | 87 | maven-plugin 88 | 89 | 90 | ${maven.version} 91 | 92 | 93 | 94 | 1.7.10 95 | 1.8 96 | 1.8 97 | 3.6.3 98 | UTF-8 99 | UTF-8 100 | 101 | 102 | 103 | 104 | org.apache.maven 105 | maven-core 106 | ${maven.version} 107 | 108 | 109 | org.apache.maven 110 | maven-plugin-api 111 | ${maven.version} 112 | 113 | 114 | org.jetbrains.kotlin 115 | kotlin-stdlib-jdk8 116 | ${kotlin.version} 117 | 118 | 119 | org.apache.maven.plugin-tools 120 | maven-plugin-annotations 121 | 3.6.4 122 | provided 123 | 124 | 125 | org.jetbrains.kotlin 126 | kotlin-test-junit 127 | ${kotlin.version} 128 | test 129 | 130 | 131 | 132 | 133 | src/main/kotlin 134 | src/test/kotlin 135 | 136 | 137 | org.apache.maven.plugins 138 | maven-plugin-plugin 139 | 3.6.4 140 | 141 | 142 | 146 | kotlin 147 | 148 | 149 | 150 | 151 | 152 | com.github.gantsign.maven.plugin-tools 153 | kotlin-maven-plugin-tools 154 | 155 | @version@ 156 | 157 | 158 | 159 | 160 | default-descriptor 161 | process-classes 162 | 163 | 164 | help-goal 165 | 166 | helpmojo 167 | 168 | 169 | 170 | 171 | 172 | org.jetbrains.kotlin 173 | kotlin-maven-plugin 174 | ${kotlin.version} 175 | 176 | 1.8 177 | 178 | 179 | 180 | compile 181 | 182 | compile 183 | 184 | process-sources 185 | 186 | 187 | test-compile 188 | 189 | test-compile 190 | 191 | test-compile 192 | 193 | 194 | 195 | 196 | 197 | 198 | ``` 199 | 200 | License 201 | ------- 202 | 203 | This software is licensed under the terms in the file named "LICENSE" in the 204 | root directory of this project. This project has dependencies that are under 205 | different licenses. 206 | 207 | Author Information 208 | ------------------ 209 | 210 | John Freeman 211 | 212 | GantSign Ltd. 213 | Company No. 06109112 (registered in England) 214 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 4.0.0 23 | 24 | 25 | com.github.gantsign.maven.plugin-tools 26 | kotlin-maven-plugin-tools-parent 27 | ${revision} 28 | ../pom.xml 29 | 30 | 31 | kotlin-maven-plugin-tools 32 | 33 | Kotlin Maven Plugin Tools 34 | Extractor for plugins written in Kotlin. 35 | 36 | 37 | 38 | com.thoughtworks.qdox 39 | qdox 40 | 41 | 42 | javax.inject 43 | javax.inject 44 | 45 | 46 | org.apache.maven 47 | maven-artifact 48 | 49 | 50 | org.apache.maven 51 | maven-core 52 | 53 | 54 | 55 | com.google.inject 56 | guice 57 | 58 | 59 | 60 | 61 | org.apache.maven 62 | maven-model 63 | 64 | 65 | org.apache.maven 66 | maven-plugin-api 67 | 68 | 69 | org.apache.maven.plugin-tools 70 | maven-plugin-annotations 71 | 72 | 73 | org.apache.maven.plugin-tools 74 | maven-plugin-tools-annotations 75 | 76 | 77 | 78 | org.apache.maven 79 | maven-project 80 | 81 | 82 | 83 | org.apache.maven 84 | maven-plugin-descriptor 85 | 86 | 87 | 88 | 89 | org.apache.maven.plugin-tools 90 | maven-plugin-tools-api 91 | 92 | 93 | 94 | org.apache.maven 95 | maven-project 96 | 97 | 98 | 99 | org.codehaus.plexus 100 | plexus-container-default 101 | 102 | 103 | 104 | org.apache.maven 105 | maven-plugin-descriptor 106 | 107 | 108 | 109 | 110 | org.codehaus.plexus 111 | plexus-archiver 112 | 113 | 114 | org.codehaus.plexus 115 | plexus-compiler-manager 116 | 117 | 118 | org.eclipse.sisu 119 | org.eclipse.sisu.plexus 120 | 121 | 122 | 123 | javax.annotation 124 | jsr250-api 125 | 126 | 127 | 128 | 129 | org.jetbrains 130 | annotations 131 | 132 | 133 | org.jetbrains 134 | markdown-jvm 135 | 136 | 137 | org.jetbrains.kotlin 138 | kotlin-compiler-embeddable 139 | 140 | 141 | javax.annotation 142 | javax.annotation-api 143 | runtime 144 | 145 | 146 | org.slf4j 147 | log4j-over-slf4j 148 | runtime 149 | 150 | 151 | com.google.inject 152 | guice 153 | test 154 | 155 | 156 | io.mockk 157 | mockk-jvm 158 | test 159 | 160 | 161 | org.junit.jupiter 162 | junit-jupiter 163 | 164 | 165 | 166 | 167 | junit 168 | junit 169 | test 170 | 171 | 172 | org.apache.maven 173 | maven-compat 174 | test 175 | 176 | 177 | org.apache.maven.plugin-testing 178 | maven-plugin-testing-harness 179 | test 180 | 181 | 182 | 183 | org.codehaus.plexus 184 | plexus-container-default 185 | 186 | 187 | 188 | 189 | org.apache.maven.plugins 190 | maven-jar-plugin 191 | test 192 | 193 | 194 | org.apache.maven.resolver 195 | maven-resolver-api 196 | test 197 | 198 | 199 | org.apache.maven.resolver 200 | maven-resolver-connector-basic 201 | test 202 | 203 | 204 | org.apache.maven.resolver 205 | maven-resolver-impl 206 | test 207 | 208 | 209 | org.apache.maven.resolver 210 | maven-resolver-transport-file 211 | test 212 | 213 | 214 | org.apache.maven.resolver 215 | maven-resolver-transport-http 216 | test 217 | 218 | 219 | org.assertj 220 | assertj-core 221 | test 222 | 223 | 224 | org.jetbrains.kotlin 225 | kotlin-test-junit 226 | test 227 | 228 | 229 | org.slf4j 230 | slf4j-simple 231 | test 232 | 233 | 234 | 235 | 236 | 237 | 238 | org.apache.maven.plugins 239 | maven-invoker-plugin 240 | 241 | 242 | integration-test 243 | 244 | install 245 | run 246 | 247 | 248 | 249 | 250 | 251 | org.eclipse.sisu 252 | sisu-maven-plugin 253 | 254 | 255 | generate-index 256 | 257 | main-index 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/it/basic/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 4.0.0 23 | 24 | com.example 25 | example-maven-plugin 26 | 1.0.0-SNAPSHOT 27 | 28 | maven-plugin 29 | 30 | 31 | ${maven.version} 32 | 33 | 34 | 35 | 1.2.41 36 | 1.8 37 | 1.8 38 | 3.5.3 39 | UTF-8 40 | UTF-8 41 | 42 | 43 | 44 | 45 | org.apache.maven 46 | maven-core 47 | ${maven.version} 48 | 49 | 50 | org.apache.maven 51 | maven-plugin-api 52 | ${maven.version} 53 | 54 | 55 | org.jetbrains.kotlin 56 | kotlin-stdlib-jdk8 57 | ${kotlin.version} 58 | 59 | 60 | org.apache.maven.plugin-tools 61 | maven-plugin-annotations 62 | 3.5.1 63 | provided 64 | 65 | 66 | org.jetbrains.kotlin 67 | kotlin-test-junit 68 | ${kotlin.version} 69 | test 70 | 71 | 72 | 73 | 74 | src/main/kotlin 75 | src/test/kotlin 76 | 77 | 78 | com.github.ekryd.sortpom 79 | sortpom-maven-plugin 80 | 2.8.0 81 | 82 | custom_1 83 | ${project.build.sourceEncoding} 84 | \n 85 | true 86 | 2 87 | true 88 | scope,groupId,artifactId 89 | groupId,artifactId 90 | false 91 | 92 | 93 | 94 | 95 | sort 96 | 97 | verify 98 | 99 | 100 | 101 | 102 | org.apache.maven.plugins 103 | maven-plugin-plugin 104 | 3.5.1 105 | 106 | 107 | kotlin 108 | 109 | 110 | 111 | 112 | @project.groupId@ 113 | @project.artifactId@ 114 | @project.version@ 115 | 116 | 117 | 118 | 119 | default-descriptor 120 | process-classes 121 | 122 | 123 | help-goal 124 | 125 | helpmojo 126 | 127 | 128 | 129 | 130 | 131 | org.jetbrains.kotlin 132 | kotlin-maven-plugin 133 | ${kotlin.version} 134 | 135 | 1.8 136 | 137 | 138 | 139 | compile 140 | 141 | compile 142 | 143 | process-sources 144 | 145 | 146 | test-compile 147 | 148 | test-compile 149 | 150 | test-compile 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/it/basic/postbuild.groovy: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | //noinspection GroovyAssignabilityCheck 21 | File file = new File(basedir, "target/classes/META-INF/maven/plugin.xml") 22 | if (!file.isFile()) { 23 | throw new FileNotFoundException("Could not find generated plugin.xml: $file") 24 | } 25 | def expected = ''' 26 | 27 | 28 | 29 | 30 | 31 | example-maven-plugin 32 | 33 | com.example 34 | example-maven-plugin 35 | 1.0.0-SNAPSHOT 36 | example 37 | false 38 | true 39 | 40 | 41 | example 42 | Example description. 43 | compile 44 | true 45 | false 46 | true 47 | true 48 | true 49 | false 50 | compile 51 | package 52 | compiler 53 | exampleLifecycle 54 | com.example.ExampleMojo 55 | java 56 | exampleConfigurator 57 | singleton 58 | always 59 | exampleVersion 60 | Example deprecated. 61 | runtime 62 | true 63 | 64 | 65 | exampleParameterName 66 | exampleParameterAlias 67 | java.lang.String 68 | exampleParameterVersion 69 | Example parameter deprecated message. 70 | true 71 | true 72 | Example parameter description. 73 | 74 | 75 | 76 | ${exampleParameterProperty} 77 | 78 | 79 | 80 | org.apache.maven.repository.RepositorySystem 81 | exampleComponentHint 82 | exampleComponent 83 | 84 | 85 | 86 | 87 | help 88 | Display help information on example-maven-plugin.<br> 89 | Call <code>mvn example:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</code> to display parameter details. 90 | false 91 | false 92 | false 93 | false 94 | false 95 | true 96 | com.example.HelpMojo 97 | java 98 | per-lookup 99 | once-per-session 100 | true 101 | 102 | 103 | detail 104 | boolean 105 | false 106 | true 107 | If <code>true</code>, display all settable properties for each goal. 108 | 109 | 110 | goal 111 | java.lang.String 112 | false 113 | true 114 | The name of the goal for which to show help. If unspecified, all goals will be displayed. 115 | 116 | 117 | indentSize 118 | int 119 | false 120 | true 121 | The number of spaces per indentation level, should be positive. 122 | 123 | 124 | lineLength 125 | int 126 | false 127 | true 128 | The maximum length of a display line, should be positive. 129 | 130 | 131 | 132 | ${detail} 133 | ${goal} 134 | ${indentSize} 135 | ${lineLength} 136 | 137 | 138 | 139 | 140 | 141 | org.apache.maven 142 | maven-core 143 | jar 144 | 3.5.3 145 | 146 | 147 | org.apache.maven 148 | maven-model 149 | jar 150 | 3.5.3 151 | 152 | 153 | org.apache.maven 154 | maven-settings 155 | jar 156 | 3.5.3 157 | 158 | 159 | org.apache.maven 160 | maven-settings-builder 161 | jar 162 | 3.5.3 163 | 164 | 165 | org.codehaus.plexus 166 | plexus-interpolation 167 | jar 168 | 1.24 169 | 170 | 171 | org.sonatype.plexus 172 | plexus-sec-dispatcher 173 | jar 174 | 1.4 175 | 176 | 177 | org.sonatype.plexus 178 | plexus-cipher 179 | jar 180 | 1.4 181 | 182 | 183 | org.apache.maven 184 | maven-builder-support 185 | jar 186 | 3.5.3 187 | 188 | 189 | org.apache.maven 190 | maven-repository-metadata 191 | jar 192 | 3.5.3 193 | 194 | 195 | org.apache.maven 196 | maven-artifact 197 | jar 198 | 3.5.3 199 | 200 | 201 | org.apache.maven 202 | maven-model-builder 203 | jar 204 | 3.5.3 205 | 206 | 207 | org.apache.maven 208 | maven-resolver-provider 209 | jar 210 | 3.5.3 211 | 212 | 213 | org.apache.maven.resolver 214 | maven-resolver-impl 215 | jar 216 | 1.1.1 217 | 218 | 219 | org.apache.maven.resolver 220 | maven-resolver-api 221 | jar 222 | 1.1.1 223 | 224 | 225 | org.apache.maven.resolver 226 | maven-resolver-spi 227 | jar 228 | 1.1.1 229 | 230 | 231 | org.apache.maven.resolver 232 | maven-resolver-util 233 | jar 234 | 1.1.1 235 | 236 | 237 | org.apache.maven.shared 238 | maven-shared-utils 239 | jar 240 | 3.2.1 241 | 242 | 243 | commons-io 244 | commons-io 245 | jar 246 | 2.5 247 | 248 | 249 | org.eclipse.sisu 250 | org.eclipse.sisu.plexus 251 | jar 252 | 0.3.3 253 | 254 | 255 | javax.enterprise 256 | cdi-api 257 | jar 258 | 1.0 259 | 260 | 261 | javax.annotation 262 | jsr250-api 263 | jar 264 | 1.0 265 | 266 | 267 | org.eclipse.sisu 268 | org.eclipse.sisu.inject 269 | jar 270 | 0.3.3 271 | 272 | 273 | com.google.inject 274 | guice 275 | jar 276 | 4.0 277 | 278 | 279 | aopalliance 280 | aopalliance 281 | jar 282 | 1.0 283 | 284 | 285 | com.google.guava 286 | guava 287 | jar 288 | 20.0 289 | 290 | 291 | javax.inject 292 | javax.inject 293 | jar 294 | 1 295 | 296 | 297 | org.codehaus.plexus 298 | plexus-utils 299 | jar 300 | 3.1.0 301 | 302 | 303 | org.codehaus.plexus 304 | plexus-classworlds 305 | jar 306 | 2.5.2 307 | 308 | 309 | org.codehaus.plexus 310 | plexus-component-annotations 311 | jar 312 | 1.7.1 313 | 314 | 315 | org.apache.commons 316 | commons-lang3 317 | jar 318 | 3.5 319 | 320 | 321 | org.apache.maven 322 | maven-plugin-api 323 | jar 324 | 3.5.3 325 | 326 | 327 | org.jetbrains.kotlin 328 | kotlin-stdlib-jdk8 329 | jar 330 | 1.2.41 331 | 332 | 333 | org.jetbrains.kotlin 334 | kotlin-stdlib 335 | jar 336 | 1.2.41 337 | 338 | 339 | org.jetbrains 340 | annotations 341 | jar 342 | 13.0 343 | 344 | 345 | org.jetbrains.kotlin 346 | kotlin-stdlib-jdk7 347 | jar 348 | 1.2.41 349 | 350 | 351 | '''.trim().normalize() 352 | 353 | def actual = file.getText("UTF-8").trim().normalize() 354 | 355 | assert expected == actual 356 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/it/basic/src/main/kotlin/com/example/ExampleMojo.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.example 21 | 22 | import org.apache.maven.plugin.AbstractMojo 23 | import org.apache.maven.plugins.annotations.Component 24 | import org.apache.maven.plugins.annotations.Execute 25 | import org.apache.maven.plugins.annotations.InstantiationStrategy 26 | import org.apache.maven.plugins.annotations.LifecyclePhase 27 | import org.apache.maven.plugins.annotations.Mojo 28 | import org.apache.maven.plugins.annotations.Parameter 29 | import org.apache.maven.plugins.annotations.ResolutionScope 30 | import org.apache.maven.repository.RepositorySystem 31 | 32 | /** 33 | * Example description. 34 | * 35 | * @since exampleVersion 36 | */ 37 | @SuppressWarnings("ALL") 38 | @Mojo( 39 | name = "example", 40 | defaultPhase = LifecyclePhase.COMPILE, 41 | requiresDependencyResolution = ResolutionScope.COMPILE, 42 | requiresDependencyCollection = ResolutionScope.RUNTIME, 43 | instantiationStrategy = InstantiationStrategy.SINGLETON, 44 | executionStrategy = "always", 45 | requiresProject = false, 46 | requiresReports = true, 47 | aggregator = true, 48 | requiresDirectInvocation = true, 49 | requiresOnline = true, 50 | inheritByDefault = false, 51 | configurator = "exampleConfigurator", 52 | threadSafe = true 53 | ) 54 | @Execute(goal = "compiler", lifecycle = "exampleLifecycle", phase = LifecyclePhase.PACKAGE) 55 | @Deprecated("Example deprecated.") 56 | open class ExampleMojo : AbstractMojo() { 57 | 58 | /** 59 | * Example parameter description. 60 | * 61 | * @since exampleParameterVersion 62 | */ 63 | @Parameter( 64 | name = "exampleParameterName", 65 | alias = "exampleParameterAlias", 66 | property = "exampleParameterProperty", 67 | defaultValue = "exampleParameterDefaultValue", 68 | required = true, 69 | readonly = false 70 | ) 71 | @Deprecated("Example parameter deprecated message.") 72 | var exampleParameter: String? = null 73 | 74 | /** 75 | * Example component description. 76 | * 77 | * @since exampleComponentVersion 78 | */ 79 | @Component(role = RepositorySystem::class, hint = "exampleComponentHint") 80 | @Deprecated("Example component deprecated message.") 81 | var exampleComponent: RepositorySystem? = null 82 | 83 | override fun execute() { 84 | // nothing 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/main/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/KotlinMojoDescriptorExtractor.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin 21 | 22 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.AnnotationScanner 23 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.SourceScanner 24 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.ClassDoc 25 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.DocTag 26 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.PropertyDoc 27 | import javax.inject.Inject 28 | import javax.inject.Named 29 | import org.apache.maven.plugin.descriptor.InvalidParameterException 30 | import org.apache.maven.plugin.descriptor.MojoDescriptor 31 | import org.apache.maven.plugin.descriptor.Parameter 32 | import org.apache.maven.plugin.descriptor.PluginDescriptor 33 | import org.apache.maven.plugin.descriptor.Requirement 34 | import org.apache.maven.repository.RepositorySystem 35 | import org.apache.maven.tools.plugin.ExtendedMojoDescriptor 36 | import org.apache.maven.tools.plugin.PluginToolsRequest 37 | import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor 38 | import org.apache.maven.tools.plugin.extractor.annotations.datamodel.ComponentAnnotationContent 39 | import org.apache.maven.tools.plugin.extractor.annotations.datamodel.ExecuteAnnotationContent 40 | import org.apache.maven.tools.plugin.extractor.annotations.datamodel.ParameterAnnotationContent 41 | import org.apache.maven.tools.plugin.extractor.annotations.scanner.MojoAnnotatedClass 42 | import org.apache.maven.tools.plugin.extractor.annotations.scanner.MojoAnnotationsScanner 43 | import org.apache.maven.tools.plugin.util.PluginUtils 44 | import org.codehaus.plexus.archiver.manager.ArchiverManager 45 | import org.codehaus.plexus.logging.AbstractLogEnabled 46 | 47 | /** 48 | * KotlinDescriptorExtractor, a MojoDescriptor extractor to read descriptors from Kotlin. 49 | */ 50 | @Named("kotlin") 51 | class KotlinMojoDescriptorExtractor @Inject constructor( 52 | private val mojoAnnotationsScanner: MojoAnnotationsScanner, 53 | private val repositorySystem: RepositorySystem, 54 | private val archiverManager: ArchiverManager 55 | ) : AbstractLogEnabled(), MojoDescriptorExtractor { 56 | 57 | override fun execute(request: PluginToolsRequest): List { 58 | val mojoAnnotatedClasses = 59 | AnnotationScanner(mojoAnnotationsScanner).scanAnnotations(request) 60 | 61 | val classDocMap = 62 | SourceScanner(logger, repositorySystem, archiverManager) 63 | .scanSourceDoc(request, mojoAnnotatedClasses.values) 64 | 65 | mojoAnnotatedClasses.populateDataFromJavadoc(classDocMap) 66 | 67 | return mojoAnnotatedClasses.toMojoDescriptors(request.pluginDescriptor) 68 | } 69 | 70 | /** 71 | * Scan sources to get @since and @deprecated and description of classes and properties. 72 | */ 73 | private fun Map.populateDataFromJavadoc( 74 | classDocMap: Map 75 | ) { 76 | val mojoAnnotatedClasses = this 77 | 78 | for ((className, mojoAnnotatedClass) in mojoAnnotatedClasses) { 79 | val classDoc = classDocMap[className] ?: continue 80 | 81 | // populate class-level content 82 | mojoAnnotatedClass.mojo?.also { mojoAnnotationContent -> 83 | mojoAnnotationContent.description = classDoc.comment 84 | 85 | classDoc.findInClassHierarchy("since") 86 | ?.let { mojoAnnotationContent.since = it.value } 87 | 88 | classDoc.findInClassHierarchy("deprecated") 89 | ?.let { mojoAnnotationContent.deprecated = it.value } 90 | } 91 | 92 | val propertyDocMap = classDoc.extractPropertyParameterTags(classDocMap) 93 | 94 | // populate parameters 95 | val parameters: Map = 96 | mojoAnnotatedClass.gatherParametersFromClassHierarchy(mojoAnnotatedClasses) 97 | .toSortedMap() 98 | 99 | for ((propertyName, parameterAnnotationContent) in parameters) { 100 | val propertyDoc = propertyDocMap[propertyName] ?: continue 101 | 102 | parameterAnnotationContent.description = propertyDoc.comment 103 | 104 | propertyDoc.tags["deprecated"] 105 | ?.let { parameterAnnotationContent.deprecated = it.value } 106 | 107 | propertyDoc.tags["since"] 108 | ?.let { parameterAnnotationContent.since = it.value } 109 | } 110 | 111 | // populate components 112 | val components: Map = 113 | mojoAnnotatedClass.components!! 114 | 115 | for ((propertyName, componentAnnotationContent) in components) { 116 | val propertyDoc = propertyDocMap[propertyName] ?: continue 117 | 118 | componentAnnotationContent.description = propertyDoc.comment 119 | 120 | propertyDoc.tags["deprecated"] 121 | ?.let { componentAnnotationContent.deprecated = it.value } 122 | 123 | propertyDoc.tags["since"] 124 | ?.let { componentAnnotationContent.since = it.value } 125 | } 126 | } 127 | } 128 | 129 | private tailrec fun ClassDoc.findInClassHierarchy(tagName: String): DocTag? { 130 | val tag: DocTag? = tags[tagName] 131 | 132 | if (tag != null) return tag 133 | 134 | val superClass: ClassDoc = superClassDoc ?: return null 135 | 136 | return superClass.findInClassHierarchy(tagName) 137 | } 138 | 139 | /** 140 | * Extract properties that are either parameters or components. 141 | * 142 | * @return map with Mojo parameters names as keys. 143 | */ 144 | private tailrec fun ClassDoc.extractPropertyParameterTags( 145 | classDocMap: Map, 146 | descendantParams: Map = mapOf() 147 | ): MutableMap { 148 | val superClass: ClassDoc? = superClassDoc 149 | 150 | val searchSuperClass = when { 151 | superClass == null -> null 152 | superClass.properties.isNotEmpty() -> superClass 153 | else -> { 154 | // maybe sources comes from scan of sources artifact 155 | classDocMap[superClass.fullyQualifiedName] 156 | } 157 | } 158 | 159 | val localParams: Map = properties.associateBy(PropertyDoc::name) 160 | 161 | // the descendant params must overwrite local (parent) params 162 | val mergedParams = localParams.toSortedMap().also { it.putAll(descendantParams) } 163 | if (searchSuperClass == null) { 164 | return mergedParams 165 | } 166 | return searchSuperClass.extractPropertyParameterTags(classDocMap, mergedParams) 167 | } 168 | 169 | private fun Map.toMojoDescriptors( 170 | pluginDescriptor: PluginDescriptor 171 | ): List { 172 | val mojoAnnotatedClasses = this 173 | 174 | return mojoAnnotatedClasses.values 175 | .filter { mojoAnnotatedClass -> 176 | // no mojo so skip it 177 | mojoAnnotatedClass.mojo != null 178 | } 179 | .map { mojoAnnotatedClass -> 180 | mojoAnnotatedClass.toMojoDescriptor(mojoAnnotatedClasses, pluginDescriptor) 181 | } 182 | } 183 | 184 | private fun MojoAnnotatedClass.toMojoDescriptor( 185 | mojoAnnotatedClasses: Map, 186 | pluginDescriptor: PluginDescriptor 187 | ): MojoDescriptor { 188 | val mojoAnnotatedClass = this 189 | 190 | return ExtendedMojoDescriptor().apply { 191 | implementation = mojoAnnotatedClass.className 192 | language = "java" 193 | 194 | val mojo = mojoAnnotatedClass.mojo!! 195 | 196 | description = mojo.description 197 | since = mojo.since 198 | deprecated = mojo.deprecated 199 | 200 | isProjectRequired = mojo.requiresProject() 201 | 202 | isRequiresReports = mojo.requiresReports() 203 | 204 | componentConfigurator = mojo.configurator() 205 | 206 | isInheritedByDefault = mojo.inheritByDefault() 207 | 208 | instantiationStrategy = mojo.instantiationStrategy().id() 209 | 210 | isAggregator = mojo.aggregator() 211 | isDependencyResolutionRequired = mojo.requiresDependencyResolution().id() 212 | dependencyCollectionRequired = mojo.requiresDependencyCollection().id() 213 | 214 | isDirectInvocationOnly = mojo.requiresDirectInvocation() 215 | isThreadSafe = mojo.threadSafe() 216 | 217 | mojoAnnotatedClass.findExecuteInClassHierarchy(mojoAnnotatedClasses)?.also { execute -> 218 | executeGoal = execute.goal() 219 | executeLifecycle = execute.lifecycle() 220 | execute.phase()?.also { executePhase = it.id() } 221 | } 222 | 223 | executionStrategy = mojo.executionStrategy() 224 | 225 | goal = mojo.name() 226 | isOnlineRequired = mojo.requiresOnline() 227 | 228 | phase = mojo.defaultPhase().id() 229 | 230 | // Parameter annotations 231 | mojoAnnotatedClass.gatherParametersFromClassHierarchy(mojoAnnotatedClasses) 232 | .values 233 | .toSortedSet() 234 | .forEach { parameterAnnotationContent -> 235 | addParameter(parameterAnnotationContent.toParameter()) 236 | } 237 | 238 | // Component annotations 239 | mojoAnnotatedClass.gatherComponentsFromClassHierarchy(mojoAnnotatedClasses) 240 | .values 241 | .toSortedSet() 242 | .forEach { componentAnnotationContent -> 243 | addParameter(componentAnnotationContent.toParameter(mojoAnnotatedClass)) 244 | } 245 | 246 | this.pluginDescriptor = pluginDescriptor 247 | } 248 | } 249 | 250 | private fun ParameterAnnotationContent.toParameter(): Parameter { 251 | val parameterAnnotationContent = this 252 | 253 | return Parameter().apply { 254 | name = parameterAnnotationContent.name() 255 | ?.takeUnless(String::isEmpty) 256 | ?: parameterAnnotationContent.fieldName 257 | alias = parameterAnnotationContent.alias() 258 | defaultValue = parameterAnnotationContent.defaultValue() 259 | deprecated = parameterAnnotationContent.deprecated 260 | description = parameterAnnotationContent.description 261 | isEditable = !parameterAnnotationContent.readonly() 262 | val property: String? = parameterAnnotationContent.property() 263 | if (property?.let { '$' in it || '{' in it || '}' in it } == true) { 264 | throw InvalidParameterException( 265 | "Invalid property for parameter '$name', forbidden characters '\${}': $property", 266 | null 267 | ) 268 | } 269 | expression = property?.let { "\${$it}" } ?: "" 270 | type = parameterAnnotationContent.className 271 | since = parameterAnnotationContent.since 272 | isRequired = parameterAnnotationContent.required() 273 | } 274 | } 275 | 276 | private fun ComponentAnnotationContent.toParameter(mojoAnnotatedClass: MojoAnnotatedClass): Parameter { 277 | val componentAnnotationContent = this 278 | 279 | return Parameter().apply { 280 | name = componentAnnotationContent.fieldName 281 | 282 | // recognize Maven-injected objects as components annotations instead of parameters 283 | @Suppress("DEPRECATION") 284 | val expression = PluginUtils.MAVEN_COMPONENTS[componentAnnotationContent.roleClassName] 285 | 286 | if (expression == null) { 287 | // normal component 288 | requirement = Requirement( 289 | componentAnnotationContent.roleClassName, 290 | componentAnnotationContent.hint() 291 | ) 292 | } else { 293 | // not a component but a Maven object to be transformed into an expression/property: deprecated 294 | logger.warn( 295 | "Deprecated @Component annotation for '$name' property in " + 296 | "${mojoAnnotatedClass.className}: replace with @Parameter( defaultValue = \"$expression\", " + 297 | "readonly = true )" 298 | ) 299 | defaultValue = expression 300 | type = componentAnnotationContent.roleClassName 301 | isRequired = true 302 | } 303 | deprecated = componentAnnotationContent.deprecated 304 | since = componentAnnotationContent.since 305 | isEditable = false 306 | } 307 | } 308 | 309 | private tailrec fun MojoAnnotatedClass.findExecuteInClassHierarchy( 310 | mojoAnnotatedClasses: Map 311 | ): ExecuteAnnotationContent? { 312 | val mojoAnnotatedClass = this 313 | 314 | if (mojoAnnotatedClass.execute != null) { 315 | return mojoAnnotatedClass.execute 316 | } 317 | 318 | val parentClassName: String = mojoAnnotatedClass.parentClassName 319 | ?.takeUnless(String::isEmpty) 320 | ?: return null 321 | 322 | val parent = mojoAnnotatedClasses[parentClassName] ?: return null 323 | return parent.findExecuteInClassHierarchy(mojoAnnotatedClasses) 324 | } 325 | 326 | private tailrec fun MojoAnnotatedClass.gatherParametersFromClassHierarchy( 327 | mojoAnnotatedClasses: Map, 328 | descendantParameterAnnotationContents: Map = mapOf() 329 | ): Map { 330 | val mojoAnnotatedClass = this 331 | 332 | val localParameterAnnotationContents = 333 | mojoAnnotatedClass.parameters.values.associateBy { it.fieldName!! } 334 | 335 | val mergedParameterAnnotationContents = 336 | localParameterAnnotationContents + descendantParameterAnnotationContents 337 | 338 | val parentClassName: String = 339 | mojoAnnotatedClass.parentClassName ?: return mergedParameterAnnotationContents 340 | 341 | val parent = 342 | mojoAnnotatedClasses[parentClassName] ?: return mergedParameterAnnotationContents 343 | 344 | return parent.gatherParametersFromClassHierarchy( 345 | mojoAnnotatedClasses, 346 | mergedParameterAnnotationContents 347 | ) 348 | } 349 | 350 | private tailrec fun MojoAnnotatedClass.gatherComponentsFromClassHierarchy( 351 | mojoAnnotatedClasses: Map, 352 | descendantComponentAnnotationContents: Map = mapOf() 353 | ): Map { 354 | val mojoAnnotatedClass = this 355 | 356 | val localComponentAnnotationContent = 357 | mojoAnnotatedClass.components.values.associateBy { it.fieldName!! } 358 | 359 | val mergedComponentAnnotationContents = 360 | localComponentAnnotationContent + descendantComponentAnnotationContents 361 | 362 | val parentClassName: String = 363 | mojoAnnotatedClass.parentClassName ?: return mergedComponentAnnotationContents 364 | 365 | val parent = 366 | mojoAnnotatedClasses[parentClassName] ?: return mergedComponentAnnotationContents 367 | 368 | return parent.gatherComponentsFromClassHierarchy( 369 | mojoAnnotatedClasses, 370 | mergedComponentAnnotationContents 371 | ) 372 | } 373 | } 374 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/main/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/AnnotationScanner.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal 21 | 22 | import java.io.File 23 | import org.apache.maven.tools.plugin.PluginToolsRequest 24 | import org.apache.maven.tools.plugin.extractor.annotations.scanner.MojoAnnotatedClass 25 | import org.apache.maven.tools.plugin.extractor.annotations.scanner.MojoAnnotationsScanner 26 | import org.apache.maven.tools.plugin.extractor.annotations.scanner.MojoAnnotationsScannerRequest 27 | 28 | internal class AnnotationScanner( 29 | private val mojoAnnotationsScanner: MojoAnnotationsScanner 30 | ) { 31 | 32 | fun scanAnnotations(request: PluginToolsRequest): Map { 33 | return mojoAnnotationsScanner.scan( 34 | MojoAnnotationsScannerRequest().apply { 35 | classesDirectories = listOf(File(request.project.build.outputDirectory!!)) 36 | dependencies = request.dependencies!! 37 | project = request.project!! 38 | } 39 | ) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/main/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/SourceScanner.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal 21 | 22 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.kotlinc.KotlinSourceScanner 23 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.ClassDoc 24 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.SourceScanRequest 25 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.SourceScanRequest.ArtifactScanRequest 26 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.SourceScanRequest.ProjectScanRequest 27 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.qdox.QDoxSourceScanner 28 | import java.io.File 29 | import java.io.IOException 30 | import java.nio.file.Files 31 | import java.nio.file.Paths 32 | import org.apache.maven.artifact.Artifact 33 | import org.apache.maven.artifact.resolver.ArtifactNotFoundException 34 | import org.apache.maven.artifact.resolver.ArtifactResolutionException 35 | import org.apache.maven.artifact.resolver.ArtifactResolutionRequest 36 | import org.apache.maven.project.MavenProject 37 | import org.apache.maven.repository.RepositorySystem 38 | import org.apache.maven.tools.plugin.PluginToolsRequest 39 | import org.apache.maven.tools.plugin.extractor.ExtractionException 40 | import org.apache.maven.tools.plugin.extractor.annotations.scanner.MojoAnnotatedClass 41 | import org.codehaus.plexus.archiver.manager.ArchiverManager 42 | import org.codehaus.plexus.archiver.manager.NoSuchArchiverException 43 | import org.codehaus.plexus.logging.Logger 44 | 45 | internal class SourceScanner( 46 | private val logger: Logger, 47 | private val repositorySystem: RepositorySystem, 48 | private val archiverManager: ArchiverManager 49 | ) { 50 | 51 | fun scanSourceDoc( 52 | request: PluginToolsRequest, 53 | mojoAnnotatedClasses: Collection 54 | ): Map { 55 | val requestProject = request.project!! 56 | val requestArtifact = requestProject.artifact!! 57 | 58 | val mavenProjects = mutableListOf() 59 | val externalArtifacts = mutableSetOf() 60 | for (mojoAnnotatedClass in mojoAnnotatedClasses) { 61 | val classArtifact = mojoAnnotatedClass.artifact!! 62 | if (classArtifact.artifactId == requestArtifact.artifactId) { 63 | continue 64 | } 65 | 66 | if (!mojoAnnotatedClass.isCandidate()) { 67 | // we don't scan sources for classes without mojo annotations 68 | continue 69 | } 70 | 71 | classArtifact.fromProjectReferences(requestProject) 72 | ?.also { mavenProjects.add(it) } 73 | ?: externalArtifacts.add(classArtifact) 74 | } 75 | 76 | val scanRequestsForExternalSources: List = 77 | externalArtifacts.mapNotNull { artifact -> 78 | val isTestSources = "tests".equals(artifact.classifier, ignoreCase = true) 79 | val classifier = if (isTestSources) "test-sources" else "sources" 80 | 81 | artifact.createScanRequest(request, classifier) 82 | } 83 | 84 | val scanRequestsForReactorSources: List = 85 | mavenProjects.map { it.createScanRequest() } 86 | 87 | val scanRequestsForLocalSources = request.project.createScanRequest() 88 | 89 | val sourceScanRequests = 90 | scanRequestsForExternalSources + scanRequestsForReactorSources + scanRequestsForLocalSources 91 | 92 | val kotinSourceScanner = KotlinSourceScanner(logger) 93 | val kotinClassDoc = kotinSourceScanner.scanSourceDoc(sourceScanRequests) 94 | 95 | val qDoxSourceScanner = QDoxSourceScanner(logger, request) 96 | val qDoxClassDoc = qDoxSourceScanner.scanSourceDoc(sourceScanRequests) 97 | 98 | return kotinClassDoc + qDoxClassDoc 99 | } 100 | 101 | private fun MojoAnnotatedClass.isCandidate(): Boolean = hasAnnotations() 102 | 103 | private fun Artifact.createScanRequest( 104 | request: PluginToolsRequest, 105 | classifier: String 106 | ): SourceScanRequest? { 107 | val artifact = this 108 | 109 | try { 110 | val sourcesArtifact = 111 | repositorySystem.createArtifactWithClassifier( 112 | artifact.groupId!!, 113 | artifact.artifactId!!, 114 | artifact.version!!, 115 | artifact.type!!, 116 | classifier 117 | )!! 118 | 119 | repositorySystem.resolve( 120 | ArtifactResolutionRequest().apply { 121 | this.artifact = sourcesArtifact 122 | localRepository = request.local 123 | remoteRepositories = request.remoteRepos 124 | } 125 | ) 126 | 127 | val sourcesArtifactFile = sourcesArtifact.file 128 | ?.takeIf(File::exists) 129 | ?: return null // could not get artifact sources 130 | 131 | // extract sources to target/maven-plugin-plugin-sources/${groupId}/${artifact}/${version}/sources 132 | val extractDirectory = sourcesArtifact.let { 133 | Paths.get( 134 | request.project.build.directory!!, 135 | "maven-plugin-plugin-sources", 136 | it.groupId!!, 137 | it.artifactId!!, 138 | it.version!!, 139 | classifier 140 | )!! 141 | } 142 | try { 143 | Files.createDirectories(extractDirectory) 144 | } catch (e: IOException) { 145 | throw ExtractionException(e.message, e) 146 | } 147 | 148 | archiverManager.getUnArchiver("jar").apply { 149 | sourceFile = sourcesArtifactFile 150 | destDirectory = extractDirectory.toFile() 151 | extract() 152 | } 153 | 154 | return ArtifactScanRequest(artifact, extractDirectory) 155 | } catch (e: ArtifactResolutionException) { 156 | throw ExtractionException(e.message, e) 157 | } catch (e: ArtifactNotFoundException) { 158 | logger.debug("skip ArtifactNotFoundException: ${e.message}") 159 | logger.warn( 160 | "Unable to get sources artifact for " + 161 | "${artifact.groupId}:${artifact.artifactId}:${artifact.version}; javadoc tags (@since, " + 162 | "@deprecated and comments) won't be available." 163 | ) 164 | return null 165 | } catch (e: NoSuchArchiverException) { 166 | throw ExtractionException(e.message, e) 167 | } 168 | } 169 | 170 | private fun MavenProject.createScanRequest(): ProjectScanRequest { 171 | val compileSourceRoots: List = compileSourceRoots!! 172 | val sources = compileSourceRoots.map { Paths.get(it)!! }.toMutableList() 173 | 174 | val generatedPlugin = basedir.toPath() 175 | .resolve(Paths.get("target", "generated-sources", "plugin")) 176 | .toAbsolutePath()!! 177 | 178 | if (generatedPlugin.toString() !in compileSourceRoots && 179 | Files.exists(generatedPlugin) 180 | ) { 181 | sources.add(generatedPlugin) 182 | } 183 | 184 | return ProjectScanRequest(this, sources) 185 | } 186 | 187 | private fun Artifact.fromProjectReferences(project: MavenProject): MavenProject? { 188 | val mavenProjects: Collection? = project.projectReferences?.values 189 | 190 | return mavenProjects?.firstOrNull { it.id == id } 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/main/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/kotlinc/KotlinModelConversion.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 - 2022 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | @file:Suppress("ktlint:filename") 21 | 22 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.kotlinc 23 | 24 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.ClassDoc 25 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.DocTag 26 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.PropertyDoc 27 | import java.net.URI 28 | import org.intellij.markdown.IElementType 29 | import org.intellij.markdown.MarkdownElementTypes 30 | import org.intellij.markdown.ast.ASTNode 31 | import org.intellij.markdown.ast.LeafASTNode 32 | import org.intellij.markdown.ast.accept 33 | import org.intellij.markdown.ast.acceptChildren 34 | import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor 35 | import org.intellij.markdown.html.GeneratingProvider 36 | import org.intellij.markdown.html.HtmlGenerator 37 | import org.intellij.markdown.parser.LinkMap 38 | import org.intellij.markdown.parser.MarkdownParser 39 | import org.jetbrains.kotlin.kdoc.psi.api.KDoc 40 | import org.jetbrains.kotlin.psi.KtAnnotated 41 | import org.jetbrains.kotlin.psi.KtClass 42 | import org.jetbrains.kotlin.psi.KtExpression 43 | import org.jetbrains.kotlin.psi.KtLiteralStringTemplateEntry 44 | import org.jetbrains.kotlin.psi.KtStringTemplateExpression 45 | 46 | private fun KDoc.since(): DocTag? = 47 | getDefaultSection().findTagByName("since")?.getContent()?.markdownToHtml()?.let(::DocTag) 48 | 49 | private fun KtAnnotated.deprecated(): DocTag? = this.annotationEntries.asSequence() 50 | .filter { it.shortName!!.asString() == "Deprecated" } 51 | .map { annotationEntry -> 52 | val arguments = annotationEntry.valueArgumentList?.arguments ?: emptyList() 53 | return@map arguments.asSequence() 54 | .filter { 55 | val argumentName = it.getArgumentName()?.asName?.asString() ?: "message" 56 | return@filter argumentName == "message" 57 | } 58 | .map { it.getArgumentExpression()!!.asString() } 59 | .firstOrNull() 60 | } 61 | .map { DocTag(it ?: "") } 62 | .firstOrNull() 63 | 64 | private fun tags(deprecated: DocTag?, since: DocTag?): Map { 65 | val tags = mutableMapOf() 66 | if (deprecated != null) { 67 | tags += mapOf("deprecated" to deprecated) 68 | } 69 | if (since != null) { 70 | tags += mapOf("since" to since) 71 | } 72 | return tags.toMap() 73 | } 74 | 75 | private fun KDoc.asString(): String = getDefaultSection().getContent().markdownToHtml() 76 | 77 | private fun String.markdownToHtml(): String { 78 | val flavour = object : CommonMarkFlavourDescriptor() { 79 | override fun createHtmlGeneratingProviders( 80 | linkMap: LinkMap, 81 | baseURI: URI? 82 | ): Map { 83 | return super.createHtmlGeneratingProviders(linkMap, baseURI) + mapOf( 84 | MarkdownElementTypes.MARKDOWN_FILE to object : GeneratingProvider { 85 | override fun processNode( 86 | visitor: HtmlGenerator.HtmlGeneratingVisitor, 87 | text: String, 88 | node: ASTNode 89 | ) { 90 | // don't wrap in body tag 91 | node.acceptChildren(visitor) 92 | } 93 | }, 94 | MarkdownElementTypes.PARAGRAPH to object : GeneratingProvider { 95 | override fun processNode( 96 | visitor: HtmlGenerator.HtmlGeneratingVisitor, 97 | text: String, 98 | node: ASTNode 99 | ) { 100 | for (child in node.children) { 101 | if (child is LeafASTNode) { 102 | visitor.visitLeaf(child) 103 | } else { 104 | child.accept(visitor) 105 | } 106 | } 107 | 108 | visitor.consumeHtml("
\n") 109 | } 110 | } 111 | ) 112 | } 113 | } 114 | val parsedTree = MarkdownParser(flavour).buildMarkdownTreeFromString(this) 115 | var html = HtmlGenerator(this, parsedTree, flavour).generateHtml() 116 | if (html.endsWith("
\n")) { 117 | html = html.substring(0, html.length - "
\n".length) 118 | } 119 | return html 120 | } 121 | 122 | private fun KtExpression.asString(): String? { 123 | if (this !is KtStringTemplateExpression) return null 124 | if (this.children.asSequence().any { it !is KtLiteralStringTemplateEntry }) return null 125 | return this.children.joinToString { (it as KtLiteralStringTemplateEntry).text } 126 | } 127 | 128 | internal fun KtClass.toClassDoc(): ClassDoc { 129 | val ktClass = this 130 | val className = ktClass.fqName!!.asString() 131 | val classComment = ktClass.docComment?.asString() 132 | val classTags = tags(ktClass.deprecated(), ktClass.docComment?.since()) 133 | val properties = ktClass.getProperties().map { property -> 134 | val propertyName = property.name!! 135 | val propertyDoc = property.docComment?.asString() 136 | val propertyTags = tags(property.deprecated(), property.docComment?.since()) 137 | return@map PropertyDoc(name = propertyName, comment = propertyDoc, tags = propertyTags) 138 | } 139 | return ClassDoc( 140 | fullyQualifiedName = className, 141 | comment = classComment, 142 | properties = properties, 143 | tags = classTags 144 | ) 145 | } 146 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/main/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/kotlinc/KotlinSourceScanner.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 - 2022 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.kotlinc 21 | 22 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.ClassDoc 23 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.SourceScanRequest 24 | import java.nio.charset.StandardCharsets.UTF_8 25 | import java.nio.file.Files 26 | import java.nio.file.Path 27 | import java.util.stream.Collectors 28 | import org.codehaus.plexus.logging.Logger 29 | import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys 30 | import org.jetbrains.kotlin.cli.common.messages.MessageRenderer 31 | import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles 32 | import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment 33 | import org.jetbrains.kotlin.com.intellij.openapi.project.Project 34 | import org.jetbrains.kotlin.com.intellij.openapi.util.Disposer 35 | import org.jetbrains.kotlin.com.intellij.psi.PsiManager 36 | import org.jetbrains.kotlin.com.intellij.testFramework.LightVirtualFile 37 | import org.jetbrains.kotlin.config.CompilerConfiguration 38 | import org.jetbrains.kotlin.idea.KotlinFileType 39 | import org.jetbrains.kotlin.psi.KtClass 40 | import org.jetbrains.kotlin.psi.KtFile 41 | 42 | private fun createProject(logger: Logger): Project { 43 | val configuration = CompilerConfiguration() 44 | configuration.put( 45 | CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, 46 | MavenMessageCollector(logger, MessageRenderer.PLAIN_RELATIVE_PATHS) 47 | ) 48 | return KotlinCoreEnvironment.createForProduction( 49 | Disposer.newDisposable(), 50 | configuration, 51 | EnvironmentConfigFiles.JVM_CONFIG_FILES 52 | ).project 53 | } 54 | 55 | internal class KotlinSourceScanner private constructor( 56 | private val project: Project 57 | ) { 58 | constructor(logger: Logger) : this(createProject(logger)) 59 | 60 | private fun createKtFile(codeString: String, fileName: String) = 61 | PsiManager.getInstance(project) 62 | .findFile( 63 | LightVirtualFile(fileName, KotlinFileType.INSTANCE, codeString) 64 | ) as KtFile 65 | 66 | fun scanSourceDoc(requests: List): Map = requests.stream() 67 | .flatMap { it.sourceDirectories.stream() } 68 | .flatMap { Files.walk(it) } 69 | .filter { Files.isRegularFile(it) } 70 | .filter { it.toString().endsWith(".kt") } 71 | .flatMap { it.parse().stream() } 72 | .collect(Collectors.toMap(ClassDoc::fullyQualifiedName, { it })) 73 | 74 | private fun Path.parse(): List { 75 | val ktFile = createKtFile(String(Files.readAllBytes(this), UTF_8), toFile().path) 76 | val classes = ktFile.findChildrenByClass(KtClass::class.java) 77 | return classes.map(KtClass::toClassDoc) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/main/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/kotlinc/MavenMessageCollector.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 - 2022 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.kotlinc 21 | 22 | import org.codehaus.plexus.logging.Logger 23 | import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity 24 | import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation 25 | import org.jetbrains.kotlin.cli.common.messages.MessageCollector 26 | import org.jetbrains.kotlin.cli.common.messages.MessageRenderer 27 | 28 | internal class MavenMessageCollector( 29 | private val logger: Logger, 30 | private val messageRenderer: MessageRenderer 31 | ) : MessageCollector { 32 | private var hasErrors = false 33 | 34 | override fun clear() { 35 | hasErrors = false 36 | } 37 | 38 | override fun report( 39 | severity: CompilerMessageSeverity, 40 | message: String, 41 | location: CompilerMessageSourceLocation? 42 | ) { 43 | if (CompilerMessageSeverity.VERBOSE.contains(severity)) return 44 | hasErrors = hasErrors or severity.isError 45 | logger.warn(messageRenderer.render(severity, message, location)) 46 | } 47 | 48 | override fun hasErrors(): Boolean = hasErrors 49 | } 50 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/main/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/model/ClassDoc.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model 21 | 22 | internal data class ClassDoc( 23 | val fullyQualifiedName: String, 24 | val comment: String?, 25 | val properties: List, 26 | val tags: Map 27 | ) { 28 | var superClassDoc: ClassDoc? = null 29 | set(value) { 30 | if (field != null) throw IllegalStateException("superClassDoc cannot be changed once set") 31 | field = value 32 | } 33 | 34 | override fun equals(other: Any?): Boolean { 35 | if (other !is ClassDoc) { 36 | return false 37 | } 38 | return fullyQualifiedName == other.fullyQualifiedName 39 | } 40 | 41 | override fun hashCode(): Int = fullyQualifiedName.hashCode() 42 | } 43 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/main/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/model/DocTag.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model 21 | 22 | internal data class DocTag(val value: String? = null) 23 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/main/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/model/PropertyDoc.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model 21 | 22 | internal data class PropertyDoc( 23 | val name: String, 24 | val comment: String?, 25 | val tags: Map 26 | ) 27 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/main/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/model/SourceScanRequest.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model 21 | 22 | import java.nio.file.Path 23 | import org.apache.maven.artifact.Artifact 24 | import org.apache.maven.project.MavenProject 25 | 26 | internal sealed class SourceScanRequest(open val sourceDirectories: List) { 27 | 28 | data class ArtifactScanRequest( 29 | val artifact: Artifact, 30 | private val sourceDirectory: Path 31 | ) : SourceScanRequest(listOf(sourceDirectory)) 32 | 33 | data class ProjectScanRequest( 34 | val project: MavenProject, 35 | override val sourceDirectories: List 36 | ) : SourceScanRequest(sourceDirectories) 37 | } 38 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/main/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/qdox/QDoxModelConversion.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | @file:Suppress("ktlint:filename") 21 | 22 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.qdox 23 | 24 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.ClassDoc 25 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.DocTag 26 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.PropertyDoc 27 | import com.thoughtworks.qdox.model.DocletTag 28 | import com.thoughtworks.qdox.model.JavaClass 29 | import com.thoughtworks.qdox.model.JavaField 30 | 31 | internal fun Map.toClassDocMap(): Map { 32 | val classDocs = values.asSequence() 33 | .map { javaClass -> 34 | ClassDoc( 35 | fullyQualifiedName = javaClass.fullyQualifiedName, 36 | comment = javaClass.comment, 37 | properties = javaClass.fields.toPropertyDocs(), 38 | tags = javaClass.tags.toDocTags() 39 | ) 40 | } 41 | .associateBy(ClassDoc::fullyQualifiedName) 42 | 43 | val superClassMapping = values 44 | .associate { it.fullyQualifiedName!! to it.superJavaClass?.fullyQualifiedName!! } 45 | 46 | for (classDoc in classDocs.values) { 47 | classDoc.superClassDoc = classDocs[superClassMapping[classDoc.fullyQualifiedName]] 48 | } 49 | 50 | return classDocs 51 | } 52 | 53 | private fun List.toPropertyDocs(): List = 54 | map { javaField -> 55 | PropertyDoc( 56 | name = javaField.name, 57 | comment = javaField.comment, 58 | tags = javaField.tags.toDocTags() 59 | ) 60 | } 61 | 62 | private fun List.toDocTags(): Map = 63 | associate { 64 | it.name to DocTag( 65 | it.value 66 | ) 67 | } 68 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/main/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/qdox/QDoxSourceScanner.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.qdox 21 | 22 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.ClassDoc 23 | import com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.model.SourceScanRequest 24 | import com.thoughtworks.qdox.JavaProjectBuilder 25 | import com.thoughtworks.qdox.library.SortedClassLibraryBuilder 26 | import com.thoughtworks.qdox.model.JavaClass 27 | import java.net.MalformedURLException 28 | import java.net.URLClassLoader 29 | import java.nio.file.Path 30 | import java.util.concurrent.TimeUnit.MILLISECONDS 31 | import java.util.concurrent.TimeUnit.SECONDS 32 | import org.apache.maven.artifact.Artifact 33 | import org.apache.maven.tools.plugin.PluginToolsRequest 34 | import org.codehaus.plexus.logging.Logger 35 | 36 | internal class QDoxSourceScanner( 37 | private val logger: Logger, 38 | private val request: PluginToolsRequest 39 | ) { 40 | 41 | fun scanSourceDoc(requests: List): Map { 42 | val encoding = request.encoding!! 43 | val requestDependencies: Set = request.dependencies!! 44 | 45 | return requests.map { 46 | when (it) { 47 | is SourceScanRequest.ArtifactScanRequest -> { 48 | it.sourceDirectories.discoverClasses(encoding, requestDependencies) 49 | } 50 | 51 | is SourceScanRequest.ProjectScanRequest -> { 52 | it.sourceDirectories.discoverClasses(encoding, it.project.artifacts!!) 53 | } 54 | } 55 | }.fold(mutableMapOf()) { acc, element -> acc.putAll(element); acc } 56 | } 57 | 58 | private fun List.discoverClasses( 59 | encoding: String, 60 | artifacts: Set 61 | ): Map { 62 | val sourceDirectories = this 63 | 64 | val classpath = artifacts.map { it.file!! } 65 | 66 | logger.debug("Performing source scanning using QDox") 67 | logger.debug("Sources: ${this.joinToString()}") 68 | logger.debug("Classpath: ${classpath.joinToString()}") 69 | 70 | val startScanMillis = System.currentTimeMillis() 71 | 72 | // Build isolated Classloader with only the artifacts of the project (none of this plugin) 73 | val classLoader = URLClassLoader( 74 | classpath.asSequence() 75 | .mapNotNull({ 76 | try { 77 | it.toURI().toURL()!! 78 | } catch (e: MalformedURLException) { 79 | null 80 | } 81 | }) 82 | .toList() 83 | .toTypedArray(), 84 | ClassLoader.getSystemClassLoader() 85 | ) 86 | 87 | val builder = JavaProjectBuilder(SortedClassLibraryBuilder()).apply { 88 | setEncoding(encoding) 89 | addClassLoader(classLoader) 90 | 91 | for (dir in sourceDirectories) { 92 | addSourceTree(dir.toFile()) 93 | } 94 | } 95 | 96 | val scanDurationMillis = System.currentTimeMillis() - startScanMillis 97 | logger.debug("done in ${SECONDS.convert(scanDurationMillis, MILLISECONDS)} secs") 98 | 99 | val javaClasses: MutableCollection = builder.classes ?: return emptyMap() 100 | 101 | return javaClasses.associateBy { it.fullyQualifiedName!! }.toClassDocMap() 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/examples/ExtendsExternalMojo.java: -------------------------------------------------------------------------------- 1 | package org.apache.maven.tools.plugin.extractor.annotations.examples; 2 | 3 | /*- 4 | * #%L 5 | * kotlin-maven-plugin-tools 6 | * %% 7 | * Copyright (C) 2018 GantSign Ltd. 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.io.File; 24 | import org.apache.maven.plugins.annotations.Execute; 25 | import org.apache.maven.plugins.annotations.InstantiationStrategy; 26 | import org.apache.maven.plugins.annotations.LifecyclePhase; 27 | import org.apache.maven.plugins.annotations.Mojo; 28 | import org.apache.maven.plugins.annotations.Parameter; 29 | import org.apache.maven.plugins.annotations.ResolutionScope; 30 | import org.apache.maven.plugins.jar.AbstractJarMojo; 31 | 32 | /** @deprecated Extends external deprecated. */ 33 | @Deprecated 34 | @SuppressWarnings("ALL") 35 | @Mojo( 36 | name = "extendsexternal", 37 | defaultPhase = LifecyclePhase.COMPILE, 38 | requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, 39 | requiresDependencyCollection = ResolutionScope.RUNTIME, 40 | instantiationStrategy = InstantiationStrategy.SINGLETON, 41 | executionStrategy = "always", 42 | requiresProject = false, 43 | requiresDirectInvocation = true, 44 | requiresOnline = true, 45 | inheritByDefault = false, 46 | configurator = "externalExternalConfigurator", 47 | threadSafe = true 48 | ) 49 | @Execute(lifecycle = "extendsExternalLifecycle", phase = LifecyclePhase.PACKAGE) 50 | public class ExtendsExternalMojo extends AbstractJarMojo { 51 | 52 | @Parameter protected String additionalParameter; 53 | 54 | @Override 55 | protected File getClassesDirectory() { 56 | return null; 57 | } 58 | 59 | @Override 60 | protected String getClassifier() { 61 | return null; 62 | } 63 | 64 | @Override 65 | protected String getType() { 66 | return null; 67 | } 68 | 69 | @Override 70 | public void execute() { 71 | // nothing 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/examples/ExtendsLocalMojo.java: -------------------------------------------------------------------------------- 1 | package org.apache.maven.tools.plugin.extractor.annotations.examples; 2 | 3 | /*- 4 | * #%L 5 | * kotlin-maven-plugin-tools 6 | * %% 7 | * Copyright (C) 2018 GantSign Ltd. 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.apache.maven.plugins.annotations.Component; 24 | import org.apache.maven.plugins.annotations.Execute; 25 | import org.apache.maven.plugins.annotations.InstantiationStrategy; 26 | import org.apache.maven.plugins.annotations.LifecyclePhase; 27 | import org.apache.maven.plugins.annotations.Mojo; 28 | import org.apache.maven.plugins.annotations.Parameter; 29 | import org.apache.maven.plugins.annotations.ResolutionScope; 30 | import org.codehaus.plexus.compiler.manager.CompilerManager; 31 | import org.codehaus.plexus.compiler.manager.DefaultCompilerManager; 32 | 33 | /** @deprecated Extends local deprecated. */ 34 | @Deprecated 35 | @SuppressWarnings("ALL") 36 | @Mojo( 37 | name = "extendslocal", 38 | defaultPhase = LifecyclePhase.COMPILE, 39 | requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, 40 | requiresDependencyCollection = ResolutionScope.RUNTIME, 41 | instantiationStrategy = InstantiationStrategy.SINGLETON, 42 | executionStrategy = "always", 43 | requiresProject = false, 44 | requiresDirectInvocation = true, 45 | requiresOnline = true, 46 | inheritByDefault = false, 47 | configurator = "localConfigurator", 48 | threadSafe = true 49 | ) 50 | @Execute(lifecycle = "extendsLocalLifecycle", phase = LifecyclePhase.PACKAGE) 51 | public class ExtendsLocalMojo extends LocalMojo { 52 | 53 | /** @deprecated extends everything parameter deprecated message */ 54 | @Deprecated 55 | @Parameter(name = "everythingParameterName", alias = "extendsEverythingParameterAlias") 56 | protected String everythingParameter; 57 | 58 | @Parameter protected String additionalParameter; 59 | 60 | /** @deprecated extends everything component deprecated message */ 61 | @Deprecated 62 | @Component(role = CompilerManager.class, hint = "extendsEverythingComponentHint") 63 | protected DefaultCompilerManager everythingComponent; 64 | 65 | @Override 66 | public void execute() { 67 | // nothing 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/examples/LocalMojo.java: -------------------------------------------------------------------------------- 1 | package org.apache.maven.tools.plugin.extractor.annotations.examples; 2 | 3 | /*- 4 | * #%L 5 | * kotlin-maven-plugin-tools 6 | * %% 7 | * Copyright (C) 2018 GantSign Ltd. 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.apache.maven.plugin.AbstractMojo; 24 | import org.apache.maven.plugin.MojoExecution; 25 | import org.apache.maven.plugins.annotations.Component; 26 | import org.apache.maven.plugins.annotations.Execute; 27 | import org.apache.maven.plugins.annotations.InstantiationStrategy; 28 | import org.apache.maven.plugins.annotations.LifecyclePhase; 29 | import org.apache.maven.plugins.annotations.Mojo; 30 | import org.apache.maven.plugins.annotations.Parameter; 31 | import org.apache.maven.plugins.annotations.ResolutionScope; 32 | import org.apache.maven.repository.RepositorySystem; 33 | import org.codehaus.plexus.compiler.manager.CompilerManager; 34 | import org.codehaus.plexus.compiler.manager.DefaultCompilerManager; 35 | 36 | /** 37 | * Local description. 38 | * 39 | * @deprecated Local deprecated. 40 | * @since localVersion 41 | */ 42 | @Deprecated 43 | @SuppressWarnings("ALL") 44 | @Mojo( 45 | name = "local", 46 | defaultPhase = LifecyclePhase.COMPILE, 47 | requiresDependencyResolution = ResolutionScope.COMPILE, 48 | requiresDependencyCollection = ResolutionScope.RUNTIME, 49 | instantiationStrategy = InstantiationStrategy.SINGLETON, 50 | executionStrategy = "always", 51 | requiresProject = false, 52 | requiresReports = true, 53 | aggregator = true, 54 | requiresDirectInvocation = true, 55 | requiresOnline = true, 56 | inheritByDefault = false, 57 | configurator = "localConfigurator", 58 | threadSafe = true 59 | ) 60 | @Execute(goal = "compiler", lifecycle = "localLifecycle", phase = LifecyclePhase.PACKAGE) 61 | public class LocalMojo extends AbstractMojo { 62 | 63 | @Parameter protected String minimalParameter; 64 | 65 | /** 66 | * Everything parameter description 67 | * 68 | * @deprecated everything parameter deprecated message 69 | * @since everythingParameterVersion 70 | */ 71 | @Deprecated 72 | @Parameter( 73 | name = "everythingParameterName", 74 | alias = "everythingParameterAlias", 75 | property = "everythingParameterProperty", 76 | defaultValue = "everythingParameterDefaultValue", 77 | required = true, 78 | readonly = true 79 | ) 80 | protected String everythingParameter; 81 | 82 | @Component protected RepositorySystem minimalComponent; 83 | 84 | /** 85 | * Everything component description. 86 | * 87 | * @deprecated everything component deprecated message 88 | * @since everythingComponentVersion 89 | */ 90 | @Deprecated 91 | @Component(role = CompilerManager.class, hint = "everythingComponentHint") 92 | protected DefaultCompilerManager everythingComponent; 93 | 94 | @Parameter(defaultValue = "${mojoExecution}", readonly = true) 95 | private MojoExecution componentAsParameter; 96 | 97 | @Override 98 | public void execute() { 99 | // nothing 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/examples/MinimalMojo.java: -------------------------------------------------------------------------------- 1 | package org.apache.maven.tools.plugin.extractor.annotations.examples; 2 | 3 | /*- 4 | * #%L 5 | * kotlin-maven-plugin-tools 6 | * %% 7 | * Copyright (C) 2018 GantSign Ltd. 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.apache.maven.plugin.AbstractMojo; 24 | import org.apache.maven.plugins.annotations.Mojo; 25 | 26 | @SuppressWarnings("ALL") 27 | @Mojo(name = "minimal") 28 | public class MinimalMojo extends AbstractMojo { 29 | 30 | @Override 31 | public void execute() { 32 | // nothing 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/test/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/examples/KotlinExtendsLocalMojo.kt: -------------------------------------------------------------------------------- 1 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.examples 2 | 3 | /*- 4 | * #%L 5 | * kotlin-maven-plugin-tools 6 | * %% 7 | * Copyright (C) 2018 GantSign Ltd. 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.apache.maven.plugins.annotations.Component 24 | import org.apache.maven.plugins.annotations.Execute 25 | import org.apache.maven.plugins.annotations.InstantiationStrategy 26 | import org.apache.maven.plugins.annotations.LifecyclePhase 27 | import org.apache.maven.plugins.annotations.Mojo 28 | import org.apache.maven.plugins.annotations.Parameter 29 | import org.apache.maven.plugins.annotations.ResolutionScope 30 | import org.apache.maven.tools.plugin.extractor.annotations.examples.LocalMojo 31 | import org.codehaus.plexus.compiler.manager.CompilerManager 32 | import org.codehaus.plexus.compiler.manager.DefaultCompilerManager 33 | 34 | /** 35 | * Kotlin extends local description. 36 | * 37 | * @since kotlinExtendsLocalVersion 38 | */ 39 | @SuppressWarnings("ALL") 40 | @Mojo( 41 | name = "kotlinextendslocal", 42 | defaultPhase = LifecyclePhase.COMPILE, 43 | requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, 44 | requiresDependencyCollection = ResolutionScope.RUNTIME, 45 | instantiationStrategy = InstantiationStrategy.SINGLETON, 46 | executionStrategy = "always", 47 | requiresProject = false, 48 | requiresDirectInvocation = true, 49 | requiresOnline = true, 50 | inheritByDefault = false, 51 | configurator = "kotlinExtendsLocalConfigurator", 52 | threadSafe = true 53 | ) 54 | @Execute( 55 | lifecycle = "kotlinExtendsLocalLifecycle", 56 | phase = LifecyclePhase.PACKAGE 57 | ) 58 | @Deprecated("Kotlin extends local deprecated.") 59 | class KotlinExtendsLocalMojo : LocalMojo() { 60 | 61 | @Parameter(name = "everythingParameterName", alias = "extendsEverythingParameterAlias") 62 | @Deprecated("extends everything parameter deprecated message") 63 | var everythingParameter: String? = null 64 | 65 | @Parameter 66 | var additionalParameter: String? = null 67 | 68 | @Component(role = CompilerManager::class, hint = "extendsEverythingComponentHint") 69 | @Deprecated("extends everything component deprecated message") 70 | var everythingComponent: DefaultCompilerManager? = null 71 | 72 | override fun execute() { 73 | // nothing 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/test/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/examples/KotlinMojo.kt: -------------------------------------------------------------------------------- 1 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.examples 2 | 3 | /*- 4 | * #%L 5 | * kotlin-maven-plugin-tools 6 | * %% 7 | * Copyright (C) 2018 GantSign Ltd. 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.apache.maven.plugin.AbstractMojo 24 | import org.apache.maven.plugin.MojoExecution 25 | import org.apache.maven.plugins.annotations.Component 26 | import org.apache.maven.plugins.annotations.Execute 27 | import org.apache.maven.plugins.annotations.InstantiationStrategy 28 | import org.apache.maven.plugins.annotations.LifecyclePhase 29 | import org.apache.maven.plugins.annotations.Mojo 30 | import org.apache.maven.plugins.annotations.Parameter 31 | import org.apache.maven.plugins.annotations.ResolutionScope 32 | import org.apache.maven.repository.RepositorySystem 33 | import org.codehaus.plexus.compiler.manager.CompilerManager 34 | import org.codehaus.plexus.compiler.manager.DefaultCompilerManager 35 | 36 | /** 37 | * Kotlin local description. 38 | * 39 | * @since kotlinLocalVersion 40 | */ 41 | @SuppressWarnings("ALL") 42 | @Mojo( 43 | name = "kotlin", 44 | defaultPhase = LifecyclePhase.COMPILE, 45 | requiresDependencyResolution = ResolutionScope.COMPILE, 46 | requiresDependencyCollection = ResolutionScope.RUNTIME, 47 | instantiationStrategy = InstantiationStrategy.SINGLETON, 48 | executionStrategy = "always", 49 | requiresProject = false, 50 | requiresReports = true, 51 | aggregator = true, 52 | requiresDirectInvocation = true, 53 | requiresOnline = true, 54 | inheritByDefault = false, 55 | configurator = "kotlinLocalConfigurator", 56 | threadSafe = true 57 | ) 58 | @Execute(goal = "compiler", lifecycle = "kotlinLocalLifecycle", phase = LifecyclePhase.PACKAGE) 59 | @Deprecated("Kotlin local deprecated.") 60 | open class KotlinMojo : AbstractMojo() { 61 | 62 | @Parameter 63 | var minimalParameter: String? = null 64 | 65 | /** 66 | * Everything parameter description. 67 | * 68 | * Paragraph 2. 69 | * 70 | * This is a [link](https://example.com). 71 | * 72 | * This is *text with emphasis*. 73 | * 74 | * This is **strong text**. 75 | * 76 | * This is `inline code`. 77 | * 78 | * @since everythingParameterVersion 79 | */ 80 | @Parameter( 81 | name = "everythingParameterName", 82 | alias = "everythingParameterAlias", 83 | property = "everythingParameterProperty", 84 | defaultValue = "everythingParameterDefaultValue", 85 | required = true, 86 | readonly = true 87 | ) 88 | @Deprecated("everything parameter deprecated message") 89 | var everythingParameter: String? = null 90 | 91 | @Component 92 | var minimalComponent: RepositorySystem? = null 93 | 94 | /** 95 | * Everything component description. 96 | * 97 | * @since everythingComponentVersion 98 | */ 99 | @Component(role = CompilerManager::class, hint = "everythingComponentHint") 100 | @Deprecated("everything component deprecated message") 101 | var everythingComponent: DefaultCompilerManager? = null 102 | 103 | @Parameter(defaultValue = "\${mojoExecution}", readonly = true) 104 | val componentAsParameter: MojoExecution? = null 105 | 106 | override fun execute() { 107 | // nothing 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/test/kotlin/com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/kotlinc/MavenMessageCollectorTest.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * kotlin-maven-plugin-tools 4 | * %% 5 | * Copyright (C) 2018 - 2022 GantSign Ltd. 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.github.gantsign.maven.tools.plugin.extractor.kotlin.internal.kotlinc 21 | 22 | import io.mockk.confirmVerified 23 | import io.mockk.mockk 24 | import io.mockk.verify 25 | import org.assertj.core.api.Assertions.assertThat 26 | import org.codehaus.plexus.logging.Logger 27 | import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity 28 | import org.jetbrains.kotlin.cli.common.messages.MessageRenderer 29 | import org.junit.Test 30 | 31 | class MavenMessageCollectorTest { 32 | 33 | @Test 34 | fun report() { 35 | val logger = mockk(relaxed = true) 36 | val collector = MavenMessageCollector(logger, MessageRenderer.PLAIN_RELATIVE_PATHS) 37 | 38 | assertThat(collector.hasErrors()).isFalse() 39 | collector.report(CompilerMessageSeverity.ERROR, "test1", null) 40 | 41 | verify { logger.warn("error: test1") } 42 | 43 | assertThat(collector.hasErrors()).isTrue() 44 | collector.clear() 45 | assertThat(collector.hasErrors()).isFalse() 46 | 47 | confirmVerified(logger) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /kotlin-maven-plugin-tools/src/test/resources/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 4.0.0 23 | 24 | com.example 25 | example-pom 26 | 1.0.0-SNAPSHOT 27 | 28 | pom 29 | 30 | 31 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Apache Maven Wrapper startup batch script, version 3.1.1 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | # e.g. to debug Maven itself, use 32 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | # ---------------------------------------------------------------------------- 35 | 36 | if [ -z "$MAVEN_SKIP_RC" ] ; then 37 | 38 | if [ -f /usr/local/etc/mavenrc ] ; then 39 | . /usr/local/etc/mavenrc 40 | fi 41 | 42 | if [ -f /etc/mavenrc ] ; then 43 | . /etc/mavenrc 44 | fi 45 | 46 | if [ -f "$HOME/.mavenrc" ] ; then 47 | . "$HOME/.mavenrc" 48 | fi 49 | 50 | fi 51 | 52 | # OS specific support. $var _must_ be set to either true or false. 53 | cygwin=false; 54 | darwin=false; 55 | mingw=false 56 | case "`uname`" in 57 | CYGWIN*) cygwin=true ;; 58 | MINGW*) mingw=true;; 59 | Darwin*) darwin=true 60 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 61 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 62 | if [ -z "$JAVA_HOME" ]; then 63 | if [ -x "/usr/libexec/java_home" ]; then 64 | JAVA_HOME="`/usr/libexec/java_home`"; export JAVA_HOME 65 | else 66 | JAVA_HOME="/Library/Java/Home"; export JAVA_HOME 67 | fi 68 | fi 69 | ;; 70 | esac 71 | 72 | if [ -z "$JAVA_HOME" ] ; then 73 | if [ -r /etc/gentoo-release ] ; then 74 | JAVA_HOME=`java-config --jre-home` 75 | fi 76 | fi 77 | 78 | # For Cygwin, ensure paths are in UNIX format before anything is touched 79 | if $cygwin ; then 80 | [ -n "$JAVA_HOME" ] && 81 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 82 | [ -n "$CLASSPATH" ] && 83 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 84 | fi 85 | 86 | # For Mingw, ensure paths are in UNIX format before anything is touched 87 | if $mingw ; then 88 | [ -n "$JAVA_HOME" ] && 89 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 90 | fi 91 | 92 | if [ -z "$JAVA_HOME" ]; then 93 | javaExecutable="`which javac`" 94 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 95 | # readlink(1) is not available as standard on Solaris 10. 96 | readLink=`which readlink` 97 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 98 | if $darwin ; then 99 | javaHome="`dirname \"$javaExecutable\"`" 100 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 101 | else 102 | javaExecutable="`readlink -f \"$javaExecutable\"`" 103 | fi 104 | javaHome="`dirname \"$javaExecutable\"`" 105 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 106 | JAVA_HOME="$javaHome" 107 | export JAVA_HOME 108 | fi 109 | fi 110 | fi 111 | 112 | if [ -z "$JAVACMD" ] ; then 113 | if [ -n "$JAVA_HOME" ] ; then 114 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 115 | # IBM's JDK on AIX uses strange locations for the executables 116 | JAVACMD="$JAVA_HOME/jre/sh/java" 117 | else 118 | JAVACMD="$JAVA_HOME/bin/java" 119 | fi 120 | else 121 | JAVACMD="`\\unset -f command; \\command -v java`" 122 | fi 123 | fi 124 | 125 | if [ ! -x "$JAVACMD" ] ; then 126 | echo "Error: JAVA_HOME is not defined correctly." >&2 127 | echo " We cannot execute $JAVACMD" >&2 128 | exit 1 129 | fi 130 | 131 | if [ -z "$JAVA_HOME" ] ; then 132 | echo "Warning: JAVA_HOME environment variable is not set." 133 | fi 134 | 135 | # traverses directory structure from process work directory to filesystem root 136 | # first directory with .mvn subdirectory is considered project base directory 137 | find_maven_basedir() { 138 | if [ -z "$1" ] 139 | then 140 | echo "Path not specified to find_maven_basedir" 141 | return 1 142 | fi 143 | 144 | basedir="$1" 145 | wdir="$1" 146 | while [ "$wdir" != '/' ] ; do 147 | if [ -d "$wdir"/.mvn ] ; then 148 | basedir=$wdir 149 | break 150 | fi 151 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 152 | if [ -d "${wdir}" ]; then 153 | wdir=`cd "$wdir/.."; pwd` 154 | fi 155 | # end of workaround 156 | done 157 | printf '%s' "$(cd "$basedir"; pwd)" 158 | } 159 | 160 | # concatenates all lines of a file 161 | concat_lines() { 162 | if [ -f "$1" ]; then 163 | echo "$(tr -s '\n' ' ' < "$1")" 164 | fi 165 | } 166 | 167 | BASE_DIR=$(find_maven_basedir "$(dirname $0)") 168 | if [ -z "$BASE_DIR" ]; then 169 | exit 1; 170 | fi 171 | 172 | MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR 173 | if [ "$MVNW_VERBOSE" = true ]; then 174 | echo $MAVEN_PROJECTBASEDIR 175 | fi 176 | 177 | ########################################################################################## 178 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 179 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 180 | ########################################################################################## 181 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 182 | if [ "$MVNW_VERBOSE" = true ]; then 183 | echo "Found .mvn/wrapper/maven-wrapper.jar" 184 | fi 185 | else 186 | if [ "$MVNW_VERBOSE" = true ]; then 187 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 188 | fi 189 | if [ -n "$MVNW_REPOURL" ]; then 190 | wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" 191 | else 192 | wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" 193 | fi 194 | while IFS="=" read key value; do 195 | case "$key" in (wrapperUrl) wrapperUrl="$value"; break ;; 196 | esac 197 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 198 | if [ "$MVNW_VERBOSE" = true ]; then 199 | echo "Downloading from: $wrapperUrl" 200 | fi 201 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 202 | if $cygwin; then 203 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 204 | fi 205 | 206 | if command -v wget > /dev/null; then 207 | QUIET="--quiet" 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found wget ... using wget" 210 | QUIET="" 211 | fi 212 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 213 | wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" 214 | else 215 | wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" 216 | fi 217 | [ $? -eq 0 ] || rm -f "$wrapperJarPath" 218 | elif command -v curl > /dev/null; then 219 | QUIET="--silent" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Found curl ... using curl" 222 | QUIET="" 223 | fi 224 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 225 | curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L 226 | else 227 | curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L 228 | fi 229 | [ $? -eq 0 ] || rm -f "$wrapperJarPath" 230 | else 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Falling back to using Java to download" 233 | fi 234 | javaSource="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 235 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" 236 | # For Cygwin, switch paths to Windows format before running javac 237 | if $cygwin; then 238 | javaSource=`cygpath --path --windows "$javaSource"` 239 | javaClass=`cygpath --path --windows "$javaClass"` 240 | fi 241 | if [ -e "$javaSource" ]; then 242 | if [ ! -e "$javaClass" ]; then 243 | if [ "$MVNW_VERBOSE" = true ]; then 244 | echo " - Compiling MavenWrapperDownloader.java ..." 245 | fi 246 | # Compiling the Java class 247 | ("$JAVA_HOME/bin/javac" "$javaSource") 248 | fi 249 | if [ -e "$javaClass" ]; then 250 | # Running the downloader 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo " - Running MavenWrapperDownloader.java ..." 253 | fi 254 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 255 | fi 256 | fi 257 | fi 258 | fi 259 | ########################################################################################## 260 | # End of extension 261 | ########################################################################################## 262 | 263 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 264 | 265 | # For Cygwin, switch paths to Windows format before running java 266 | if $cygwin; then 267 | [ -n "$JAVA_HOME" ] && 268 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 269 | [ -n "$CLASSPATH" ] && 270 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 271 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 272 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 273 | fi 274 | 275 | # Provide a "standardized" way to retrieve the CLI args that will 276 | # work with both Windows and non-Windows executions. 277 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 278 | export MAVEN_CMD_LINE_ARGS 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | $MAVEN_DEBUG_OPTS \ 285 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 286 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 287 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 288 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Apache Maven Wrapper startup batch script, version 3.1.1 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 28 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 29 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 30 | @REM e.g. to debug Maven itself, use 31 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 32 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 33 | @REM ---------------------------------------------------------------------------- 34 | 35 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 36 | @echo off 37 | @REM set title of command window 38 | title %0 39 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 40 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 41 | 42 | @REM set %HOME% to equivalent of $HOME 43 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 44 | 45 | @REM Execute a user defined script before this one 46 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 47 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 48 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 49 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 50 | :skipRcPre 51 | 52 | @setlocal 53 | 54 | set ERROR_CODE=0 55 | 56 | @REM To isolate internal variables from possible post scripts, we use another setlocal 57 | @setlocal 58 | 59 | @REM ==== START VALIDATION ==== 60 | if not "%JAVA_HOME%" == "" goto OkJHome 61 | 62 | echo. 63 | echo Error: JAVA_HOME not found in your environment. >&2 64 | echo Please set the JAVA_HOME variable in your environment to match the >&2 65 | echo location of your Java installation. >&2 66 | echo. 67 | goto error 68 | 69 | :OkJHome 70 | if exist "%JAVA_HOME%\bin\java.exe" goto init 71 | 72 | echo. 73 | echo Error: JAVA_HOME is set to an invalid directory. >&2 74 | echo JAVA_HOME = "%JAVA_HOME%" >&2 75 | echo Please set the JAVA_HOME variable in your environment to match the >&2 76 | echo location of your Java installation. >&2 77 | echo. 78 | goto error 79 | 80 | @REM ==== END VALIDATION ==== 81 | 82 | :init 83 | 84 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 85 | @REM Fallback to current working directory if not found. 86 | 87 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 88 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 89 | 90 | set EXEC_DIR=%CD% 91 | set WDIR=%EXEC_DIR% 92 | :findBaseDir 93 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 94 | cd .. 95 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 96 | set WDIR=%CD% 97 | goto findBaseDir 98 | 99 | :baseDirFound 100 | set MAVEN_PROJECTBASEDIR=%WDIR% 101 | cd "%EXEC_DIR%" 102 | goto endDetectBaseDir 103 | 104 | :baseDirNotFound 105 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 106 | cd "%EXEC_DIR%" 107 | 108 | :endDetectBaseDir 109 | 110 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 111 | 112 | @setlocal EnableExtensions EnableDelayedExpansion 113 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 114 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 115 | 116 | :endReadAdditionalConfig 117 | 118 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" 123 | 124 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 125 | IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | if "%MVNW_VERBOSE%" == "true" ( 132 | echo Found %WRAPPER_JAR% 133 | ) 134 | ) else ( 135 | if not "%MVNW_REPOURL%" == "" ( 136 | SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" 137 | ) 138 | if "%MVNW_VERBOSE%" == "true" ( 139 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 140 | echo Downloading from: %WRAPPER_URL% 141 | ) 142 | 143 | powershell -Command "&{"^ 144 | "$webclient = new-object System.Net.WebClient;"^ 145 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 146 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 147 | "}"^ 148 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ 149 | "}" 150 | if "%MVNW_VERBOSE%" == "true" ( 151 | echo Finished downloading %WRAPPER_JAR% 152 | ) 153 | ) 154 | @REM End of extension 155 | 156 | @REM Provide a "standardized" way to retrieve the CLI args that will 157 | @REM work with both Windows and non-Windows executions. 158 | set MAVEN_CMD_LINE_ARGS=%* 159 | 160 | %MAVEN_JAVA_EXE% ^ 161 | %JVM_CONFIG_MAVEN_PROPS% ^ 162 | %MAVEN_OPTS% ^ 163 | %MAVEN_DEBUG_OPTS% ^ 164 | -classpath %WRAPPER_JAR% ^ 165 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 166 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 167 | if ERRORLEVEL 1 goto error 168 | goto end 169 | 170 | :error 171 | set ERROR_CODE=1 172 | 173 | :end 174 | @endlocal & set ERROR_CODE=%ERROR_CODE% 175 | 176 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 177 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 178 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 179 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 180 | :skipRcPost 181 | 182 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 183 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 184 | 185 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 186 | 187 | cmd /C exit /B %ERROR_CODE% 188 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 4.0.0 23 | 24 | 25 | com.github.gantsign.parent 26 | kotlin-parent 27 | 3.4.1 28 | 29 | 30 | 31 | com.github.gantsign.maven.plugin-tools 32 | kotlin-maven-plugin-tools-parent 33 | ${revision} 34 | 35 | pom 36 | 37 | Kotlin Maven plugin Tools parent POM 38 | POM with shared configuration for the Kotlin Maven Plugin Tools project. 39 | 40 | 41 | kotlin-maven-plugin-tools 42 | 43 | 44 | 45 | 1.7.20 46 | 0.8.8 47 | 11 48 | 11 49 | 4.13.2 50 | 1.7.20 51 | 3.3.0 52 | 3.6.4 53 | 1.8.2 54 | 8 55 | 3.5.4 56 | 2.1.1 57 | 0.3.5 58 | 1.7.36 59 | 60 | 61 | 62 | 63 | 64 | com.google.guava 65 | guava 66 | 31.1-jre 67 | 68 | 69 | com.google.inject 70 | guice 71 | 5.1.0 72 | 73 | 74 | com.thoughtworks.qdox 75 | qdox 76 | 2.0.3 77 | 78 | 79 | commons-io 80 | commons-io 81 | 2.11.0 82 | 83 | 84 | javax.annotation 85 | javax.annotation-api 86 | 1.3.2 87 | 88 | 89 | javax.inject 90 | javax.inject 91 | 1 92 | 93 | 94 | org.apache.commons 95 | commons-lang3 96 | 3.12.0 97 | 98 | 99 | org.apache.httpcomponents 100 | httpcore 101 | 4.4.15 102 | 103 | 104 | org.apache.maven 105 | maven-artifact 106 | ${maven.version} 107 | 108 | 109 | org.apache.maven 110 | maven-compat 111 | ${maven.version} 112 | 113 | 114 | org.apache.maven 115 | maven-core 116 | ${maven.version} 117 | 118 | 119 | org.apache.maven 120 | maven-model 121 | ${maven.version} 122 | 123 | 124 | org.apache.maven 125 | maven-plugin-api 126 | ${maven.version} 127 | 128 | 129 | org.apache.maven 130 | maven-settings 131 | ${maven.version} 132 | 133 | 134 | org.apache.maven.plugin-testing 135 | maven-plugin-testing-harness 136 | 3.3.0 137 | 138 | 139 | org.apache.maven.plugin-tools 140 | maven-plugin-annotations 141 | ${maven-plugin-tools.version} 142 | 143 | 144 | org.apache.maven.plugin-tools 145 | maven-plugin-tools-annotations 146 | ${maven-plugin-tools.version} 147 | 148 | 149 | org.apache.maven.plugin-tools 150 | maven-plugin-tools-api 151 | ${maven-plugin-tools.version} 152 | 153 | 154 | org.apache.maven.plugins 155 | maven-jar-plugin 156 | 3.3.0 157 | 158 | 159 | org.apache.maven.resolver 160 | maven-resolver-api 161 | ${maven-resolver.version} 162 | 163 | 164 | org.apache.maven.resolver 165 | maven-resolver-connector-basic 166 | ${maven-resolver.version} 167 | 168 | 169 | org.apache.maven.resolver 170 | maven-resolver-impl 171 | ${maven-resolver.version} 172 | 173 | 174 | org.apache.maven.resolver 175 | maven-resolver-spi 176 | ${maven-resolver.version} 177 | 178 | 179 | org.apache.maven.resolver 180 | maven-resolver-transport-file 181 | ${maven-resolver.version} 182 | 183 | 184 | org.apache.maven.resolver 185 | maven-resolver-transport-http 186 | ${maven-resolver.version} 187 | 188 | 189 | org.apache.maven.resolver 190 | maven-resolver-util 191 | ${maven-resolver.version} 192 | 193 | 194 | org.apache.maven.shared 195 | maven-shared-utils 196 | 3.3.4 197 | 198 | 199 | org.apache.maven.wagon 200 | wagon-provider-api 201 | 3.5.2 202 | 203 | 204 | org.codehaus.plexus 205 | plexus-archiver 206 | 4.5.0 207 | 208 | 209 | org.codehaus.plexus 210 | plexus-component-annotations 211 | ${plexus-containers.version} 212 | 213 | 214 | org.codehaus.plexus 215 | plexus-interpolation 216 | 1.26 217 | 218 | 219 | org.codehaus.plexus 220 | plexus-utils 221 | 3.4.2 222 | 223 | 224 | org.eclipse.sisu 225 | org.eclipse.sisu.inject 226 | ${sisu.version} 227 | 228 | 229 | org.eclipse.sisu 230 | org.eclipse.sisu.plexus 231 | ${sisu.version} 232 | 233 | 234 | org.jetbrains 235 | markdown-jvm 236 | 0.3.1 237 | 238 | 239 | org.jetbrains.kotlin 240 | kotlin-compiler-embeddable 241 | ${kotlin.version} 242 | 243 | 244 | org.codehaus.plexus 245 | plexus-compiler-manager 246 | 2.12.1 247 | test 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | org.codehaus.mojo 257 | animal-sniffer-maven-plugin 258 | 1.22 259 | 260 | 261 | org.eclipse.sisu 262 | sisu-maven-plugin 263 | ${sisu.version} 264 | 265 | 266 | org.jetbrains.dokka 267 | dokka-maven-plugin 268 | ${dokka-maven-plugin.version} 269 | 270 | 271 | 272 | 273 | 274 | 275 | org.apache.maven.plugins 276 | maven-deploy-plugin 277 | false 278 | 279 | 280 | true 281 | 282 | 283 | 284 | org.apache.maven.plugins 285 | maven-enforcer-plugin 286 | 287 | 288 | enforce-versions 289 | 290 | enforce 291 | 292 | 293 | 294 | 295 | [3.5.0,3.9) 296 | 297 | 298 | [11,12) 299 | 300 | 301 | 302 | 303 | No Snapshots Allowed! 304 | true 305 | 306 | 307 | 308 | 309 | Best Practice is to always define plugin versions! 310 | true 311 | true 312 | true 313 | clean,deploy,site 314 | 315 | org.apache.maven.plugins:maven-javadoc-plugin 316 | org.apache.maven.plugins:maven-release-plugin 317 | org.apache.maven.plugins:maven-source-plugin 318 | 319 | 320 | 321 | 322 | org.apache.maven.plugins:maven-verifier-plugin 323 | 324 | Please consider using the maven-invoker-plugin (http://maven.apache.org/plugins/maven-invoker-plugin/)! 325 | 326 | 327 | Best Practice is to never define repositories in pom.xml (use a repository manager instead) 328 | 329 | 330 | true 331 | 332 | 333 | 8 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | org.codehaus.mojo 342 | animal-sniffer-maven-plugin 343 | 344 | 345 | org.codehaus.mojo.signature 346 | java18 347 | 1.0 348 | 349 | 350 | 351 | 352 | verify-java8 353 | 354 | check 355 | 356 | test 357 | 358 | 359 | 360 | 361 | org.codehaus.mojo 362 | build-helper-maven-plugin 363 | 364 | 365 | add-test-source 366 | 367 | add-test-source 368 | 369 | generate-test-sources 370 | 371 | 372 | src/test/java 373 | 374 | 375 | 376 | 377 | 378 | 379 | org.codehaus.mojo 380 | flatten-maven-plugin 381 | 382 | 383 | org.codehaus.mojo 384 | license-maven-plugin 385 | 386 | kotlin-maven-plugin-tools 387 | apache_v2 388 | 389 | 390 | 391 | config 392 | 393 | update-file-header 394 | 395 | process-sources 396 | 397 | ${basedir} 398 | .editorconfig,.gitattributes,pom.xml 399 | 400 | properties 401 | properties 402 | properties 403 | 404 | 405 | 406 | 407 | sources 408 | 409 | update-file-header 410 | 411 | process-sources 412 | 413 | 414 | 415 | 416 | org.jacoco 417 | jacoco-maven-plugin 418 | 419 | 420 | 421 | com/github/gantsign/maven/tools/plugin/extractor/kotlin/internal/model/** 422 | 423 | 424 | 425 | 426 | org.jetbrains.kotlin 427 | kotlin-maven-plugin 428 | 429 | 430 | compile 431 | 432 | compile 433 | 434 | process-sources 435 | 436 | 437 | 438 | 439 | 440 | 441 | https://github.com/gantsign/kotlin-maven-plugin-tools 442 | 443 | 2018 444 | 445 | 446 | GantSign Ltd. 447 | 448 | 449 | 450 | 451 | Apache License, Version 2.0 452 | https://opensource.org/licenses/Apache-2.0 453 | repo 454 | A business-friendly OSS license 455 | 456 | 457 | 458 | 459 | 460 | John Freeman 461 | https://github.com/freemanjp 462 | GantSign Ltd. 463 | 464 | architect 465 | developer 466 | 467 | Europe/London 468 | 469 | 470 | 471 | 472 | scm:git:https://github.com/gantsign/kotlin-maven-plugin-tools.git 473 | scm:git:git@github.com:gantsign/kotlin-maven-plugin-tools.git 474 | https://github.com/gantsign/kotlin-maven-plugin-tools 475 | HEAD 476 | 477 | 478 | 479 | GitHub 480 | https://github.com/gantsign/kotlin-maven-plugin-tools/issues 481 | 482 | 483 | 484 | GitHub Actions 485 | https://github.com/gantsign/kotlin-maven-plugin-tools/actions 486 | 487 | 488 | 489 | 490 | ossrh 491 | https://oss.sonatype.org/content/repositories/snapshots 492 | 493 | 494 | 495 | 496 | 497 | github 498 | 499 | 500 | 501 | env.GITHUB_ACTIONS 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | org.apache.maven.plugins 510 | maven-gpg-plugin 511 | 512 | 513 | --pinentry-mode 514 | loopback 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | publish-artifacts 525 | 526 | 527 | 528 | 529 | org.apache.maven.plugins 530 | maven-source-plugin 531 | 532 | 533 | attach-sources 534 | 535 | jar-no-fork 536 | 537 | 538 | 539 | 540 | 541 | org.jetbrains.dokka 542 | dokka-maven-plugin 543 | 544 | 545 | 546 | javadocJar 547 | 548 | package 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | --------------------------------------------------------------------------------