mirror of
https://github.com/HighCapable/Gropify.git
synced 2025-12-08 14:13:44 +08:00
Initial commit
This commit is contained in:
35
.editorconfig
Normal file
35
.editorconfig
Normal file
@@ -0,0 +1,35 @@
|
||||
# noinspection EditorConfigKeyCorrectness
|
||||
[{*.kt,*.kts}]
|
||||
ktlint_standard_annotation = disabled
|
||||
ktlint_standard_filename = disabled
|
||||
ktlint_standard_wrapping = disabled
|
||||
ktlint_standard_import-ordering = enabled
|
||||
ktlint_standard_max-line-length = disabled
|
||||
ktlint_standard_multiline-if-else = disabled
|
||||
ktlint_standard_argument-list-wrapping = disabled
|
||||
ktlint_standard_parameter-list-wrapping = disabled
|
||||
ktlint_standard_trailing-comma-on-declaration-site = disabled
|
||||
ktlint_function_signature_body_expression_wrapping = multiline
|
||||
ktlint_standard_string-template-indent = disabled
|
||||
ktlint_standard_function-signature = disabled
|
||||
ktlint_standard_trailing-comma-on-call-site = disabled
|
||||
ktlint_standard_multiline-expression-wrapping = disabled
|
||||
ktlint_standard_no-empty-first-line-in-class-body = disabled
|
||||
ktlint_standard_if-else-wrapping = disabled
|
||||
ktlint_standard_if-else-bracing = disabled
|
||||
ktlint_standard_statement-wrapping = disabled
|
||||
ktlint_standard_blank-line-before-declaration = disabled
|
||||
ktlint_standard_no-empty-file = disabled
|
||||
ktlint_standard_property-naming = disabled
|
||||
ktlint_standard_function-naming = disabled
|
||||
ktlint_standard_chain-method-continuation = disabled
|
||||
ktlint_standard_class-signature = disabled
|
||||
ktlint_standard_condition-wrapping = disabled
|
||||
ktlint_standard_class-signature = disabled
|
||||
ktlint_standard_no-trailing-spaces = disabled
|
||||
ktlint_standard_multiline-loop = disabled
|
||||
ij_continuation_indent_size = 2
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = false
|
||||
max_line_length = 150
|
||||
40
.github/workflows/docs-deploy.yml
vendored
Normal file
40
.github/workflows/docs-deploy.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
name: Deploy to GitHub pages
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ main ]
|
||||
paths:
|
||||
- 'gropify-gradle-plugin/src/**'
|
||||
- 'docs-source/**'
|
||||
- '.github/workflows/**'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
docs:
|
||||
if: ${{ success() }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
- name: Build VuePress site
|
||||
run: |
|
||||
cd docs-source
|
||||
yarn -i
|
||||
yarn docs:build-gh-pages
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: crazy-max/ghaction-github-pages@v4
|
||||
with:
|
||||
target_branch: gh-pages
|
||||
build_dir: docs-source/dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
120
.gitignore
vendored
Normal file
120
.gitignore
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
## Fully .gtignore for IntelliJ, Android Studio and Gradle based Java projects
|
||||
## References:
|
||||
## - https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
## - https://github.com/android/platform-samples/blob/main/.gitignore
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
.idea/.name
|
||||
.idea/artifacts
|
||||
.idea/compiler.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/modules.xml
|
||||
.idea/*.iml
|
||||
.idea/modules
|
||||
.idea/caches
|
||||
.idea/material_theme**
|
||||
.idea/other.xml
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
# Kotlin
|
||||
.kotlin
|
||||
.idea/kotlinc.xml
|
||||
|
||||
# Misc
|
||||
.idea/misc.xml
|
||||
.idea/markdown.xml
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
# Android studio 3.1+ additional
|
||||
.idea/deployment*.xml
|
||||
.idea/assetWizardSettings.xml
|
||||
.idea/androidTestResultsUserPreferences.xml
|
||||
|
||||
# Android projects
|
||||
.idea/AndroidProjectSystem.xml
|
||||
.idea/deviceManager.xml
|
||||
**/local.properties
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
|
||||
# Gradle projects
|
||||
.gradle
|
||||
build/
|
||||
|
||||
# Mkdocs temporary serving folder
|
||||
docs-gen
|
||||
site
|
||||
*.bak
|
||||
.idea/appInsightsSettings.xml
|
||||
|
||||
# Discord plugin for IntelliJ
|
||||
.idea/discord.xml
|
||||
|
||||
# Copilot for IntelliJ
|
||||
.idea/copilot**
|
||||
|
||||
# Mac OS
|
||||
.DS_Store
|
||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
1
.idea/fileTemplates/includes/copyright-name.template
generated
Normal file
1
.idea/fileTemplates/includes/copyright-name.template
generated
Normal file
@@ -0,0 +1 @@
|
||||
2019 HighCapable
|
||||
13
.idea/fileTemplates/includes/license-content.template
generated
Normal file
13
.idea/fileTemplates/includes/license-content.template
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
13
.idea/fileTemplates/includes/open-source-license-header.template
generated
Normal file
13
.idea/fileTemplates/includes/open-source-license-header.template
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* #parse("project-name") - #parse("project-description")
|
||||
|
||||
* Copyright (C) #parse("copyright-name")
|
||||
|
||||
* #parse("project-url")
|
||||
|
||||
*
|
||||
#parse("license-content")
|
||||
|
||||
*
|
||||
* This file is created by $USER on $DATE.
|
||||
*/
|
||||
1
.idea/fileTemplates/includes/project-description.template
generated
Normal file
1
.idea/fileTemplates/includes/project-description.template
generated
Normal file
@@ -0,0 +1 @@
|
||||
A type-safe and modern properties plugin for Gradle.
|
||||
1
.idea/fileTemplates/includes/project-name.template
generated
Normal file
1
.idea/fileTemplates/includes/project-name.template
generated
Normal file
@@ -0,0 +1 @@
|
||||
Gropify
|
||||
1
.idea/fileTemplates/includes/project-url.template
generated
Normal file
1
.idea/fileTemplates/includes/project-url.template
generated
Normal file
@@ -0,0 +1 @@
|
||||
https://github.com/HighCapable/Gropify
|
||||
6
.idea/fileTemplates/internal/Kotlin Annotation.kt
generated
Normal file
6
.idea/fileTemplates/internal/Kotlin Annotation.kt
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
#parse("open-source-license-header")
|
||||
|
||||
#if (${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
|
||||
#end
|
||||
|
||||
annotation class ${NAME}
|
||||
7
.idea/fileTemplates/internal/Kotlin Class.kt
generated
Normal file
7
.idea/fileTemplates/internal/Kotlin Class.kt
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
#parse("open-source-license-header")
|
||||
|
||||
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
|
||||
|
||||
#end
|
||||
class ${NAME} {
|
||||
}
|
||||
6
.idea/fileTemplates/internal/Kotlin Data Class.kt
generated
Normal file
6
.idea/fileTemplates/internal/Kotlin Data Class.kt
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
#parse("open-source-license-header")
|
||||
|
||||
#if (${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
|
||||
#end
|
||||
|
||||
data class ${NAME}()
|
||||
7
.idea/fileTemplates/internal/Kotlin Enum.kt
generated
Normal file
7
.idea/fileTemplates/internal/Kotlin Enum.kt
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
#parse("open-source-license-header")
|
||||
|
||||
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
|
||||
|
||||
#end
|
||||
enum class ${NAME} {
|
||||
}
|
||||
5
.idea/fileTemplates/internal/Kotlin File.kt
generated
Normal file
5
.idea/fileTemplates/internal/Kotlin File.kt
generated
Normal file
@@ -0,0 +1,5 @@
|
||||
#parse("open-source-license-header")
|
||||
|
||||
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
|
||||
|
||||
#end
|
||||
7
.idea/fileTemplates/internal/Kotlin Interface.kt
generated
Normal file
7
.idea/fileTemplates/internal/Kotlin Interface.kt
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
#parse("open-source-license-header")
|
||||
|
||||
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
|
||||
|
||||
#end
|
||||
interface ${NAME} {
|
||||
}
|
||||
7
.idea/fileTemplates/internal/Kotlin Object.kt
generated
Normal file
7
.idea/fileTemplates/internal/Kotlin Object.kt
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
#parse("open-source-license-header")
|
||||
|
||||
#if (${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
|
||||
#end
|
||||
|
||||
object ${NAME} {
|
||||
}
|
||||
16
.idea/icon.svg
generated
Normal file
16
.idea/icon.svg
generated
Normal file
@@ -0,0 +1,16 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="512" height="512" rx="128" fill="#434256"/>
|
||||
<path d="M165.49 165.49C215.477 115.503 296.523 115.503 346.51 165.49C396.497 215.477 396.497 296.523 346.51 346.51C334.685 358.335 321.121 367.362 306.642 373.592C303.452 374.965 299.999 372.555 299.999 369.082V339.791C299.999 337.961 301.005 336.286 302.583 335.358C309.178 331.482 315.393 326.714 321.054 321.054C356.982 285.126 356.982 226.874 321.054 190.946C285.126 155.018 226.874 155.018 190.946 190.946C155.018 226.874 155.018 285.126 190.946 321.054C196.607 326.714 202.821 331.482 209.415 335.358C210.993 336.286 211.999 337.961 211.999 339.791V369.082C211.999 372.555 208.546 374.964 205.356 373.592C190.878 367.362 177.315 358.334 165.49 346.51C115.503 296.523 115.503 215.477 165.49 165.49Z" fill="white"/>
|
||||
<path d="M235.361 102.5H276.639C280.539 102.5 283.789 105.49 284.113 109.377L286.779 141.377C287.144 145.75 283.693 149.5 279.306 149.5H232.694C228.307 149.5 224.856 145.75 225.221 141.377L227.887 109.377C228.211 105.49 231.461 102.5 235.361 102.5Z" fill="white" stroke="white"/>
|
||||
<path d="M133.661 163.046L163.046 133.661C165.765 130.942 170.101 130.72 173.084 133.147L191.006 147.735C194.453 150.541 194.719 155.712 191.576 158.855L158.854 191.576C155.712 194.719 150.541 194.454 147.735 191.006L133.147 173.084C130.72 170.101 130.942 165.765 133.661 163.046Z" fill="white" stroke="white"/>
|
||||
<path d="M378.339 163.046L348.954 133.661C346.235 130.942 341.899 130.72 338.916 133.147L320.994 147.735C317.547 150.541 317.281 155.712 320.424 158.855L353.146 191.576C356.288 194.719 361.459 194.454 364.265 191.006L378.853 173.084C381.28 170.101 381.058 165.765 378.339 163.046Z" fill="white" stroke="white"/>
|
||||
<path d="M133.659 348.96L163.044 378.345C165.763 381.064 170.098 381.286 173.081 378.859L191.004 364.271C194.451 361.465 194.716 356.294 191.574 353.151L158.852 320.43C155.709 317.287 150.538 317.552 147.732 321L133.145 338.922C130.717 341.905 130.939 346.241 133.659 348.96Z" fill="white" stroke="white"/>
|
||||
<path d="M378.336 348.96L348.951 378.345C346.231 381.064 341.896 381.286 338.913 378.858L320.989 364.27C317.542 361.464 317.277 356.293 320.42 353.15L353.141 320.429C356.284 317.286 361.455 317.551 364.261 320.998L378.849 338.922C381.277 341.905 381.055 346.24 378.336 348.96Z" fill="white" stroke="white"/>
|
||||
<path d="M409.5 235.361V276.639C409.5 280.539 406.51 283.789 402.623 284.113L370.623 286.779C366.25 287.144 362.5 283.693 362.5 279.306V232.694C362.5 228.307 366.25 224.856 370.623 225.221L402.623 227.887C406.51 228.211 409.5 231.461 409.5 235.361Z" fill="white" stroke="white"/>
|
||||
<path d="M102.5 276.639V235.361C102.5 231.461 105.49 228.211 109.377 227.887L141.377 225.221C145.75 224.856 149.5 228.307 149.5 232.694V279.306C149.5 283.693 145.75 287.144 141.377 286.779L109.377 284.113C105.49 283.789 102.5 280.539 102.5 276.639Z" fill="white" stroke="white"/>
|
||||
<path opacity="0.6" d="M280.3 398C280.3 401.727 280.3 403.591 279.691 405.062C278.879 407.022 277.322 408.579 275.361 409.391C273.891 410 272.027 410 268.3 410H243.7C239.973 410 238.109 410 236.639 409.391C234.678 408.579 233.121 407.022 232.309 405.062C231.7 403.591 231.7 401.727 231.7 398H280.3Z" fill="white"/>
|
||||
<path d="M280.3 398H231.7V263.391C236.076 267.895 245.313 271 256 271C266.687 271 275.924 267.895 280.3 263.391V398Z" fill="white"/>
|
||||
<path opacity="0.8" d="M276.976 249C278.273 249.8 279.391 250.674 280.3 251.61V263.39C275.924 267.894 266.688 271 256 271C245.313 271 236.076 267.895 231.7 263.391V251.609C232.609 250.674 233.727 249.799 235.023 249H276.976Z" fill="white"/>
|
||||
<path d="M243.315 225.463C246.767 228.298 251.185 230.001 256 230.001C260.815 230.001 265.233 228.298 268.685 225.464L277.42 244.375C279.513 248.906 280.559 251.173 280.248 253.006C280.077 254.011 279.653 254.945 279.031 255.729C278.789 256.126 278.504 256.518 278.173 256.901C276.967 258.296 275.199 259.564 272.971 260.632C270.742 261.7 268.095 262.547 265.184 263.125C262.272 263.703 259.151 264 256 264C252.848 264 249.727 263.703 246.815 263.125C243.904 262.547 241.258 261.7 239.029 260.632C236.801 259.564 235.032 258.296 233.826 256.901C233.495 256.518 233.209 256.125 232.967 255.728C232.345 254.945 231.923 254.01 231.752 253.006C231.441 251.173 232.487 248.906 234.58 244.375L243.315 225.463Z" fill="white"/>
|
||||
<path opacity="0.6" d="M253.361 206.92C255.026 206.105 256.972 206.106 258.637 206.92C260.552 207.858 261.94 210.861 264.715 216.868L268.684 225.462C265.232 228.297 260.815 229.999 256 229.999C251.184 229.999 246.766 228.297 243.314 225.461L247.284 216.868C250.059 210.861 251.446 207.858 253.361 206.92Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.6 KiB |
7
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
7
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="DuplicatedCode" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnstableApiUsage" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
202
LICENSE
Normal file
202
LICENSE
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright HighCapable [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
69
README-zh-CN.md
Normal file
69
README-zh-CN.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# Gropify
|
||||
|
||||
[](https://github.com/HighCapable/Gropify/blob/main/LICENSE)
|
||||
[](https://t.me/HighCapable_Dev)
|
||||
[](https://qm.qq.com/cgi-bin/qm/qr?k=Pnsc5RY6N2mBKFjOLPiYldbAbprAU3V7&jump_from=webapi&authKey=X5EsOVzLXt1dRunge8ryTxDRrh9/IiW1Pua75eDLh9RE3KXE+bwXIYF5cWri/9lf)
|
||||
|
||||
<img src="img-src/icon.svg" width = "100" height = "100" alt="LOGO"/>
|
||||
|
||||
一个类型安全且现代化的 Gradle 属性插件。
|
||||
|
||||
[English](README.md) | 简体中文
|
||||
|
||||
| <img src="https://github.com/HighCapable/.github/blob/main/img-src/logo.jpg?raw=true" width = "30" height = "30" alt="LOGO"/> | [HighCapable](https://github.com/HighCapable) |
|
||||
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
|
||||
|
||||
这个项目属于上述组织,**点击上方链接关注这个组织**,发现更多好项目。
|
||||
|
||||
## 这是什么
|
||||
|
||||
这是一个为 Gradle 构建脚本设计的插件,旨在将类似 `gradle.properties` 文件中的属性以类型安全的方式引入到构建脚本中,从而避免硬编码字符串可能带来的问题。
|
||||
|
||||
项目图标由 [MaiTungTM](https://github.com/Lagrio) 设计,名称取自 **G**radleP**ropify**,意为针对 Gradle 属性的插件。
|
||||
|
||||
它是基于 [SweetProperty](https://github.com/HighCapable/SweetProperty) 重构的全新项目,借鉴了以往的设计方案,使得其在原有基础上更加完善和易用。
|
||||
|
||||
`Gropify` 的配置方案与 `SweetProperty` 类似,如果你正在使用 `SweetProperty`,你可以考虑将其迁移到 `Gropify`。
|
||||
|
||||
## 开始使用
|
||||
|
||||
[点击这里](https://highcapable.github.io/Gropify/zh-cn) 前往文档页面查看更多详细教程和内容。
|
||||
|
||||
## 项目推广
|
||||
|
||||
<!--suppress HtmlDeprecatedAttribute -->
|
||||
<div align="center">
|
||||
<h2>嘿,还请君留步!👋</h2>
|
||||
<h3>这里有 Android 开发工具、UI 设计、Gradle 插件、Xposed 模块和实用软件等相关项目。</h3>
|
||||
<h3>如果下方的项目能为你提供帮助,不妨为我点个 star 吧!</h3>
|
||||
<h3>所有项目免费、开源,遵循对应开源许可协议。</h3>
|
||||
<h1><a href="https://github.com/fankes/fankes/blob/main/project-promote/README-zh-CN.md">→ 查看更多关于我的项目,请点击这里 ←</a></h1>
|
||||
</div>
|
||||
|
||||
## Star History
|
||||
|
||||

|
||||
|
||||
## 许可证
|
||||
|
||||
- [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
```
|
||||
Apache License Version 2.0
|
||||
|
||||
Copyright (C) 2019 HighCapable
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
```
|
||||
|
||||
版权所有 © 2019 HighCapable
|
||||
72
README.md
Normal file
72
README.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# Gropify
|
||||
|
||||
[](https://github.com/HighCapable/Gropify/blob/main/LICENSE)
|
||||
[](https://t.me/HighCapable_Dev)
|
||||
[](https://qm.qq.com/cgi-bin/qm/qr?k=Pnsc5RY6N2mBKFjOLPiYldbAbprAU3V7&jump_from=webapi&authKey=X5EsOVzLXt1dRunge8ryTxDRrh9/IiW1Pua75eDLh9RE3KXE+bwXIYF5cWri/9lf)
|
||||
|
||||
<img src="img-src/icon.svg" width = "100" height = "100" alt="LOGO"/>
|
||||
|
||||
A type-safe and modern properties plugin for Gradle.
|
||||
|
||||
English | [简体中文](README-zh-CN.md)
|
||||
|
||||
| <img src="https://github.com/HighCapable/.github/blob/main/img-src/logo.jpg?raw=true" width = "30" height = "30" alt="LOGO"/> | [HighCapable](https://github.com/HighCapable) |
|
||||
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
|
||||
|
||||
This project belongs to the above-mentioned organization, **click the link above to follow this organization** and discover more good projects.
|
||||
|
||||
## What's this
|
||||
|
||||
This plugin is designed for Gradle build scripts. It aims to bring properties similar to those in the `gradle.properties` file into build scripts in a
|
||||
type-safe way, avoiding problems that hard-coded strings might cause.
|
||||
|
||||
The project icon was designed by [MaiTungTM](https://github.com/Lagrio). The name comes from **G**radleP**ropify**, meaning a plugin for Gradle
|
||||
properties.
|
||||
|
||||
It is a brand-new project rebuilt from [SweetProperty](https://github.com/HighCapable/SweetProperty), borrowing previous design ideas and making it
|
||||
more polished and easier to use.
|
||||
|
||||
The configuration plan format of `Gropify` is similar to `SweetProperty`. If you are using `SweetProperty`, you can consider migrating to `Gropify`.
|
||||
|
||||
## Get Started
|
||||
|
||||
[Click here](https://highcapable.github.io/Gropify/en) go to the documentation page for more detailed tutorials and content.
|
||||
|
||||
## Promotion
|
||||
|
||||
<!--suppress HtmlDeprecatedAttribute -->
|
||||
<div align="center">
|
||||
<h2>Hey, please stay! 👋</h2>
|
||||
<h3>Here are related projects such as Android development tools, UI design, Gradle plugins, Xposed Modules and practical software. </h3>
|
||||
<h3>If the project below can help you, please give me a star! </h3>
|
||||
<h3>All projects are free, open source, and follow the corresponding open source license agreement. </h3>
|
||||
<h1><a href="https://github.com/fankes/fankes/blob/main/project-promote/README.md">→ To see more about my projects, please click here ←</a></h1>
|
||||
</div>
|
||||
|
||||
## Star History
|
||||
|
||||

|
||||
|
||||
## License
|
||||
|
||||
- [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
```
|
||||
Apache License Version 2.0
|
||||
|
||||
Copyright (C) 2019 HighCapable
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
```
|
||||
|
||||
Copyright © 2019 HighCapable
|
||||
4
build.gradle.kts
Normal file
4
build.gradle.kts
Normal file
@@ -0,0 +1,4 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.jvm) apply false
|
||||
alias(libs.plugins.maven.publish) apply false
|
||||
}
|
||||
4
docs-source/.gitignore
vendored
Normal file
4
docs-source/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/node_modules
|
||||
/src/.vuepress/.cache
|
||||
/src/.vuepress/.temp
|
||||
/dist
|
||||
3
docs-source/.vscode/settings.json
vendored
Normal file
3
docs-source/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"git.ignoreLimitWarning": true
|
||||
}
|
||||
17
docs-source/package.json
Normal file
17
docs-source/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "gropify_docs",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@mr-hope/vuepress-plugin-copy-code": "^1.30.0",
|
||||
"@vuepress/plugin-prismjs": "2.0.0-rc.0",
|
||||
"@vuepress/plugin-search": "2.0.0-rc.0",
|
||||
"@vuepress/plugin-shiki": "2.0.0-rc.0",
|
||||
"vuepress": "2.0.0-rc.0"
|
||||
},
|
||||
"scripts": {
|
||||
"docs:dev": "vuepress dev src",
|
||||
"docs:build": "vuepress build src",
|
||||
"docs:build-gh-pages": "vuepress build src && touch dist/.nojekyll"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
64
docs-source/src/.vuepress/config.ts
Normal file
64
docs-source/src/.vuepress/config.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { defaultTheme } from 'vuepress';
|
||||
import { shikiPlugin } from '@vuepress/plugin-shiki';
|
||||
import { searchPlugin } from '@vuepress/plugin-search';
|
||||
import { navBarItems, sideBarItems, configs, pageLinkRefs } from './configs/template';
|
||||
import { env, markdown } from './configs/utils';
|
||||
|
||||
export default {
|
||||
dest: configs.dev.dest,
|
||||
port: configs.dev.port,
|
||||
base: configs.website.base,
|
||||
head: [['link', { rel: 'icon', href: configs.website.icon }]],
|
||||
title: configs.website.title,
|
||||
description: configs.website.locales['/en/'].description,
|
||||
locales: configs.website.locales,
|
||||
theme: defaultTheme({
|
||||
logo: configs.website.logo,
|
||||
repo: configs.github.repo,
|
||||
docsRepo: configs.github.repo,
|
||||
docsBranch: configs.github.branch,
|
||||
docsDir: configs.github.dir,
|
||||
editLinkPattern: ':repo/edit/:branch/:path',
|
||||
sidebar: sideBarItems,
|
||||
sidebarDepth: 2,
|
||||
locales: {
|
||||
'/en/': {
|
||||
navbar: navBarItems['/en/'],
|
||||
selectLanguageText: 'English (US)',
|
||||
selectLanguageName: 'English',
|
||||
editLinkText: 'Edit this page on GitHub',
|
||||
tip: 'Tips',
|
||||
warning: 'Notice',
|
||||
danger: 'Pay Attention',
|
||||
},
|
||||
'/zh-cn/': {
|
||||
navbar: navBarItems['/zh-cn/'],
|
||||
selectLanguageText: '简体中文 (CN)',
|
||||
selectLanguageName: '简体中文',
|
||||
editLinkText: '在 GitHub 上编辑此页',
|
||||
notFound: ['这里什么都没有', '我们怎么到这来了?', '这是一个 404 页面', '看起来我们进入了错误的链接'],
|
||||
backToHome: '回到首页',
|
||||
contributorsText: '贡献者',
|
||||
lastUpdatedText: '上次更新',
|
||||
tip: '小提示',
|
||||
warning: '注意',
|
||||
danger: '特别注意',
|
||||
openInNewWindow: '在新窗口中打开',
|
||||
toggleColorMode: '切换颜色模式'
|
||||
}
|
||||
},
|
||||
}),
|
||||
extendsMarkdown: (md: markdownit) => {
|
||||
markdown.injectLinks(md, env.dev ? pageLinkRefs.dev : pageLinkRefs.prod);
|
||||
},
|
||||
plugins: [
|
||||
shikiPlugin({ theme: 'github-dark-dimmed' }),
|
||||
searchPlugin({
|
||||
isSearchable: (page) => page.path !== '/',
|
||||
locales: {
|
||||
'/en/': { placeholder: 'Search' },
|
||||
'/zh-cn/': { placeholder: '搜索' }
|
||||
}
|
||||
})
|
||||
]
|
||||
};
|
||||
107
docs-source/src/.vuepress/configs/template.ts
Normal file
107
docs-source/src/.vuepress/configs/template.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
import { i18n } from './utils';
|
||||
|
||||
interface PageLinkRefs {
|
||||
dev: Record<string, string>[];
|
||||
prod: Record<string, string>[];
|
||||
}
|
||||
|
||||
const navigationLinks = {
|
||||
start: [
|
||||
'/guide/home',
|
||||
'/guide/quick-start'
|
||||
],
|
||||
about: [
|
||||
'/about/changelog',
|
||||
'/about/future',
|
||||
'/about/contacts',
|
||||
'/about/about'
|
||||
]
|
||||
};
|
||||
|
||||
export const configs = {
|
||||
dev: {
|
||||
dest: 'dist',
|
||||
port: 9000
|
||||
},
|
||||
website: {
|
||||
base: '/Gropify/',
|
||||
icon: '/Gropify/images/logo.svg',
|
||||
logo: '/images/logo.svg',
|
||||
title: 'Gropify',
|
||||
locales: {
|
||||
'/en/': {
|
||||
lang: 'en-US',
|
||||
description: 'A type-safe and modern properties plugin for Gradle'
|
||||
},
|
||||
'/zh-cn/': {
|
||||
lang: 'zh-CN',
|
||||
description: '一个类型安全且现代化的 Gradle 属性插件'
|
||||
}
|
||||
}
|
||||
},
|
||||
github: {
|
||||
repo: 'https://github.com/HighCapable/Gropify',
|
||||
page: 'https://highcapable.github.io/Gropify',
|
||||
branch: 'main',
|
||||
dir: 'docs-source/src'
|
||||
}
|
||||
};
|
||||
|
||||
export const pageLinkRefs: PageLinkRefs = {
|
||||
dev: [
|
||||
{ 'repo://': `${configs.github.repo}/` }
|
||||
],
|
||||
prod: [
|
||||
{ 'repo://': `${configs.github.repo}/` }
|
||||
]
|
||||
};
|
||||
|
||||
export const navBarItems = {
|
||||
'/en/': [{
|
||||
text: 'Navigation',
|
||||
children: [{
|
||||
text: 'Get Started',
|
||||
children: i18n.array(navigationLinks.start, 'en')
|
||||
}, {
|
||||
text: 'About',
|
||||
children: i18n.array(navigationLinks.about, 'en')
|
||||
}]
|
||||
}, {
|
||||
text: 'Contact Us',
|
||||
link: i18n.string(navigationLinks.about[2], 'en')
|
||||
}],
|
||||
'/zh-cn/': [{
|
||||
text: '导航',
|
||||
children: [{
|
||||
text: '入门',
|
||||
children: i18n.array(navigationLinks.start, 'zh-cn')
|
||||
}, {
|
||||
text: '关于',
|
||||
children: i18n.array(navigationLinks.about, 'zh-cn')
|
||||
}]
|
||||
}, {
|
||||
text: '联系我们',
|
||||
link: i18n.string(navigationLinks.about[2], 'zh-cn')
|
||||
}]
|
||||
};
|
||||
|
||||
export const sideBarItems = {
|
||||
'/en/': [{
|
||||
text: 'Get Started',
|
||||
collapsible: true,
|
||||
children: i18n.array(navigationLinks.start, 'en')
|
||||
}, {
|
||||
text: 'About',
|
||||
collapsible: true,
|
||||
children: i18n.array(navigationLinks.about, 'en')
|
||||
}],
|
||||
'/zh-cn/': [{
|
||||
text: '入门',
|
||||
collapsible: true,
|
||||
children: i18n.array(navigationLinks.start, 'zh-cn')
|
||||
}, {
|
||||
text: '关于',
|
||||
collapsible: true,
|
||||
children: i18n.array(navigationLinks.about, 'zh-cn')
|
||||
}]
|
||||
};
|
||||
39
docs-source/src/.vuepress/configs/utils.ts
Normal file
39
docs-source/src/.vuepress/configs/utils.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
export const env = {
|
||||
dev: process.env.NODE_ENV === 'development'
|
||||
};
|
||||
|
||||
export const i18n = {
|
||||
space: ' ',
|
||||
string: (content: string, locale: string) => {
|
||||
return '/' + locale + content;
|
||||
},
|
||||
array: (contents: string[], locale: string) => {
|
||||
const newContents: string[] = [];
|
||||
contents.forEach((content) => {
|
||||
newContents.push(i18n.string(content, locale));
|
||||
});
|
||||
return newContents;
|
||||
}
|
||||
};
|
||||
|
||||
export const markdown = {
|
||||
injectLinks: (md: markdownit, maps: Record<string, string>[]) => {
|
||||
const defaultRender = md.renderer.rules.link_open || function (tokens, idx, options, _env, self) {
|
||||
return self.renderToken(tokens, idx, options);
|
||||
};
|
||||
md.renderer.rules.link_open = function (tokens, idx, options, env, self) {
|
||||
const hrefIndex = tokens[idx].attrIndex('href');
|
||||
let current = tokens[idx].attrs!![hrefIndex][1];
|
||||
for (const map of maps) {
|
||||
for (const [search, replace] of Object.entries(map)) {
|
||||
if (current.startsWith(search)) {
|
||||
current = current.replace(search, replace);
|
||||
tokens[idx].attrs!![hrefIndex][1] = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return defaultRender(tokens, idx, options, env, self);
|
||||
};
|
||||
}
|
||||
};
|
||||
16
docs-source/src/.vuepress/public/images/logo.svg
Normal file
16
docs-source/src/.vuepress/public/images/logo.svg
Normal file
@@ -0,0 +1,16 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="512" height="512" rx="128" fill="#434256"/>
|
||||
<path d="M165.49 165.49C215.477 115.503 296.523 115.503 346.51 165.49C396.497 215.477 396.497 296.523 346.51 346.51C334.685 358.335 321.121 367.362 306.642 373.592C303.452 374.965 299.999 372.555 299.999 369.082V339.791C299.999 337.961 301.005 336.286 302.583 335.358C309.178 331.482 315.393 326.714 321.054 321.054C356.982 285.126 356.982 226.874 321.054 190.946C285.126 155.018 226.874 155.018 190.946 190.946C155.018 226.874 155.018 285.126 190.946 321.054C196.607 326.714 202.821 331.482 209.415 335.358C210.993 336.286 211.999 337.961 211.999 339.791V369.082C211.999 372.555 208.546 374.964 205.356 373.592C190.878 367.362 177.315 358.334 165.49 346.51C115.503 296.523 115.503 215.477 165.49 165.49Z" fill="white"/>
|
||||
<path d="M235.361 102.5H276.639C280.539 102.5 283.789 105.49 284.113 109.377L286.779 141.377C287.144 145.75 283.693 149.5 279.306 149.5H232.694C228.307 149.5 224.856 145.75 225.221 141.377L227.887 109.377C228.211 105.49 231.461 102.5 235.361 102.5Z" fill="white" stroke="white"/>
|
||||
<path d="M133.661 163.046L163.046 133.661C165.765 130.942 170.101 130.72 173.084 133.147L191.006 147.735C194.453 150.541 194.719 155.712 191.576 158.855L158.854 191.576C155.712 194.719 150.541 194.454 147.735 191.006L133.147 173.084C130.72 170.101 130.942 165.765 133.661 163.046Z" fill="white" stroke="white"/>
|
||||
<path d="M378.339 163.046L348.954 133.661C346.235 130.942 341.899 130.72 338.916 133.147L320.994 147.735C317.547 150.541 317.281 155.712 320.424 158.855L353.146 191.576C356.288 194.719 361.459 194.454 364.265 191.006L378.853 173.084C381.28 170.101 381.058 165.765 378.339 163.046Z" fill="white" stroke="white"/>
|
||||
<path d="M133.659 348.96L163.044 378.345C165.763 381.064 170.098 381.286 173.081 378.859L191.004 364.271C194.451 361.465 194.716 356.294 191.574 353.151L158.852 320.43C155.709 317.287 150.538 317.552 147.732 321L133.145 338.922C130.717 341.905 130.939 346.241 133.659 348.96Z" fill="white" stroke="white"/>
|
||||
<path d="M378.336 348.96L348.951 378.345C346.231 381.064 341.896 381.286 338.913 378.858L320.989 364.27C317.542 361.464 317.277 356.293 320.42 353.15L353.141 320.429C356.284 317.286 361.455 317.551 364.261 320.998L378.849 338.922C381.277 341.905 381.055 346.24 378.336 348.96Z" fill="white" stroke="white"/>
|
||||
<path d="M409.5 235.361V276.639C409.5 280.539 406.51 283.789 402.623 284.113L370.623 286.779C366.25 287.144 362.5 283.693 362.5 279.306V232.694C362.5 228.307 366.25 224.856 370.623 225.221L402.623 227.887C406.51 228.211 409.5 231.461 409.5 235.361Z" fill="white" stroke="white"/>
|
||||
<path d="M102.5 276.639V235.361C102.5 231.461 105.49 228.211 109.377 227.887L141.377 225.221C145.75 224.856 149.5 228.307 149.5 232.694V279.306C149.5 283.693 145.75 287.144 141.377 286.779L109.377 284.113C105.49 283.789 102.5 280.539 102.5 276.639Z" fill="white" stroke="white"/>
|
||||
<path opacity="0.6" d="M280.3 398C280.3 401.727 280.3 403.591 279.691 405.062C278.879 407.022 277.322 408.579 275.361 409.391C273.891 410 272.027 410 268.3 410H243.7C239.973 410 238.109 410 236.639 409.391C234.678 408.579 233.121 407.022 232.309 405.062C231.7 403.591 231.7 401.727 231.7 398H280.3Z" fill="white"/>
|
||||
<path d="M280.3 398H231.7V263.391C236.076 267.895 245.313 271 256 271C266.687 271 275.924 267.895 280.3 263.391V398Z" fill="white"/>
|
||||
<path opacity="0.8" d="M276.976 249C278.273 249.8 279.391 250.674 280.3 251.61V263.39C275.924 267.894 266.688 271 256 271C245.313 271 236.076 267.895 231.7 263.391V251.609C232.609 250.674 233.727 249.799 235.023 249H276.976Z" fill="white"/>
|
||||
<path d="M243.315 225.463C246.767 228.298 251.185 230.001 256 230.001C260.815 230.001 265.233 228.298 268.685 225.464L277.42 244.375C279.513 248.906 280.559 251.173 280.248 253.006C280.077 254.011 279.653 254.945 279.031 255.729C278.789 256.126 278.504 256.518 278.173 256.901C276.967 258.296 275.199 259.564 272.971 260.632C270.742 261.7 268.095 262.547 265.184 263.125C262.272 263.703 259.151 264 256 264C252.848 264 249.727 263.703 246.815 263.125C243.904 262.547 241.258 261.7 239.029 260.632C236.801 259.564 235.032 258.296 233.826 256.901C233.495 256.518 233.209 256.125 232.967 255.728C232.345 254.945 231.923 254.01 231.752 253.006C231.441 251.173 232.487 248.906 234.58 244.375L243.315 225.463Z" fill="white"/>
|
||||
<path opacity="0.6" d="M253.361 206.92C255.026 206.105 256.972 206.106 258.637 206.92C260.552 207.858 261.94 210.861 264.715 216.868L268.684 225.462C265.232 228.297 260.815 229.999 256 229.999C251.184 229.999 246.766 228.297 243.314 225.461L247.284 216.868C250.059 210.861 251.446 207.858 253.361 206.92Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.6 KiB |
179
docs-source/src/.vuepress/styles/index.scss
Normal file
179
docs-source/src/.vuepress/styles/index.scss
Normal file
@@ -0,0 +1,179 @@
|
||||
$primary-color: rgb(98, 95, 124);
|
||||
$accent-color: rgb(145, 132, 151);
|
||||
$content-width: 965px;
|
||||
$scroll-bar-width: 8px;
|
||||
$scroll-bar-height: 6.5px;
|
||||
$scroll-bar-border-radius: 50px;
|
||||
$scroll-bar-track-color-code: rgb(98, 95, 124);
|
||||
$scroll-bar-thumb-hover-color-code: rgb(145, 132, 151);
|
||||
|
||||
:root {
|
||||
--c-brand: #{$primary-color};
|
||||
--c-brand-light: #{$accent-color};
|
||||
--content-width: #{$content-width};
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 3px 5px 3px 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.badge {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.custom-container {
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.sidebar-item {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.language-text {
|
||||
::-webkit-scrollbar-track {
|
||||
background: #{$scroll-bar-track-color-code};
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #{$scroll-bar-thumb-hover-color-code};
|
||||
}
|
||||
}
|
||||
|
||||
.language-kotlin {
|
||||
::-webkit-scrollbar-track {
|
||||
background: #{$scroll-bar-track-color-code};
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #{$scroll-bar-thumb-hover-color-code};
|
||||
}
|
||||
}
|
||||
|
||||
.language-java {
|
||||
::-webkit-scrollbar-track {
|
||||
background: #{$scroll-bar-track-color-code};
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #{$scroll-bar-thumb-hover-color-code};
|
||||
}
|
||||
}
|
||||
|
||||
.language-groovy {
|
||||
::-webkit-scrollbar-track {
|
||||
background: #{$scroll-bar-track-color-code};
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #{$scroll-bar-thumb-hover-color-code};
|
||||
}
|
||||
}
|
||||
|
||||
.language-xml {
|
||||
::-webkit-scrollbar-track {
|
||||
background: #{$scroll-bar-track-color-code};
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #{$scroll-bar-thumb-hover-color-code};
|
||||
}
|
||||
}
|
||||
|
||||
.hidden-anchor-page {
|
||||
h6 {
|
||||
color: transparent;
|
||||
margin-bottom: -35px;
|
||||
padding-top: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
.code-page {
|
||||
h1 {
|
||||
font-size: 24pt;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 18pt;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 15pt;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 9.6pt;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 8.4pt;
|
||||
}
|
||||
|
||||
.symbol {
|
||||
color: rgb(142, 155, 168);
|
||||
}
|
||||
|
||||
.deprecated {
|
||||
color: rgb(142, 155, 168);
|
||||
text-decoration: line-through;
|
||||
}
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: #{$scroll-bar-width};
|
||||
height: #{$scroll-bar-height};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: rgb(234, 236, 239);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgb(189, 189, 189);
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgb(133, 133, 133);
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
}
|
||||
|
||||
html.dark {
|
||||
--c-brand: #{$primary-color};
|
||||
--c-brand-light: #{$accent-color};
|
||||
--content-width: #{$content-width};
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: #{$scroll-bar-width};
|
||||
height: #{$scroll-bar-height};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: rgb(41, 46, 53);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgb(65, 72, 83);
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgb(56, 62, 72);
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
}
|
||||
27
docs-source/src/en/about/about.md
Normal file
27
docs-source/src/en/about/about.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# About This Document
|
||||
|
||||
> This document is powered by [VuePress](https://v2.vuepress.vuejs.org/en).
|
||||
|
||||
## License
|
||||
|
||||
[Apache-2.0](https://github.com/HighCapable/Gropify/blob/main/LICENSE)
|
||||
|
||||
```:no-line-numbers
|
||||
Apache License Version 2.0
|
||||
|
||||
Copyright (C) 2019 HighCapable
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
```
|
||||
|
||||
Copyright © 2019 HighCapable
|
||||
21
docs-source/src/en/about/changelog.md
Normal file
21
docs-source/src/en/about/changelog.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Changelog
|
||||
|
||||
> The version update history of `Gropify` is recorded here.
|
||||
|
||||
::: danger
|
||||
|
||||
We will only maintain the latest API version. If you are using an outdated API version, you voluntarily renounce any possibility of maintenance.
|
||||
|
||||
:::
|
||||
|
||||
::: warning
|
||||
|
||||
To avoid translation time consumption, Changelog will use **Google Translation** from **Chinese** to **English**, please refer to the original text for actual reference.
|
||||
|
||||
Time zone of version release date: **UTC+8**
|
||||
|
||||
:::
|
||||
|
||||
### 1.0.0 | 2025.11.11  <Badge type="tip" text="latest" vertical="middle" />
|
||||
|
||||
- The first version is submitted to Maven
|
||||
15
docs-source/src/en/about/contacts.md
Normal file
15
docs-source/src/en/about/contacts.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Contact Us
|
||||
|
||||
> If you have any questions during usage, or have any constructive suggestions, you can contact us.
|
||||
|
||||
Join our developers group.
|
||||
|
||||
- [Click to join Telegram group (Developer)](https://t.me/HighCapable_Dev)
|
||||
|
||||
Find me on **Twitter** [@fankesyooni](https://twitter.com/fankesyooni).
|
||||
|
||||
## Help with Maintenance
|
||||
|
||||
Thank you for choosing and using `Gropify`.
|
||||
|
||||
If you have code-related suggestions and requests, you can submit a Pull Request on GitHub.
|
||||
12
docs-source/src/en/about/future.md
Normal file
12
docs-source/src/en/about/future.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Looking Toward the Future
|
||||
|
||||
> The future is bright and uncertain, let us look forward to the future development potential of `Gropify`.
|
||||
|
||||
## Future Plans
|
||||
|
||||
> Features that `Gropify` may add later are included here.
|
||||
|
||||
### Support More Project Types
|
||||
|
||||
`Gropify` currently supports generating properties into the source code of Kotlin, Java, and Android projects.
|
||||
In the future, it may support more projects that can participate in Gradle builds, such as C/C++ (Android JNI), Swift, etc., to meet the needs of more developers.
|
||||
71
docs-source/src/en/guide/home.md
Normal file
71
docs-source/src/en/guide/home.md
Normal file
@@ -0,0 +1,71 @@
|
||||
# Introduction
|
||||
|
||||
> `Gropify` is a type-safe and modern properties plugin for Gradle.
|
||||
|
||||
## Background
|
||||
|
||||
This plugin is designed for Gradle build scripts. It aims to bring properties similar to those in the `gradle.properties` file into build scripts in a type-safe way, avoiding problems that hard-coded strings might cause.
|
||||
|
||||
The project icon was designed by [MaiTungTM](https://github.com/Lagrio). The name comes from **G**radleP**ropify**, meaning a plugin for Gradle properties.
|
||||
|
||||
It is a brand-new project rebuilt from [SweetProperty](https://github.com/HighCapable/SweetProperty), borrowing previous design ideas and making it more polished and easier to use.
|
||||
|
||||
The configuration plan format of `Gropify` is similar to `SweetProperty`. If you are using `SweetProperty`, you can consider migrating to `Gropify`.
|
||||
|
||||
## Usage
|
||||
|
||||
`Gropify` is mainly designed for Kotlin DSL build scripts. Groovy can directly use properties from the `gradle.properties` file as variables, but you can still use `Gropify` to achieve type-safe property access.
|
||||
|
||||
`Gropify` also supports generating properties (similar to those defined in a `gradle.properties` file) in a type-safe way into the source code of Kotlin, Java, and Android projects for use at application runtime—similar to Android's `BuildConfig`'s `buildConfigField` feature.
|
||||
|
||||
Suppose we have the following `gradle.properties` file.
|
||||
|
||||
> The following example
|
||||
|
||||
```properties
|
||||
project.app.name=Gropify-Demo
|
||||
project.app.version=1.0.0
|
||||
```
|
||||
|
||||
Here is an example of calling the code automatically generated by `Gropify`.
|
||||
|
||||
> Build Script (Kotlin DSL, Groovy DSL)
|
||||
|
||||
```kotlin
|
||||
val appName = gropify.project.app.name
|
||||
val appVersion = gropify.project.app.version
|
||||
```
|
||||
|
||||
```groovy
|
||||
def appName = gropify.project.app.name
|
||||
def appVersion = gropify.project.app.version
|
||||
```
|
||||
|
||||
> Source Code (Kotlin, Java)
|
||||
|
||||
```kotlin
|
||||
val appName = MyAppProperties.PROJECT_APP_NAME
|
||||
val appVersion = MyAppProperties.PROJECT_APP_VERSION
|
||||
```
|
||||
|
||||
```java
|
||||
var appName = MyAppProperties.PROJECT_APP_NAME;
|
||||
var appVersion = MyAppProperties.PROJECT_APP_VERSION;
|
||||
```
|
||||
|
||||
`Gropify` also supports Kotlin Multiplatform projects, and you can use the generated property classes in the `commonMain` source set.
|
||||
|
||||
## Language Requirement
|
||||
|
||||
It's recommended to use Kotlin DSL to configure your project's build scripts. Groovy is also supported, but in pure Groovy projects some configuration syntax may have compatibility issues.
|
||||
|
||||
In Groovy DSL, we will no longer be responsible for troubleshooting and fixing any issues that arise from using this plugin, and it may be completely unsupported in future versions.
|
||||
|
||||
## Contribution
|
||||
|
||||
The maintenance of this project is inseparable from the support and contributions of all developers.
|
||||
|
||||
This project is currently in its early stages, and there may still be some problems or lack of functions you need.
|
||||
|
||||
If possible, feel free to submit a PR to contribute features you think are needed to this project or go to [GitHub Issues](repo://issues)
|
||||
to make suggestions to us.
|
||||
691
docs-source/src/en/guide/quick-start.md
Normal file
691
docs-source/src/en/guide/quick-start.md
Normal file
@@ -0,0 +1,691 @@
|
||||
# Quick Start
|
||||
|
||||
> Integrate `Gropify` into your project.
|
||||
|
||||
## Deploy Plugin
|
||||
|
||||

|
||||
<span style="margin-left: 5px"/>
|
||||

|
||||
|
||||
`Gropify` dependencies are published on **Maven Central** and our public repository. You can configure the repository as follows.
|
||||
|
||||
We recommend using Gradle version `7.x.x` or higher, and recommend using Kotlin DSL as the Gradle build script language. This documentation will no longer detail how to use it in Groovy DSL.
|
||||
|
||||
We recommend using the new `pluginManagement` method for deployment, which is a feature added since Gradle version `7.x.x`.
|
||||
|
||||
If your project is still using `buildscript` for management, we recommend migrating to the new method. Instructions for the old version will no longer be provided here.
|
||||
|
||||
First, configure the plugin repository in your project's `settings.gradle.kts`.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal() // Optional
|
||||
google() // Optional
|
||||
mavenCentral() // Required
|
||||
// (Optional) You can add this URL to use our public repository
|
||||
// This repository is added as an alternative when Sonatype-OSS fails to publish dependencies
|
||||
// For details, please visit: https://github.com/HighCapable/maven-repository
|
||||
maven("https://raw.githubusercontent.com/HighCapable/maven-repository/main/repository/releases")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then add the `Gropify` plugin dependency in `plugin` in `settings.gradle.kts`. Please note **do not** add `apply false` after it.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
plugins {
|
||||
id("com.highcapable.gropify") version "<version>"
|
||||
}
|
||||
```
|
||||
|
||||
Please replace `<version>` with the version shown at the top of this section.
|
||||
|
||||
After completing the above configuration, run Gradle sync once.
|
||||
|
||||
`Gropify` will automatically search for `gradle.properties` files in the root project and each subproject, read the property key-values in them, and generate corresponding code for each project.
|
||||
|
||||
::: warning
|
||||
|
||||
`Gropify` can only be applied to `settings.gradle.kts`, configuring it once will take effect globally. Please do not apply it to `build.gradle.kts`, otherwise the functionality will be invalid.
|
||||
|
||||
:::
|
||||
|
||||
## Feature Configuration
|
||||
|
||||
You can configure `Gropify` to implement customization and personalized features.
|
||||
|
||||
`Gropify` provides relatively rich customizable features. Below are the descriptions and configuration methods for these features.
|
||||
|
||||
Please add the `gropify` method block in your `settings.gradle.kts` to start configuring `Gropify`.
|
||||
|
||||
To use in Groovy DSL, please change all variable `=` to spaces, remove `is` before `Enabled`.
|
||||
|
||||
If you encounter a `Gradle DSL method not found` error, the solution is to migrate to Kotlin DSL.
|
||||
|
||||
If you don't want to use Kotlin DSL entirely, you can also migrate only `settings.gradle` to `settings.gradle.kts`.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
gropify {
|
||||
// Enable Gropify, setting it to `false` will disable all features
|
||||
isEnabled = true
|
||||
}
|
||||
```
|
||||
|
||||
`Gropify`'s configuration mode is divided into three types: `global` global configuration, and `rootProject`, `projects` root project and subproject configuration.
|
||||
|
||||
You can continue to configure and integrate the configuration of the parent project in the child code blocks.
|
||||
|
||||
All configurations below are performed in the `gropify` method block.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// Global configuration.
|
||||
//
|
||||
// You can modify configurations in all projects in the global configuration.
|
||||
// Configurations not declared in each project will use the global configuration.
|
||||
// The functions in each configuration method block are exactly the same.
|
||||
//
|
||||
// You can refer to the configuration methods of root project and subprojects below.
|
||||
global {
|
||||
// Common configuration.
|
||||
common {
|
||||
// Configure "common".
|
||||
}
|
||||
|
||||
// Build script configuration.
|
||||
buildscript {
|
||||
// Configure "buildscript".
|
||||
}
|
||||
|
||||
// Android project configuration.
|
||||
android {
|
||||
// Configure "android".
|
||||
}
|
||||
|
||||
// JVM project configuration.
|
||||
jvm {
|
||||
// Configure "jvm".
|
||||
}
|
||||
|
||||
// Kotlin Multiplatform project configuration.
|
||||
kmp {
|
||||
// Configure "kmp".
|
||||
}
|
||||
}
|
||||
|
||||
// Root project configuration.
|
||||
//
|
||||
// This is a special configuration method block that can only be used for the root project.
|
||||
rootProject {
|
||||
common {
|
||||
// Configure "common".
|
||||
}
|
||||
buildscript {
|
||||
// Configure "buildscript".
|
||||
}
|
||||
android {
|
||||
// Configure "android".
|
||||
}
|
||||
jvm {
|
||||
// Configure "jvm".
|
||||
}
|
||||
kmp {
|
||||
// Configure "kmp".
|
||||
}
|
||||
}
|
||||
|
||||
// Other projects and subprojects configuration.
|
||||
//
|
||||
// Fill in the full name of the project you need to configure in the
|
||||
// method parameters to configure the corresponding project.
|
||||
//
|
||||
// If the current project is a subproject, you must include the ":" before
|
||||
// the subproject name, such as ":app".
|
||||
//
|
||||
// If the current project is a nested subproject, such as app → sub,
|
||||
// you need to use ":" to separate multiple subprojects, such as ":app:sub".
|
||||
//
|
||||
// The name of the root project cannot be used directly to configure subprojects,
|
||||
// please use "rootProject".
|
||||
//
|
||||
// You can configure multiple projects and subprojects at the same time by filling
|
||||
// in an array of full project names in the method parameters to
|
||||
// configure each corresponding project.
|
||||
projects(":app", ":modules:library1", ":modules:library2") {
|
||||
common {
|
||||
// Configure "common".
|
||||
}
|
||||
buildscript {
|
||||
// Configure "buildscript".
|
||||
}
|
||||
android {
|
||||
// Configure "android".
|
||||
}
|
||||
jvm {
|
||||
// Configure "jvm".
|
||||
}
|
||||
kmp {
|
||||
// Configure "kmp".
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can continue below to learn how to configure the features in each method block.
|
||||
|
||||
### Common Configuration
|
||||
|
||||
Here you can configure related features for all configuration types at the same time. The configurations here will be applied down to [Build Script Configuration](#build-script-configuration), [Android Project Configuration](#android-project-configuration), [JVM Project Configuration](#jvm-project-configuration), [Kotlin Multiplatform Project Configuration](#kotlin-multiplatform-project-configuration).
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
common {
|
||||
// Enable feature.
|
||||
//
|
||||
// You can set [buildscript], [android], [jvm], [kmp] separately.
|
||||
isEnabled = true
|
||||
|
||||
// Whether to exclude the non-string type key-values content.
|
||||
//
|
||||
// Enabled by default, when enabled, key-values and content that are not
|
||||
// string types will be excluded from properties' key-values.
|
||||
excludeNonStringValue = true
|
||||
|
||||
// Whether to use type auto conversion.
|
||||
//
|
||||
// Enabled by default, when enabled, the type in the properties' key-values will be
|
||||
// automatically identified and converted to the corresponding type.
|
||||
//
|
||||
// After enabling, if you want to force the content of a key-values to be a string type,
|
||||
// you can use single quotes or double quotes to wrap the entire string.
|
||||
//
|
||||
// - Note: After disabled this function, the functions mentioned above will also be invalid.
|
||||
useTypeAutoConversion = true
|
||||
|
||||
// Whether to use key-values content interpolation.
|
||||
//
|
||||
// Enabled by default, after enabling it will automatically identify
|
||||
// the `${...}` content in the properties' key-values content and replace it.
|
||||
//
|
||||
// Note: The interpolated content will only be looked up from the
|
||||
// current (current configuration file) properties' key-values list.
|
||||
useValueInterpolation = true
|
||||
|
||||
// Set exists property files.
|
||||
//
|
||||
// The property files will be automatically obtained from the root directory
|
||||
// of the current root project,
|
||||
// subproject and user directory according to the file name you set.
|
||||
//
|
||||
// By default, will add "gradle.properties" if [addDefault] is `true`.
|
||||
//
|
||||
// You can add multiple sets of property files name, they will be read in order.
|
||||
//
|
||||
// - Note: Generally there is no need to modify this setting,
|
||||
// an incorrect file name will result in obtaining empty key-values content.
|
||||
existsPropertyFiles(
|
||||
"some-other-1.properties",
|
||||
"some-other-2.properties",
|
||||
addDefault = true
|
||||
)
|
||||
|
||||
// Set a permanent list of properties' key-values.
|
||||
//
|
||||
// Here you can set some key-values that must exist, these key-values will be
|
||||
// generated regardless of whether they can be obtained from the properties' key-values.
|
||||
//
|
||||
// These keys use the content of the properties' key if it exists,
|
||||
// use the content set here if it does not exist.
|
||||
//
|
||||
// - Note: Special symbols and spaces cannot exist in properties' key names,
|
||||
// otherwise the generation may fail.
|
||||
permanentKeyValues(
|
||||
"permanent.some.key1" to "some_value_1",
|
||||
"permanent.some.key2" to "some_value_2"
|
||||
)
|
||||
|
||||
// Set a replacement list of properties' key-values.
|
||||
//
|
||||
// Here you can set some key-values that need to be replaced, these key-values
|
||||
// will be replaced the existing properties' key-values, if not exist, they will be ignored.
|
||||
//
|
||||
// The key-values set here will also overwrite the key-values set in [permanentKeyValues].
|
||||
replacementKeyValues(
|
||||
"some.key1" to "new.value1",
|
||||
"some.key2" to "new.value2"
|
||||
)
|
||||
|
||||
// Set a key list of properties' key-values name that need to be excluded.
|
||||
//
|
||||
// Here you can set some key names that you want to exclude from
|
||||
// known properties' key-values.
|
||||
//
|
||||
// These keys are excluded if they are present in the properties' key,
|
||||
// will not appear in the generated code.
|
||||
//
|
||||
// - Note: If you exclude key-values set in [permanentKeyValues], then they will
|
||||
// only change to the initial key-values content you set and continue to exist.
|
||||
excludeKeys(
|
||||
"exclude.some.key1",
|
||||
"exclude.some.key2"
|
||||
)
|
||||
|
||||
// Set a key list of properties' key-values name that need to be included.
|
||||
//
|
||||
// Here you can set some key value names that you want to include from
|
||||
// known properties' key-values.
|
||||
//
|
||||
// These keys are included if the properties' key exists,
|
||||
// unincluded keys will not appear in the generated code.
|
||||
includeKeys(
|
||||
"include.some.key1",
|
||||
"include.some.key2"
|
||||
)
|
||||
|
||||
// Set properties' key-values rules.
|
||||
//
|
||||
// You can set up a set of key-values rules,
|
||||
// use [ValueRule] to create new rule for parsing the obtained key-values content.
|
||||
//
|
||||
// These key-values rules are applied when properties' keys exist.
|
||||
keyValuesRules(
|
||||
"some.key1" to ValueRule { if (it.contains("_")) it.replace("_", "-") else it },
|
||||
"some.key2" to ValueRule { "$it-value" }
|
||||
)
|
||||
|
||||
// Set where to find properties' key-values.
|
||||
//
|
||||
// Defaults are [GropifyLocation.CurrentProject], [GropifyLocation.RootProject].
|
||||
//
|
||||
// You can set this up using the following types.
|
||||
//
|
||||
// - [GropifyLocation.CurrentProject]
|
||||
// - [GropifyLocation.RootProject]
|
||||
// - [GropifyLocation.Global]
|
||||
// - [GropifyLocation.System]
|
||||
// - [GropifyLocation.SystemEnv]
|
||||
//
|
||||
// We will generate properties' key-values in sequence from the locations you set,
|
||||
// the order of the generation locations follows the order you set.
|
||||
//
|
||||
// - Risk warning: [GropifyLocation.Global], [GropifyLocation.System],
|
||||
// [GropifyLocation.SystemEnv] may have keys and certificates,
|
||||
// please manage the generated code carefully.
|
||||
locations(GropifyLocation.CurrentProject, GropifyLocation.RootProject)
|
||||
}
|
||||
```
|
||||
|
||||
::: tip
|
||||
|
||||
When referencing `GropifyLocation`, the build script may generate the following at the top of the build script when used with IDE auto-import.
|
||||
|
||||
```kotlin :no-line-numbers
|
||||
import com.highcapable.gropify.plugin.config.type.GropifyLocation
|
||||
```
|
||||
|
||||
`Gropify` does alias processing for this, you can directly delete this import statement.
|
||||
|
||||
:::
|
||||
|
||||
### Build Script Configuration
|
||||
|
||||
The code generated in the build script can be directly used by the current `build.gradle.kts`, `build.gradle`.
|
||||
|
||||
The configuration here includes the configuration in `common`, and you can override it.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
buildscript {
|
||||
// Custom buildscript extension name.
|
||||
//
|
||||
// Default is "gropify".
|
||||
extensionName = "gropify"
|
||||
}
|
||||
```
|
||||
|
||||
::: warning
|
||||
|
||||
Gradle also has a `buildscript` method block, please be careful to use the correct DSL level.
|
||||
|
||||
:::
|
||||
|
||||
### Android Project Configuration
|
||||
|
||||
The content in this configuration block only takes effect for projects with AGP.
|
||||
|
||||
The configuration here includes the configuration in `common`, and you can override it.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
android {
|
||||
// Custom generated directory path.
|
||||
//
|
||||
// You can fill in the path relative to the current project.
|
||||
//
|
||||
// Format example: "path/to/your/src/main", the "src/main" is a fixed suffix.
|
||||
//
|
||||
// Default is "build/generated/gropify/src/main".
|
||||
//
|
||||
// We recommend that you set the generated path under the "build" directory,
|
||||
// which is ignored by version control systems by default.
|
||||
generateDirPath = "build/generated/gropify"
|
||||
|
||||
// Custom deployment `sourceSet` name.
|
||||
//
|
||||
// If your project source code deployment name is not default, you can customize it here.
|
||||
//
|
||||
// Default is "main".
|
||||
sourceSetName = "main"
|
||||
|
||||
// Custom generated package name.
|
||||
//
|
||||
// Android projects use the `namespace` in the `android` configuration method block
|
||||
// by default.
|
||||
//
|
||||
// The "generated" is a fixed suffix that avoids conflicts with your own namespaces,
|
||||
// if you don't want this suffix, you can refer to [isIsolationEnabled].
|
||||
packageName = "com.example.mydemo"
|
||||
|
||||
// Custom generated class name.
|
||||
//
|
||||
// Default is use the name of the current project.
|
||||
//
|
||||
// The "Properties" is a fixed suffix to distinguish it from your own class names.
|
||||
className = "MyDemo"
|
||||
|
||||
// Whether to use Kotlin language generation.
|
||||
//
|
||||
// Enabled by default, when enabled will generate Kotlin code,
|
||||
// disabled will generate Java code.
|
||||
//
|
||||
// - Note: This option will be disabled when this project is a pure Java project.
|
||||
useKotlin = true
|
||||
|
||||
// Whether to enable restricted access.
|
||||
//
|
||||
// Disabled by default, when enabled will add the `internal` modifier to
|
||||
// generated Kotlin classes or remove the `public` modifier to generated Java classes.
|
||||
isRestrictedAccessEnabled = false
|
||||
|
||||
// Whether to enable code isolation.
|
||||
//
|
||||
// Enabled by default, when enabled will generate code in an
|
||||
// isolated package suffix "generated" to avoid conflicts with other projects that
|
||||
// also use or not only Gropify to generate code.
|
||||
//
|
||||
// - Note: If you disable this option, please make sure that there are no other projects
|
||||
// that also use or not only Gropify to generate code to avoid conflicts.
|
||||
isIsolationEnabled = true
|
||||
}
|
||||
```
|
||||
|
||||
### JVM Project Configuration
|
||||
|
||||
The content in this configuration block only takes effect for pure JVM projects (including Kotlin and Java projects). For Android projects, please refer to [Android Project Configuration](#android-project-configuration) for configuration.
|
||||
|
||||
The configuration here includes the configuration in `common`, and you can override it.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
jvm {
|
||||
// Custom generated directory path.
|
||||
//
|
||||
// You can fill in the path relative to the current project.
|
||||
//
|
||||
// Format example: "path/to/your/src/main", the "src/main" is a fixed suffix.
|
||||
//
|
||||
// Default is "build/generated/gropify/src/main".
|
||||
//
|
||||
// We recommend that you set the generated path under the "build" directory,
|
||||
// which is ignored by version control systems by default.
|
||||
generateDirPath = "build/generated/gropify"
|
||||
|
||||
// Custom deployment `sourceSet` name.
|
||||
//
|
||||
// If your project source code deployment name is not default, you can customize it here.
|
||||
//
|
||||
// Default is "main".
|
||||
sourceSetName = "main"
|
||||
|
||||
// Custom generated package name.
|
||||
//
|
||||
// Java, Kotlin projects use the `project.group` of the project settings by default.
|
||||
//
|
||||
// The "generated" is a fixed suffix that avoids conflicts with your own namespaces,
|
||||
// if you don't want this suffix, you can refer to [isIsolationEnabled].
|
||||
packageName = "com.example.mydemo"
|
||||
|
||||
// Custom generated class name.
|
||||
//
|
||||
// Default is use the name of the current project.
|
||||
//
|
||||
// The "Properties" is a fixed suffix to distinguish it from your own class names.
|
||||
className = "MyDemo"
|
||||
|
||||
// Whether to use Kotlin language generation.
|
||||
//
|
||||
// Enabled by default, when enabled will generate Kotlin code,
|
||||
// disabled will generate Java code.
|
||||
//
|
||||
// - Note: This option will be disabled when this project is a pure Java project.
|
||||
useKotlin = true
|
||||
|
||||
// Whether to enable restricted access.
|
||||
//
|
||||
// Disabled by default, when enabled will add the `internal` modifier to
|
||||
// generated Kotlin classes or remove the `public` modifier to generated Java classes.
|
||||
isRestrictedAccessEnabled = false
|
||||
|
||||
// Whether to enable code isolation.
|
||||
//
|
||||
// Enabled by default, when enabled will generate code in an
|
||||
// isolated package suffix "generated" to avoid conflicts with other projects that
|
||||
// also use or not only Gropify to generate code.
|
||||
//
|
||||
// - Note: If you disable this option, please make sure that there are no other projects
|
||||
// that also use or not only Gropify to generate code to avoid conflicts.
|
||||
isIsolationEnabled = true
|
||||
}
|
||||
```
|
||||
|
||||
### Kotlin Multiplatform Project Configuration
|
||||
|
||||
The content in this configuration block only takes effect for projects with the Kotlin Multiplatform plugin.
|
||||
|
||||
The configuration here includes the configuration in `common`, and you can override it.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
kmp {
|
||||
// Custom generated directory path.
|
||||
//
|
||||
// You can fill in the path relative to the current project.
|
||||
//
|
||||
// Format example: "path/to/your/src/main", the "src/main" is a fixed suffix.
|
||||
//
|
||||
// Default is "build/generated/gropify/src/main".
|
||||
//
|
||||
// We recommend that you set the generated path under the "build" directory,
|
||||
// which is ignored by version control systems by default.
|
||||
generateDirPath = "build/generated/gropify"
|
||||
|
||||
// Custom deployment `sourceSet` name.
|
||||
//
|
||||
// If your project source code deployment name is not default, you can customize it here.
|
||||
//
|
||||
// Default is "commonMain".
|
||||
sourceSetName = "commonMain"
|
||||
|
||||
// Custom generated package name.
|
||||
//
|
||||
// Kotlin Multiplatform projects use the `project.group` of the project settings
|
||||
// by default.
|
||||
//
|
||||
// In a Kotlin Multiplatform project, if the AGP plugin is also applied,
|
||||
// the `namespace` will still be used as the package name by default.
|
||||
//
|
||||
// The "generated" is a fixed suffix that avoids conflicts with your own namespaces,
|
||||
// if you don't want this suffix, you can refer to [isIsolationEnabled].
|
||||
packageName = "com.example.mydemo"
|
||||
|
||||
// Custom generated class name.
|
||||
//
|
||||
// Default is use the name of the current project.
|
||||
//
|
||||
// The "Properties" is a fixed suffix to distinguish it from your own class names.
|
||||
className = "MyDemo"
|
||||
|
||||
// Whether to enable restricted access.
|
||||
//
|
||||
// Disabled by default, when enabled will add the `internal` modifier to
|
||||
// generated Kotlin classes.
|
||||
isRestrictedAccessEnabled = false
|
||||
|
||||
// Whether to enable code isolation.
|
||||
//
|
||||
// Enabled by default, when enabled will generate code in an
|
||||
// isolated package suffix "generated" to avoid conflicts with other projects that
|
||||
// also use or not only Gropify to generate code.
|
||||
//
|
||||
// - Note: If you disable this option, please make sure that there are no other projects
|
||||
// that also use or not only Gropify to generate code to avoid conflicts.
|
||||
isIsolationEnabled = true
|
||||
}
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
|
||||
Below is a project's `gradle.properties` configuration file.
|
||||
|
||||
> The following example
|
||||
|
||||
```properties
|
||||
project.groupName=com.highcapable.gropifydemo
|
||||
project.description=Hello Gropify Demo!
|
||||
project.version=1.0.0
|
||||
```
|
||||
|
||||
In the build script `build.gradle.kts`, we can directly use these key-values as shown below.
|
||||
|
||||
Here is an example of the Maven publish configuration section.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
groupId = gropify.project.groupName
|
||||
version = gropify.project.version
|
||||
pom.description.set(gropify.project.description)
|
||||
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Similarly, you can also call the generated key-values in the current project.
|
||||
|
||||
> Kotlin
|
||||
|
||||
```kotlin
|
||||
val groupName = GropifyDemoProperties.PROJECT_GROUP_NAME
|
||||
val description = GropifyDemoProperties.PROJECT_DESCRIPTION
|
||||
val version = GropifyDemoProperties.PROJECT_VERSION
|
||||
```
|
||||
|
||||
> Java
|
||||
|
||||
```java
|
||||
var groupName = GropifyDemoProperties.PROJECT_GROUP_NAME;
|
||||
var description = GropifyDemoProperties.PROJECT_DESCRIPTION;
|
||||
var version = GropifyDemoProperties.PROJECT_VERSION;
|
||||
```
|
||||
|
||||
Let's take another example with an Android project.
|
||||
|
||||
In Android projects, many repetitive and fixed properties usually need to be configured, such as `targetSdk`.
|
||||
|
||||
> The following example
|
||||
|
||||
```properties
|
||||
project.namespace=com.highcapable.gropifydemo
|
||||
project.compileSdk=36
|
||||
project.targetSdk=36
|
||||
project.minSdk=26
|
||||
```
|
||||
|
||||
When you set `useTypeAutoConversion = true`, `Gropify` will try to convert it to the corresponding type during the entity class generation process under the default configuration.
|
||||
|
||||
For example, the key-values used below can be identified as string and integer types, which can be directly used by the project configuration.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
android {
|
||||
namespace = gropify.project.namespace
|
||||
compileSdk = gropify.project.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = gropify.project.minSdk
|
||||
targetSdk = gropify.project.targetSdk
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You no longer need to use `buildConfigField` to add code to `BuildConfig`. With the property key-value code generated by `Gropify`, you can manage your project more flexibly.
|
||||
|
||||
You can also use interpolation `${...}` in property key-values to reference each other's content, but recursive references are not allowed.
|
||||
|
||||
When you set `useValueInterpolation = true`, `Gropify` will automatically merge these referenced contents to the corresponding positions.
|
||||
|
||||
> The following example
|
||||
|
||||
```properties
|
||||
project.name=MyDemo
|
||||
project.developer.name=myname
|
||||
project.url=https://github.com/${project.developer.name}/${project.name}
|
||||
```
|
||||
|
||||
If you add `GropifyLocation.SystemEnv` to `locations`, you can also directly reference system environment variables.
|
||||
|
||||
> The following example
|
||||
|
||||
```properties
|
||||
# Use the $USER environment variable in Linux or macOS systems to get the current username.
|
||||
project.developer.name=${USER}
|
||||
# Assume you have a system environment variable called SECRET_KEY (PLEASE BE SURE TO BE SAFE).
|
||||
project.secretKey=${SECRET_KEY}
|
||||
```
|
||||
|
||||
::: warning
|
||||
|
||||
This feature is provided by `Gropify`. Native `gradle.properties` does not support this feature.
|
||||
|
||||
The interpolated content is searched and replaced from top to bottom through the `locations` hierarchy.
|
||||
If there are duplicate key names, the last found content will be used for replacement.
|
||||
|
||||
:::
|
||||
|
||||
## Possible Issues
|
||||
|
||||
If your project only has a root project and no subprojects are imported, and the extension method cannot be generated normally at this time,
|
||||
you can migrate your root project to a subproject and import this subproject in `settings.gradle.kts`, which can solve this problem.
|
||||
|
||||
We generally recommend categorizing the functions of the project, with the root project only used to manage plugins and some configurations.
|
||||
|
||||
## Limitations
|
||||
|
||||
`Gropify` cannot generate extension methods in `settings.gradle.kts` because it is upstream of `Gropify`.
|
||||
13
docs-source/src/en/index.md
Normal file
13
docs-source/src/en/index.md
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
home: true
|
||||
title: Home
|
||||
heroImage: /images/logo.svg
|
||||
actions:
|
||||
- text: Get Started
|
||||
link: /en/guide/home
|
||||
type: primary
|
||||
- text: Changelog
|
||||
link: /en/about/changelog
|
||||
type: secondary
|
||||
footer: Apache-2.0 License | Copyright (C) 2019 HighCapable
|
||||
---
|
||||
17
docs-source/src/index.md
Normal file
17
docs-source/src/index.md
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
home: true
|
||||
navbar: false
|
||||
sidebar: false
|
||||
title: null
|
||||
heroAlt: null
|
||||
heroText: null
|
||||
tagline: Select a language
|
||||
actions:
|
||||
- text: English
|
||||
link: /en/
|
||||
type: secondary
|
||||
- text: 简体中文
|
||||
link: /zh-cn/
|
||||
type: secondary
|
||||
footer: Apache-2.0 License | Copyright (C) 2019 HighCapable
|
||||
---
|
||||
27
docs-source/src/zh-cn/about/about.md
Normal file
27
docs-source/src/zh-cn/about/about.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# 关于此文档
|
||||
|
||||
> 此文档由 [VuePress](https://v2.vuepress.vuejs.org/zh) 强力驱动。
|
||||
|
||||
## 许可证
|
||||
|
||||
[Apache-2.0](https://github.com/HighCapable/Gropify/blob/main/LICENSE)
|
||||
|
||||
```:no-line-numbers
|
||||
Apache License Version 2.0
|
||||
|
||||
Copyright (C) 2019 HighCapable
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
```
|
||||
|
||||
版权所有 © 2019 HighCapable
|
||||
13
docs-source/src/zh-cn/about/changelog.md
Normal file
13
docs-source/src/zh-cn/about/changelog.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# 更新日志
|
||||
|
||||
> 这里记录了 `Gropify` 的版本更新历史。
|
||||
|
||||
::: danger
|
||||
|
||||
我们只会对最新的 API 版本进行维护,若你正在使用过时的 API 版本则代表你自愿放弃一切维护的可能性。
|
||||
|
||||
:::
|
||||
|
||||
### 1.0.0 | 2025.11.11  <Badge type="tip" text="最新" vertical="middle" />
|
||||
|
||||
- 首个版本提交至 Maven
|
||||
14
docs-source/src/zh-cn/about/contacts.md
Normal file
14
docs-source/src/zh-cn/about/contacts.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# 联系我们
|
||||
|
||||
> 如在使用中有任何问题,或有任何建设性的建议,都可以联系我们。
|
||||
|
||||
加入我们的开发者群组。
|
||||
|
||||
- [点击加入 Telegram 群组 (开发者)](https://t.me/HighCapable_Dev)
|
||||
- [点击加入 QQ 群 (开发者)](https://qm.qq.com/cgi-bin/qm/qr?k=Pnsc5RY6N2mBKFjOLPiYldbAbprAU3V7&jump_from=webapi&authKey=X5EsOVzLXt1dRunge8ryTxDRrh9/IiW1Pua75eDLh9RE3KXE+bwXIYF5cWri/9lf)
|
||||
|
||||
在 **酷安** 找到我 [@星夜不荟](http://www.coolapk.com/u/876977)。
|
||||
|
||||
## 助力维护
|
||||
|
||||
感谢您选择并使用 `Gropify`,如有代码相关的建议和请求,可在 GitHub 提交 Pull Request。
|
||||
11
docs-source/src/zh-cn/about/future.md
Normal file
11
docs-source/src/zh-cn/about/future.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# 展望未来
|
||||
|
||||
> 未来是美好的,也是不确定的,让我们共同期待 `Gropify` 在未来的发展空间。
|
||||
|
||||
## 未来的计划
|
||||
|
||||
> 这里收录了 `Gropify` 可能会在后期添加的功能。
|
||||
|
||||
### 支持更多项目类型
|
||||
|
||||
`Gropify` 目前支持将属性生成到 Kotlin、Java 和 Android 项目的源代码中,在未来可能会支持更多能够参与 Gradle 构建的项目,例如 C/C++ (Android JNI)、Swift 等,以满足更多开发者的需求。
|
||||
67
docs-source/src/zh-cn/guide/home.md
Normal file
67
docs-source/src/zh-cn/guide/home.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# 介绍
|
||||
|
||||
> `Gropify` 是一个类型安全且现代化的 Gradle 属性插件。
|
||||
|
||||
## 背景
|
||||
|
||||
这是一个为 Gradle 构建脚本设计的插件,旨在将类似 `gradle.properties` 文件中的属性以类型安全的方式引入到构建脚本中,从而避免硬编码字符串可能带来的问题。
|
||||
|
||||
项目图标由 [MaiTungTM](https://github.com/Lagrio) 设计,名称取自 **G**radleP**ropify**,意为针对 Gradle 属性的插件。
|
||||
|
||||
它是基于 [SweetProperty](https://github.com/HighCapable/SweetProperty) 重构的全新项目,借鉴了以往的设计方案,使得其在原有基础上更加完善和易用。
|
||||
|
||||
`Gropify` 的配置方案与 `SweetProperty` 类似,如果你正在使用 `SweetProperty`,你可以考虑将其迁移到 `Gropify`。
|
||||
|
||||
## 用途
|
||||
|
||||
`Gropify` 主要针对 Kotlin DSL 构建脚本设计,Groovy 语言可以直接将 `gradle.properties` 文件中的属性作为变量使用,但是你也可以通过 `Gropify` 来实现类型安全的属性访问。
|
||||
|
||||
`Gropify` 同时支持将类似 `gradle.properties` 文件中的属性以类型安全的方式生成到 Kotlin、Java、Android 项目的源码中以供应用程序运行时使用,功能类似 Android 的 `BuildConfig` 中的 `buildConfigField` 功能。
|
||||
|
||||
假设我们有以下 `gradle.properties` 文件。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```properties
|
||||
project.app.name=Gropify-Demo
|
||||
project.app.version=1.0.0
|
||||
```
|
||||
|
||||
这是 `Gropify` 自动生成的代码调用示例。
|
||||
|
||||
> 构建脚本 (Kotlin DSL、Groovy DSL)
|
||||
|
||||
```kotlin
|
||||
val appName = gropify.project.app.name
|
||||
val appVersion = gropify.project.app.version
|
||||
```
|
||||
|
||||
```groovy
|
||||
def appName = gropify.project.app.name
|
||||
def appVersion = gropify.project.app.version
|
||||
```
|
||||
|
||||
> 源代码 (Kotlin、Java)
|
||||
|
||||
```kotlin
|
||||
val appName = MyAppProperties.PROJECT_APP_NAME
|
||||
val appVersion = MyAppProperties.PROJECT_APP_VERSION
|
||||
```
|
||||
|
||||
```java
|
||||
var appName = MyAppProperties.PROJECT_APP_NAME;
|
||||
var appVersion = MyAppProperties.PROJECT_APP_VERSION;
|
||||
```
|
||||
|
||||
`Gropify` 同样支持 Kotlin Multiplatform 项目,你可以在 `commonMain` 源集中使用生成的属性类。
|
||||
|
||||
## 语言要求
|
||||
|
||||
推荐使用 Kotlin DSL 来配置项目的构建脚本,Groovy 语言同样受支持,但在纯 Groovy 项目中部分配置语法可能存在兼容性问题。
|
||||
|
||||
在 Groovy DSL 中使用此插件发生的任何问题,我们都将不再负责排查和修复,并且在后期版本可能会完全不再支持 Groovy DSL。
|
||||
|
||||
## 功能贡献
|
||||
|
||||
本项目的维护离不开各位开发者的支持和贡献,目前这个项目处于初期阶段,可能依然存在一些问题或者缺少你需要的功能,
|
||||
如果可能,欢迎提交 PR 为此项目贡献你认为需要的功能或前往 [GitHub Issues](repo://issues) 向我们提出建议。
|
||||
661
docs-source/src/zh-cn/guide/quick-start.md
Normal file
661
docs-source/src/zh-cn/guide/quick-start.md
Normal file
@@ -0,0 +1,661 @@
|
||||
# 快速开始
|
||||
|
||||
> 集成 `Gropify` 到你的项目中。
|
||||
|
||||
## 部署插件
|
||||
|
||||

|
||||
<span style="margin-left: 5px"/>
|
||||

|
||||
|
||||
`Gropify` 的依赖发布在 **Maven Central** 和我们的公共存储库中,你可以使用如下方式配置存储库。
|
||||
|
||||
我们建议使用不低于 `7.x.x` 版本的 Gradle,并推荐使用 Kotlin DSL 作为 Gradle 构建脚本语言,文档中将不再详细介绍在 Groovy DSL 中的使用方法。
|
||||
|
||||
我们推荐使用 `pluginManagement` 新方式进行部署,它是自 Gradle `7.x.x` 版本开始添加的功能。
|
||||
|
||||
如果你的项目依然在使用 `buildscript` 的方式进行管理,推荐迁移到新方式,这里将不再提供旧版本的使用方式说明。
|
||||
|
||||
首先,在你的项目 `settings.gradle.kts` 中配置插件的存储库。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal() // 可选
|
||||
google() // 可选
|
||||
mavenCentral() // 必须
|
||||
// (可选) 你可以添加此 URL 以使用我们的公共存储库
|
||||
// 当 Sonatype-OSS 发生故障无法发布依赖时,此存储库作为备选进行添加
|
||||
// 详情请前往:https://github.com/HighCapable/maven-repository
|
||||
maven("https://raw.githubusercontent.com/HighCapable/maven-repository/main/repository/releases")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
然后在 `settings.gradle.kts` 中 `plugin` 添加 `Gropify` 插件依赖,请注意**不要**在后方加入 `apply false`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
plugins {
|
||||
id("com.highcapable.gropify") version "<version>"
|
||||
}
|
||||
```
|
||||
|
||||
请将 `<version>` 修改为此小结顶部显示的版本。
|
||||
|
||||
上述配置完成后,运行一次 Gradle Sync。
|
||||
|
||||
`Gropify` 将会自动搜索根项目和每个子项目中的 `gradle.properties` 文件,并读取其中的属性键值,为每个项目生成对应的代码。
|
||||
|
||||
::: warning
|
||||
|
||||
`Gropify` 只能被应用到 `settings.gradle.kts` 中,配置一次即可全局生效,请勿将其应用到 `build.gradle.kts` 中,否则功能将会无效。
|
||||
|
||||
:::
|
||||
|
||||
## 功能配置
|
||||
|
||||
你可以对 `Gropify` 进行配置来实现自定义和个性化功能。
|
||||
|
||||
`Gropify` 为你提供了相对丰富的可自定义功能,下面是这些功能的说明与配置方法。
|
||||
|
||||
请在你的 `settings.gradle.kts` 中添加 `gropify` 方法块以开始配置 `Gropify`。
|
||||
|
||||
如需在 Groovy DSL 中使用,请将所有变量的 `=` 改为空格,并删除 `Enabled` 前方的 `is` 即可。
|
||||
|
||||
如果你遇到了 `Gradle DSL method not found` 错误,解决方案为迁移到 Kotlin DSL。
|
||||
|
||||
如果你不想全部使用 Kotlin DSL,你也可以仅将 `settings.gradle` 迁移到 `settings.gradle.kts`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
gropify {
|
||||
// 启用 Gropify,设置为 `false` 将禁用所有功能
|
||||
isEnabled = true
|
||||
}
|
||||
```
|
||||
|
||||
`Gropify` 的配置模式分为 `global` 全局配置和 `rootProject`、`projects` 根项目和子项目配置三种。
|
||||
|
||||
你可以在子项的代码块中继续配置和集成顶层项目的配置。
|
||||
|
||||
以下配置均在 `gropify` 方法块中进行。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 全局配置
|
||||
//
|
||||
// 你可以在全局配置中修改所有项目中的配置
|
||||
// 每个项目中未进行声明的配置将使用全局配置
|
||||
// 每个配置方法块中的功能完全一致
|
||||
//
|
||||
// 你可以参考下方根项目、子项目的配置方法
|
||||
global {
|
||||
// 通用配置
|
||||
common {
|
||||
// 配置 "common"
|
||||
}
|
||||
|
||||
// 构建脚本配置
|
||||
buildscript {
|
||||
// 配置 "buildscript"
|
||||
}
|
||||
|
||||
// Android 项目配置
|
||||
android {
|
||||
// 配置 "android"
|
||||
}
|
||||
|
||||
// JVM 项目配置
|
||||
jvm {
|
||||
// 配置 "jvm"
|
||||
}
|
||||
|
||||
// Kotlin 多平台项目配置
|
||||
kmp {
|
||||
// 配置 "kmp"
|
||||
}
|
||||
}
|
||||
|
||||
// 根项目 (Root Project) 配置
|
||||
//
|
||||
// 这是一个特殊的配置方法块,只能用于根项目
|
||||
rootProject {
|
||||
common {
|
||||
// 配置 "common"
|
||||
}
|
||||
buildscript {
|
||||
// 配置 "buildscript"
|
||||
}
|
||||
android {
|
||||
// 配置 "android"
|
||||
}
|
||||
jvm {
|
||||
// 配置 "jvm"
|
||||
}
|
||||
kmp {
|
||||
// 配置 "kmp"
|
||||
}
|
||||
}
|
||||
|
||||
// 其它项目与子项目配置
|
||||
//
|
||||
// 在方法参数中填入需要配置的项目完整名称来配置对应的项目
|
||||
//
|
||||
// 如果当前项目是子项目,你必须填写子项目前面的 ":",例如 ":app"
|
||||
//
|
||||
// 如果当前项目为嵌套型子项目,例如 app → sub
|
||||
// 此时你需要使用 ":" 来分隔多个子项目,例如 ":app:sub"
|
||||
//
|
||||
// 根项目的名称不能直接用来配置子项目,请使用 "rootProject"
|
||||
// 你可以同时进行多个项目与子项目配置,在方法参数中填入需要配置的项目完整名称数组来配置每个对应的项目
|
||||
projects(":app", ":modules:library1", ":modules:library2") {
|
||||
common {
|
||||
// 配置 "common"
|
||||
}
|
||||
buildscript {
|
||||
// 配置 "buildscript"
|
||||
}
|
||||
android {
|
||||
// 配置 "android"
|
||||
}
|
||||
jvm {
|
||||
// 配置 "jvm"
|
||||
}
|
||||
kmp {
|
||||
// 配置 "kmp"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
你可以继续在下方了解如何配置每个方法块中的功能。
|
||||
|
||||
### 通用配置
|
||||
|
||||
在这里你可以同时配置所有配置类型的相关功能,这里的配置会向下应用到 [构建脚本配置](#构建脚本配置)、[Android 项目配置](#android-项目配置)、[JVM 项目配置](#jvm-项目配置)、[Kotlin 多平台项目配置](#kotlin-多平台项目配置) 中。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
common {
|
||||
// 启用功能
|
||||
//
|
||||
// 你可以分别对 [buildscript]、[android]、[jvm]、[kmp] 进行设置
|
||||
isEnabled = true
|
||||
|
||||
// 是否排除非字符串类型的键值内容
|
||||
//
|
||||
// 默认启用,启用后将排除非字符串类型的键值和内容
|
||||
excludeNonStringValue = true
|
||||
|
||||
// 是否使用类型自动转换
|
||||
//
|
||||
// 默认启用,启用后将自动识别属性键值中的类型并转换为对应类型
|
||||
//
|
||||
// 启用后,如果你想强制将键值内容设为字符串类型,
|
||||
// 可以使用单引号或双引号包裹整个字符串
|
||||
//
|
||||
// - 注意: 禁用此功能后,上述功能也将失效
|
||||
useTypeAutoConversion = true
|
||||
|
||||
// 是否使用键值内容插值
|
||||
//
|
||||
// 默认启用,启用后将自动识别属性键值内容中的 `${...}` 并进行替换
|
||||
//
|
||||
// 注意: 插值内容仅会从当前 (当前配置文件) 属性键值列表中查找
|
||||
useValueInterpolation = true
|
||||
|
||||
// 设置已存在的属性文件
|
||||
//
|
||||
// 属性文件将根据你设置的文件名自动从当前根项目、
|
||||
// 子项目和用户目录的根目录获取
|
||||
//
|
||||
// 默认情况下,如果 [addDefault] 为 `true`,将添加 "gradle.properties"
|
||||
//
|
||||
// 你可以添加多组属性文件名,它们将按顺序读取
|
||||
//
|
||||
// - 注意: 通常无需修改此设置,错误的文件名将导致获取空键值内容
|
||||
existsPropertyFiles(
|
||||
"some-other-1.properties",
|
||||
"some-other-2.properties",
|
||||
addDefault = true
|
||||
)
|
||||
|
||||
// 设置永久属性键值列表
|
||||
//
|
||||
// 在这里你可以设置一些必须存在的键值,无论是否能从属性键值中获取,
|
||||
// 这些键值都将被生成
|
||||
//
|
||||
// 这些键如果存在于属性键中则使用属性键的内容,
|
||||
// 如果不存在则使用这里设置的内容
|
||||
//
|
||||
// - 注意: 属性键名称中不能存在特殊符号和空格,否则可能导致生成失败
|
||||
permanentKeyValues(
|
||||
"permanent.some.key1" to "some_value_1",
|
||||
"permanent.some.key2" to "some_value_2"
|
||||
)
|
||||
|
||||
// 设置替换属性键值列表
|
||||
//
|
||||
// 在这里你可以设置一些需要替换的键值,这些键值
|
||||
// 将替换现有的属性键值,如果不存在则忽略
|
||||
//
|
||||
// 这里设置的键值也会覆盖 [permanentKeyValues] 中设置的键值
|
||||
replacementKeyValues(
|
||||
"some.key1" to "new.value1",
|
||||
"some.key2" to "new.value2"
|
||||
)
|
||||
|
||||
// 设置需要排除的属性键值名称列表
|
||||
//
|
||||
// 在这里你可以设置一些要从已知属性键值中排除的键名称
|
||||
//
|
||||
// 如果这些键存在于属性键中则排除它们,
|
||||
// 不会出现在生成的代码中
|
||||
//
|
||||
// - 注意: 如果你排除了 [permanentKeyValues] 中设置的键值,那么它们将
|
||||
// 仅更改为你设置的初始键值内容并继续存在
|
||||
excludeKeys(
|
||||
"exclude.some.key1",
|
||||
"exclude.some.key2"
|
||||
)
|
||||
|
||||
// 设置需要包含的属性键值名称列表
|
||||
//
|
||||
// 在这里你可以设置一些要从已知属性键值中包含的键名称
|
||||
//
|
||||
// 如果属性键存在则包含这些键,未包含的键不会出现在生成的代码中
|
||||
includeKeys(
|
||||
"include.some.key1",
|
||||
"include.some.key2"
|
||||
)
|
||||
|
||||
// 设置属性键值规则
|
||||
//
|
||||
// 你可以设置一组键值规则,
|
||||
// 使用 [ValueRule] 创建新规则来解析获取的键值内容
|
||||
//
|
||||
// 当属性键存在时应用这些键值规则
|
||||
keyValuesRules(
|
||||
"some.key1" to ValueRule { if (it.contains("_")) it.replace("_", "-") else it },
|
||||
"some.key2" to ValueRule { "$it-value" }
|
||||
)
|
||||
|
||||
// 设置查找属性键值的位置
|
||||
//
|
||||
// 默认为 [GropifyLocation.CurrentProject]、[GropifyLocation.RootProject]
|
||||
//
|
||||
// 你可以使用以下类型进行设置
|
||||
//
|
||||
// - [GropifyLocation.CurrentProject]
|
||||
// - [GropifyLocation.RootProject]
|
||||
// - [GropifyLocation.Global]
|
||||
// - [GropifyLocation.System]
|
||||
// - [GropifyLocation.SystemEnv]
|
||||
//
|
||||
// 我们将按顺序从你设置的位置生成属性键值,生成位置的顺序遵循你设置的顺序
|
||||
//
|
||||
// - 风险警告: [GropifyLocation.Global]、[GropifyLocation.System]、
|
||||
// [GropifyLocation.SystemEnv] 可能包含密钥和证书,请谨慎管理生成的代码
|
||||
locations(GropifyLocation.CurrentProject, GropifyLocation.RootProject)
|
||||
}
|
||||
```
|
||||
|
||||
::: tip
|
||||
|
||||
在引用 `GropifyLocation` 时,构建脚本在配合 IDE 自动导入时可能会在构建脚本顶部生成以下内容。
|
||||
|
||||
```kotlin :no-line-numbers
|
||||
import com.highcapable.gropify.plugin.config.type.GropifyLocation
|
||||
```
|
||||
|
||||
`Gropify` 对此做了 alias 处理,你可以直接删除此 import 语句。
|
||||
|
||||
:::
|
||||
|
||||
### 构建脚本配置
|
||||
|
||||
在构建脚本中生成的代码可直接被当前 `build.gradle.kts`、`build.gradle` 使用。
|
||||
|
||||
这里的配置包括 `common` 中的配置,你可以对其进行复写。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
buildscript {
|
||||
// 自定义构建脚本扩展名称
|
||||
//
|
||||
// 默认为 "gropify"
|
||||
extensionName = "gropify"
|
||||
}
|
||||
```
|
||||
|
||||
::: warning
|
||||
|
||||
Gradle 中也有一个 `buildscript` 方法块,请注意使用正确的 DSL 层级。
|
||||
|
||||
:::
|
||||
|
||||
### Android 项目配置
|
||||
|
||||
此配置块中的内容仅对存在 AGP 的项目生效。
|
||||
|
||||
这里的配置包括 `common` 中的配置,你可以对其进行复写。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
android {
|
||||
// 自定义生成的目录路径
|
||||
//
|
||||
// 你可以填写相对于当前项目的路径
|
||||
//
|
||||
// 格式示例: "path/to/your/src/main","src/main" 是固定后缀
|
||||
//
|
||||
// 默认为 "build/generated/gropify/src/main"
|
||||
//
|
||||
// 我们建议你将生成路径设置在 "build" 目录下,该目录默认被版本控制系统忽略
|
||||
generateDirPath = "build/generated/gropify"
|
||||
|
||||
// 自定义部署 `sourceSet` 名称
|
||||
//
|
||||
// 如果你的项目源代码部署名称不是默认的,可以在此处自定义
|
||||
//
|
||||
// 默认为 "main"
|
||||
sourceSetName = "main"
|
||||
|
||||
// 自定义生成的包名
|
||||
//
|
||||
// Android 项目默认使用 `android` 配置方法块中的 `namespace`
|
||||
//
|
||||
// "generated" 是固定后缀,用于避免与你自己的命名空间冲突,
|
||||
// 如果你不想要此后缀,可以参考 [isIsolationEnabled]
|
||||
packageName = "com.example.mydemo"
|
||||
|
||||
// 自定义生成的类名
|
||||
//
|
||||
// 默认使用当前项目的名称
|
||||
//
|
||||
// "Properties" 是固定后缀,用于与你自己的类名区分
|
||||
className = "MyDemo"
|
||||
|
||||
// 是否使用 Kotlin 语言生成
|
||||
//
|
||||
// 默认启用,启用后将生成 Kotlin 代码,
|
||||
// 禁用后将生成 Java 代码
|
||||
//
|
||||
// - 注意: 当此项目为纯 Java 项目时,此选项将被禁用
|
||||
useKotlin = true
|
||||
|
||||
// 是否启用受限访问
|
||||
//
|
||||
// 默认禁用,启用后将为生成的 Kotlin 类添加 `internal` 修饰符,
|
||||
// 或为生成的 Java 类移除 `public` 修饰符
|
||||
isRestrictedAccessEnabled = false
|
||||
|
||||
// 是否启用代码隔离
|
||||
//
|
||||
// 默认启用,启用后将在隔离的包后缀 "generated" 中生成代码,
|
||||
// 以避免与其他同样使用或不仅使用 Gropify 生成代码的项目冲突
|
||||
//
|
||||
// - 注意: 如果你禁用此选项,请确保没有其他同样使用或不仅使用
|
||||
// Gropify 生成代码的项目,以避免冲突
|
||||
isIsolationEnabled = true
|
||||
}
|
||||
```
|
||||
|
||||
### JVM 项目配置
|
||||
|
||||
此配置块中的内容仅对纯 JVM 项目生效 (包括 Kotlin、Java 项目),如果是 Android 项目请参考 [Android 项目配置](#android-项目配置) 进行配置。
|
||||
|
||||
这里的配置包括 `common` 中的配置,你可以对其进行复写。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
jvm {
|
||||
// 自定义生成的目录路径
|
||||
//
|
||||
// 你可以填写相对于当前项目的路径
|
||||
//
|
||||
// 格式示例: "path/to/your/src/main","src/main" 是固定后缀
|
||||
//
|
||||
// 默认为 "build/generated/gropify/src/main"
|
||||
//
|
||||
// 我们建议你将生成路径设置在 "build" 目录下,该目录默认被版本控制系统忽略
|
||||
generateDirPath = "build/generated/gropify"
|
||||
|
||||
// 自定义部署 `sourceSet` 名称
|
||||
//
|
||||
// 如果你的项目源代码部署名称不是默认的,可以在此处自定义
|
||||
//
|
||||
// 默认为 "main"
|
||||
sourceSetName = "main"
|
||||
|
||||
// 自定义生成的包名
|
||||
//
|
||||
// Java、Kotlin 项目默认使用项目设置的 `project.group`
|
||||
//
|
||||
// "generated" 是固定后缀,用于避免与你自己的命名空间冲突,
|
||||
// 如果你不想要此后缀,可以参考 [isIsolationEnabled]
|
||||
packageName = "com.example.mydemo"
|
||||
|
||||
// 自定义生成的类名
|
||||
//
|
||||
// 默认使用当前项目的名称
|
||||
//
|
||||
// "Properties" 是固定后缀,用于与你自己的类名区分
|
||||
className = "MyDemo"
|
||||
|
||||
// 是否使用 Kotlin 语言生成
|
||||
//
|
||||
// 默认启用,启用后将生成 Kotlin 代码,
|
||||
// 禁用后将生成 Java 代码
|
||||
//
|
||||
// - 注意: 当此项目为纯 Java 项目时,此选项将被禁用
|
||||
useKotlin = true
|
||||
|
||||
// 是否启用受限访问
|
||||
//
|
||||
// 默认禁用,启用后将为生成的 Kotlin 类添加 `internal` 修饰符,
|
||||
// 或为生成的 Java 类移除 `public` 修饰符
|
||||
isRestrictedAccessEnabled = false
|
||||
|
||||
// 是否启用代码隔离
|
||||
//
|
||||
// 默认启用,启用后将在隔离的包后缀 "generated" 中生成代码,
|
||||
// 以避免与其他同样使用或不仅使用 Gropify 生成代码的项目冲突
|
||||
//
|
||||
// - 注意: 如果你禁用此选项,请确保没有其他同样使用或不仅使用
|
||||
// Gropify 生成代码的项目,以避免冲突
|
||||
isIsolationEnabled = true
|
||||
}
|
||||
```
|
||||
|
||||
### Kotlin 多平台项目配置
|
||||
|
||||
此配置块中的内容仅对含有 Kotlin Multiplatform 插件的项目生效。
|
||||
|
||||
这里的配置包括 `common` 中的配置,你可以对其进行复写。
|
||||
|
||||
```kotlin
|
||||
kmp {
|
||||
// 自定义生成的目录路径
|
||||
//
|
||||
// 你可以填写相对于当前项目的路径
|
||||
//
|
||||
// 格式示例: "path/to/your/src/main","src/main" 是固定后缀
|
||||
//
|
||||
// 默认为 "build/generated/gropify/src/main"
|
||||
//
|
||||
// 我们建议你将生成路径设置在 "build" 目录下,该目录默认被版本控制系统忽略
|
||||
generateDirPath = "build/generated/gropify"
|
||||
|
||||
// 自定义部署 `sourceSet` 名称
|
||||
//
|
||||
// 如果你的项目源代码部署名称不是默认的,可以在此处自定义。
|
||||
//
|
||||
// 默认为 "commonMain"
|
||||
sourceSetName = "commonMain"
|
||||
|
||||
// 自定义生成的包名
|
||||
//
|
||||
// Kotlin 多平台项目默认使用项目设置的 `project.group`
|
||||
//
|
||||
// 在 Kotlin 多平台项目中,如果同时应用了 AGP 插件,
|
||||
// 仍将默认使用 `namespace` 作为包名
|
||||
//
|
||||
// "generated" 是固定后缀,用于避免与你自己的命名空间冲突,
|
||||
// 如果你不想要此后缀,可以参考 [isIsolationEnabled]
|
||||
packageName = "com.example.mydemo"
|
||||
|
||||
// 自定义生成的类名
|
||||
//
|
||||
// 默认使用当前项目的名称
|
||||
//
|
||||
// "Properties" 是固定后缀,用于与你自己的类名区分
|
||||
className = "MyDemo"
|
||||
|
||||
// 是否启用受限访问
|
||||
//
|
||||
// 默认禁用,启用后将为生成的 Kotlin 类添加 `internal` 修饰符
|
||||
isRestrictedAccessEnabled = false
|
||||
|
||||
// 是否启用代码隔离
|
||||
//
|
||||
// 默认启用,启用后将在隔离的包后缀 "generated" 中生成代码,
|
||||
// 以避免与其他同样使用或不仅使用 Gropify 生成代码的项目冲突
|
||||
//
|
||||
// - 注意: 如果你禁用此选项,请确保没有其他同样使用或不仅使用
|
||||
// Gropify 生成代码的项目,以避免冲突
|
||||
isIsolationEnabled = true
|
||||
}
|
||||
```
|
||||
|
||||
## 使用示例
|
||||
|
||||
下面是一个项目的 `gradle.properties` 配置文件。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```properties
|
||||
project.groupName=com.highcapable.gropifydemo
|
||||
project.description=Hello Gropify Demo!
|
||||
project.version=1.0.0
|
||||
```
|
||||
|
||||
在构建脚本 `build.gradle.kts` 中,我们就可以如下所示这样直接去使用这些键值。
|
||||
|
||||
这里以 Maven 发布的配置部分举例。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
groupId = gropify.project.groupName
|
||||
version = gropify.project.version
|
||||
pom.description.set(gropify.project.description)
|
||||
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
同样地,你也可以在当前项目中调用生成的键值。
|
||||
|
||||
> Kotlin
|
||||
|
||||
```kotlin
|
||||
val groupName = GropifyDemoProperties.PROJECT_GROUP_NAME
|
||||
val description = GropifyDemoProperties.PROJECT_DESCRIPTION
|
||||
val version = GropifyDemoProperties.PROJECT_VERSION
|
||||
```
|
||||
|
||||
> Java
|
||||
|
||||
```java
|
||||
var groupName = GropifyDemoProperties.PROJECT_GROUP_NAME;
|
||||
var description = GropifyDemoProperties.PROJECT_DESCRIPTION;
|
||||
var version = GropifyDemoProperties.PROJECT_VERSION;
|
||||
```
|
||||
|
||||
下面再以 Android 项目举例。
|
||||
|
||||
在 Android 项目中通常需要配置很多重复、固定的属性,例如 `targetSdk`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```properties
|
||||
project.namespace=com.highcapable.gropifydemo
|
||||
project.compileSdk=36
|
||||
project.targetSdk=36
|
||||
project.minSdk=26
|
||||
```
|
||||
|
||||
当你设置了 `useTypeAutoConversion = true` 时,`Gropify` 在生成实体类过程在默认配置下将尝试将其转换为对应的类型。
|
||||
|
||||
例如下方所使用的键值,其类型可被识别为字符串和整型,可被项目配置直接使用。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
android {
|
||||
namespace = gropify.project.namespace
|
||||
compileSdk = gropify.project.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = gropify.project.minSdk
|
||||
targetSdk = gropify.project.targetSdk
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
你可以无需再使用 `buildConfigField` 向 `BuildConfig` 添加代码,有了 `Gropify` 生成的属性键值代码,你可以更加灵活地管理你的项目。
|
||||
|
||||
你还可以在属性键值中使用插值 `${...}` 互相引用其中的内容,但不允许递归引用。
|
||||
|
||||
当你设置了 `useValueInterpolation = true` 时,`Gropify` 将自动合并这些引用的内容到对应位置。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```properties
|
||||
project.name=MyDemo
|
||||
project.developer.name=myname
|
||||
project.url=https://github.com/${project.developer.name}/${project.name}
|
||||
```
|
||||
|
||||
如果你在 `locations` 中添加了 `GropifyLocation.SystemEnv`,你还可以直接引用系统环境变量。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```properties
|
||||
# Linux 或 macOS 系统中使用 $USER 环境变量可以获取当前用户名
|
||||
project.developer.name=${USER}
|
||||
# 假设你有一个名为 SECRET_KEY 的系统环境变量 (请确保安全)
|
||||
project.secretKey=${SECRET_KEY}
|
||||
```
|
||||
|
||||
::: warning
|
||||
|
||||
这个特性是 `Gropify` 提供的,原生的 `gradle.properties` 并不支持此功能。
|
||||
|
||||
插值内容通过 `locations` 的层级自上而下进行查找替换,如果存在重复的键值名称,将使用最后查找到的内容进行替换。
|
||||
|
||||
:::
|
||||
|
||||
## 可能遇到的问题
|
||||
|
||||
如果你的项目仅存在一个根项目,且没有导入任何子项目,此时如果扩展方法不能正常生成,
|
||||
你可以将你的根项目迁移至子项目并在 `settings.gradle.kts` 中导入这个子项目,这样即可解决此问题。
|
||||
|
||||
我们一般推荐将项目的功能进行分类,根项目仅用来管理插件和一些配置。
|
||||
|
||||
## 局限性说明
|
||||
|
||||
`Gropify` 无法生成 `settings.gradle.kts` 中的扩展方法,因为这属于 `Gropify` 的上游。
|
||||
13
docs-source/src/zh-cn/index.md
Normal file
13
docs-source/src/zh-cn/index.md
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
home: true
|
||||
title: 首页
|
||||
heroImage: /images/logo.svg
|
||||
actions:
|
||||
- text: 快速上手
|
||||
link: /zh-cn/guide/home
|
||||
type: primary
|
||||
- text: 更新日志
|
||||
link: /zh-cn/about/changelog
|
||||
type: secondary
|
||||
footer: Apache-2.0 License | Copyright (C) 2019 HighCapable
|
||||
---
|
||||
2004
docs-source/yarn.lock
Normal file
2004
docs-source/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
27
gradle.properties
Normal file
27
gradle.properties
Normal file
@@ -0,0 +1,27 @@
|
||||
# Project Configuration
|
||||
project.name=Gropify
|
||||
project.url=https://github.com/HighCapable/Gropify
|
||||
project.groupName=com.highcapable.gropify
|
||||
project.moduleName=gropify
|
||||
project.version=1.0.0
|
||||
# Gradle Plugin Configuration
|
||||
gradle.plugin.moduleName=${project.groupName}.gradle.plugin
|
||||
gradle.plugin.implementationClass=${project.groupName}.plugin.GropifyPlugin
|
||||
# Maven Publish Configuration
|
||||
SONATYPE_HOST=CENTRAL_PORTAL
|
||||
RELEASE_SIGNING_ENABLED=true
|
||||
# Maven POM Configuration
|
||||
POM_NAME=Gropify
|
||||
POM_ARTIFACT_ID=gropify
|
||||
POM_DESCRIPTION=A type-safe and modern properties plugin for Gradle.
|
||||
POM_URL=https://github.com/HighCapable/Gropify
|
||||
POM_LICENSE_NAME=Apache License 2.0
|
||||
POM_LICENSE_URL=https://github.com/HighCapable/Gropify/blob/main/LICENSE
|
||||
POM_LICENSE_DIST=repo
|
||||
POM_SCM_URL=https://github.com/HighCapable/Gropify
|
||||
POM_SCM_CONNECTION=scm:git:git://github.com/HighCapable/Gropify
|
||||
POM_SCM_DEV_CONNECTION=scm:git:ssh://github.com/HighCapable/Gropify
|
||||
POM_DEVELOPER_ID=0
|
||||
POM_DEVELOPER_NAME=fankes
|
||||
POM_DEVELOPER_EMAIL=qzmmcn@163.com
|
||||
POM_DEVELOPER_URL=https://github.com/fankes
|
||||
21
gradle/libs.versions.toml
Normal file
21
gradle/libs.versions.toml
Normal file
@@ -0,0 +1,21 @@
|
||||
[versions]
|
||||
kotlin = "2.2.21"
|
||||
jackson = "3.0.1"
|
||||
kavaref-core = "1.0.2"
|
||||
kavaref-extension = "1.0.1"
|
||||
kotlinpoet = "2.2.0"
|
||||
javapoet = "0.7.0"
|
||||
zip4j = "2.11.5"
|
||||
maven-publish = "0.34.0"
|
||||
|
||||
[plugins]
|
||||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" }
|
||||
|
||||
[libraries]
|
||||
jackson-module-kotlin = { module = "tools.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
|
||||
kavaref-core = { module = "com.highcapable.kavaref:kavaref-core", version.ref = "kavaref-core" }
|
||||
kavaref-extension = { module = "com.highcapable.kavaref:kavaref-extension", version.ref = "kavaref-extension" }
|
||||
kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" }
|
||||
javapoet = { module = "com.palantir.javapoet:javapoet", version.ref = "javapoet" }
|
||||
zip4j = { module = "net.lingala.zip4j:zip4j", version.ref = "zip4j" }
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#Wed Oct 08 00:46:51 CST 2025
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
234
gradlew
vendored
Executable file
234
gradlew
vendored
Executable file
@@ -0,0 +1,234 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
89
gradlew.bat
vendored
Normal file
89
gradlew.bat
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
65
gropify-gradle-plugin/build.gradle.kts
Normal file
65
gropify-gradle-plugin/build.gradle.kts
Normal file
@@ -0,0 +1,65 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
alias(libs.plugins.kotlin.jvm)
|
||||
alias(libs.plugins.maven.publish)
|
||||
}
|
||||
|
||||
group = gropify.project.groupName
|
||||
version = gropify.project.version
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(17)
|
||||
|
||||
sourceSets.all { languageSettings { languageVersion = "2.0" } }
|
||||
|
||||
compilerOptions {
|
||||
freeCompilerArgs = listOf(
|
||||
"-Xno-param-assertions",
|
||||
"-Xno-call-assertions",
|
||||
"-Xno-receiver-assertions"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.jackson.module.kotlin)
|
||||
implementation(libs.kavaref.core)
|
||||
implementation(libs.kavaref.extension)
|
||||
implementation(libs.kotlinpoet)
|
||||
implementation(libs.javapoet)
|
||||
implementation(libs.zip4j)
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create(gropify.project.moduleName) {
|
||||
id = gropify.project.groupName
|
||||
implementationClass = gropify.gradle.plugin.implementationClass
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
configure<PublishingExtension> {
|
||||
repositories {
|
||||
val repositoryDir = gradle.gradleUserHomeDir
|
||||
.resolve("highcapable-maven-repository")
|
||||
.resolve("repository")
|
||||
|
||||
maven {
|
||||
name = "HighCapableMavenReleases"
|
||||
url = repositoryDir.resolve("releases").toURI()
|
||||
}
|
||||
maven {
|
||||
name = "HighCapableMavenSnapShots"
|
||||
url = repositoryDir.resolve("snapshots").toURI()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/22.
|
||||
*/
|
||||
package com.highcapable.gropify.gradle.api
|
||||
|
||||
import org.gradle.api.initialization.Settings
|
||||
import org.gradle.api.invocation.Gradle
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/**
|
||||
* Gradle description implementation.
|
||||
*/
|
||||
internal object GradleDescriptor {
|
||||
|
||||
private var gradle by Delegates.notNull<Gradle>()
|
||||
|
||||
/** Current Gradle version. */
|
||||
val version get() = gradle.gradleVersion
|
||||
|
||||
/**
|
||||
* Initialize Gradle instance.
|
||||
* @param settings the current Gradle settings instance.
|
||||
*/
|
||||
fun init(settings: Settings) {
|
||||
gradle = settings.gradle
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
package com.highcapable.gropify.gradle.api.entity
|
||||
|
||||
/**
|
||||
* Dependency entity.
|
||||
* @param groupId the group ID.
|
||||
* @param artifactId the artifact ID.
|
||||
* @param version the current version.
|
||||
*/
|
||||
internal data class Dependency(
|
||||
val groupId: String,
|
||||
val artifactId: String,
|
||||
val version: String
|
||||
) {
|
||||
|
||||
/**
|
||||
* Get [Dependency] relative path.
|
||||
* @return [String]
|
||||
*/
|
||||
val relativePath get() = "${groupId.toPathName()}/$artifactId/$version"
|
||||
|
||||
private fun String.toPathName() = trim()
|
||||
.replace(".", "/")
|
||||
.replace("_", "/")
|
||||
.replace(":", "/")
|
||||
.replace("-", "/")
|
||||
|
||||
override fun toString() = "$groupId:$artifactId:$version"
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* SweetProperty - An easy get project properties anywhere Gradle plugin.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/SweetProperty
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2023/8/28.
|
||||
*/
|
||||
package com.highcapable.gropify.gradle.api.entity
|
||||
|
||||
import com.highcapable.gropify.gradle.api.extension.getFullName
|
||||
import com.highcapable.gropify.internal.error
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.initialization.Settings
|
||||
import java.io.File
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/**
|
||||
* Project description implementation.
|
||||
*/
|
||||
internal class ProjectDescriptor private constructor() {
|
||||
|
||||
internal companion object {
|
||||
|
||||
/**
|
||||
* Create [ProjectDescriptor] from [Settings].
|
||||
* @param settings the current settings.
|
||||
* @param name the project name, leave it blank to get root project.
|
||||
* @return [ProjectDescriptor]
|
||||
*/
|
||||
fun create(settings: Settings, name: String = "") = ProjectDescriptor().also {
|
||||
val isRootProject = name.isBlank() || name.lowercase() == settings.rootProject.name.lowercase()
|
||||
val subProjectNotice = "if this is a sub-project, please set it like \":$name\""
|
||||
|
||||
it.type = Type.Settings
|
||||
it.name = name.ifBlank { null } ?: settings.rootProject.name
|
||||
it.currentDir = (if (isRootProject) settings.rootProject else settings.findProject(name))?.projectDir
|
||||
?: Gropify.error("Project '$name' not found${if (!name.startsWith(":")) ", $subProjectNotice." else "."}")
|
||||
it.rootDir = settings.rootDir
|
||||
it.homeDir = settings.gradle.gradleUserHomeDir
|
||||
}
|
||||
|
||||
/**
|
||||
* Create [ProjectDescriptor] from [Project].
|
||||
* @param project the current project.
|
||||
* @return [ProjectDescriptor]
|
||||
*/
|
||||
fun create(project: Project) = ProjectDescriptor().also {
|
||||
it.type = Type.Project
|
||||
it.name = project.getFullName()
|
||||
it.currentDir = project.projectDir
|
||||
it.rootDir = project.rootDir
|
||||
it.homeDir = project.gradle.gradleUserHomeDir
|
||||
}
|
||||
}
|
||||
|
||||
/** The buildscript type. */
|
||||
var type by Delegates.notNull<Type>()
|
||||
|
||||
/** The project name. */
|
||||
var name = ""
|
||||
|
||||
/** The current project directory. */
|
||||
var currentDir by Delegates.notNull<File>()
|
||||
|
||||
/** The root project directory. */
|
||||
var rootDir by Delegates.notNull<File>()
|
||||
|
||||
/** The Gradle home directory. */
|
||||
var homeDir by Delegates.notNull<File>()
|
||||
|
||||
/**
|
||||
* Project type definition.
|
||||
*/
|
||||
enum class Type {
|
||||
Settings,
|
||||
Project
|
||||
}
|
||||
|
||||
override fun toString() = "ProjectDescriptor(type=$type, name=$name)"
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
package com.highcapable.gropify.gradle.api.extension
|
||||
|
||||
import com.highcapable.gropify.internal.error
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import com.highcapable.gropify.utils.extension.camelcase
|
||||
import com.highcapable.kavaref.extension.classOf
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.plugins.ExtensionAware
|
||||
|
||||
/**
|
||||
* Create or get extension.
|
||||
* @receiver [ExtensionAware]
|
||||
* @param name the name, auto called by [toSafeExtName].
|
||||
* @param target the target class.
|
||||
* @param args the constructor arguments.
|
||||
* @return [ExtensionAware]
|
||||
*/
|
||||
internal fun ExtensionAware.getOrCreate(name: String, target: Class<*>, vararg args: Any) = name.toSafeExtName().let { sName ->
|
||||
runCatching { extensions.create(sName, target, *args).asExtension() }.getOrElse {
|
||||
if (!(it is IllegalArgumentException && it.message?.startsWith("Cannot add extension with name.") == true)) throw it
|
||||
runCatching { extensions.getByName(sName).asExtension() }.getOrNull() ?: Gropify.error("Create or get extension failed with name \"$sName\".")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or get extension [T].
|
||||
* @receiver [ExtensionAware]
|
||||
* @param name the name, auto called by [toSafeExtName].
|
||||
* @param args the constructor arguments.
|
||||
* @return [ExtensionAware]
|
||||
*/
|
||||
internal inline fun <reified T : Any> ExtensionAware.getOrCreate(name: String, vararg args: Any) = name.toSafeExtName().let { sName ->
|
||||
runCatching { extensions.create(sName, classOf<T>(), *args) }.getOrElse {
|
||||
if (!(it is IllegalArgumentException && it.message?.startsWith("Cannot add extension with name.") == true)) throw it
|
||||
runCatching { extensions.getByName(sName) as? T? }.getOrNull() ?: Gropify.error("Create or get extension failed with name \"$sName\".")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get extension.
|
||||
* @receiver [ExtensionAware]
|
||||
* @param name the name.
|
||||
* @return [ExtensionAware]
|
||||
*/
|
||||
internal fun ExtensionAware.get(name: String) = runCatching {
|
||||
extensions.getByName(name).asExtension()
|
||||
}.getOrNull() ?: Gropify.error("Could not get extension with name \"$name\".")
|
||||
|
||||
/**
|
||||
* Get extension or null if not exists.
|
||||
* @receiver [ExtensionAware]
|
||||
* @param name the name.
|
||||
* @return [ExtensionAware] or null.
|
||||
*/
|
||||
internal fun ExtensionAware.getOrNull(name: String) = runCatching {
|
||||
extensions.getByName(name).asExtension()
|
||||
}.getOrNull()
|
||||
|
||||
/**
|
||||
* Get extension, target [T].
|
||||
* @receiver [ExtensionAware]
|
||||
* @param name the name.
|
||||
* @return [T]
|
||||
*/
|
||||
internal inline fun <reified T> ExtensionAware.get(name: String) = runCatching {
|
||||
extensions.getByName(name) as T
|
||||
}.getOrNull() ?: Gropify.error("Could not get extension with name \"$name\".")
|
||||
|
||||
/**
|
||||
* Get extension, target [T].
|
||||
* @receiver [ExtensionAware]
|
||||
* @return [T]
|
||||
*/
|
||||
internal inline fun <reified T : Any> ExtensionAware.get() = runCatching {
|
||||
extensions.getByType(classOf<T>())
|
||||
}.getOrNull() ?: Gropify.error("Could not get extension with type ${classOf<T>()}.")
|
||||
|
||||
/**
|
||||
* Configure extension, target [T].
|
||||
* @receiver [ExtensionAware]
|
||||
* @param name the name.
|
||||
* @param configure the configure action.
|
||||
*/
|
||||
internal inline fun <reified T : Any> ExtensionAware.configure(name: String, configure: Action<T>) = extensions.configure(name, configure)
|
||||
|
||||
/**
|
||||
* Detect whether the extension exists.
|
||||
* @receiver [ExtensionAware]
|
||||
* @param name the name.
|
||||
* @return [Boolean]
|
||||
*/
|
||||
internal fun ExtensionAware.hasExtension(name: String) = runCatching { extensions.getByName(name); true }.getOrNull() ?: false
|
||||
|
||||
/**
|
||||
* Convert to [ExtensionAware].
|
||||
* @receiver [Any]
|
||||
* @return [ExtensionAware]
|
||||
* @throws IllegalStateException when the instance is not a valid [ExtensionAware].
|
||||
*/
|
||||
internal fun Any.asExtension() = this as? ExtensionAware? ?: Gropify.error("This instance \"$this\" is not a valid ExtensionAware.")
|
||||
|
||||
/**
|
||||
* Since Gradle has an [ExtensionAware] extension,
|
||||
* this function is used to detect if the current string is a keyword name used by Gradle.
|
||||
* @receiver [String]
|
||||
* @return [Boolean]
|
||||
*/
|
||||
internal fun String.isUnSafeExtName() = camelcase().let { it == "ext" || it == "extra" || it == "extraProperties" || it == "extensions" }
|
||||
|
||||
/**
|
||||
* Since Gradle has an [ExtensionAware] extension,
|
||||
* this function is used to convert non-conforming strings to "{string}s"
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.toSafeExtName() = if (isUnSafeExtName()) "${this}s" else this
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
package com.highcapable.gropify.gradle.api.extension
|
||||
|
||||
import com.highcapable.gropify.gradle.api.entity.Dependency
|
||||
import com.highcapable.gropify.utils.extension.toFile
|
||||
import com.highcapable.kavaref.extension.toClassOrNull
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.buildscript
|
||||
import org.gradle.kotlin.dsl.repositories
|
||||
|
||||
/**
|
||||
* Get the full name of the specified project.
|
||||
* @receiver [Project]
|
||||
* @param useColon whether to use a colon before sub-items, default is true.
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun Project.getFullName(useColon: Boolean = true): String {
|
||||
val isRoot = this == rootProject
|
||||
val baseNames = mutableListOf<String>()
|
||||
|
||||
fun fetchChild(project: Project) {
|
||||
project.parent?.also { if (it != it.rootProject) fetchChild(it) }
|
||||
baseNames.add(project.name)
|
||||
}
|
||||
|
||||
fetchChild(project = this)
|
||||
|
||||
return buildString {
|
||||
baseNames.onEach { append(":$it") }.clear()
|
||||
}.let { if (useColon && !isRoot) it else it.drop(1) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Add custom dependency to the buildscript.
|
||||
* @receiver [Project]
|
||||
* @param repositoryPath the repository path.
|
||||
* @param dependency the dependency entity.
|
||||
*/
|
||||
internal fun Project.addDependencyToBuildscript(repositoryPath: String, dependency: Dependency) {
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
url = repositoryPath.toFile().toURI()
|
||||
mavenContent { includeGroup(dependency.groupId) }
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath(dependency.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert string to class or null by project buildscript classloader.
|
||||
* @receiver [String]
|
||||
* @param project the target [Project].
|
||||
* @return [Class] or null.
|
||||
*/
|
||||
internal fun String.toClassOrNull(project: Project) = toClassOrNull(project.buildscript.classLoader)
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
package com.highcapable.gropify.gradle.api.plugin
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.initialization.Settings
|
||||
|
||||
/**
|
||||
* Gradle plugin lifecycle interface.
|
||||
*/
|
||||
internal interface PluginLifecycle {
|
||||
|
||||
/**
|
||||
* Callback when Gradle starts loading.
|
||||
*/
|
||||
fun onCreate(settings: Settings)
|
||||
|
||||
/**
|
||||
* Callback when Gradle settings evaluation is complete.
|
||||
*/
|
||||
fun onSettingsEvaluated(settings: Settings)
|
||||
|
||||
/**
|
||||
* Callback when Gradle root project starts evaluation.
|
||||
*/
|
||||
fun beforeProjectEvaluate(rootProject: Project)
|
||||
|
||||
/**
|
||||
* Callback when Gradle root project evaluation is complete.
|
||||
*/
|
||||
fun afterProjectEvaluate(rootProject: Project)
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/16.
|
||||
*/
|
||||
@file:Suppress("UnusedReceiverParameter")
|
||||
|
||||
package com.highcapable.gropify.internal
|
||||
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
/**
|
||||
* Gropify exception.
|
||||
*/
|
||||
internal class GropifyException(message: String) : IllegalStateException("Gropify was ran into an error: $message")
|
||||
|
||||
/**
|
||||
* Throws a [GropifyException] with the specified [message].
|
||||
*/
|
||||
internal fun Gropify.error(message: String): Nothing = throw GropifyException(message)
|
||||
|
||||
/**
|
||||
* Requires that a condition is true. If it is not, throws a [GropifyException] with the result of
|
||||
* calling the specified [lazyMessage] function.
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
internal fun Gropify.require(value: Boolean, lazyMessage: () -> Any) {
|
||||
contract {
|
||||
returns() implies value
|
||||
}
|
||||
if (!value) {
|
||||
val message = lazyMessage()
|
||||
throw GropifyException(message.toString())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/16.
|
||||
*/
|
||||
@file:Suppress("unused", "LoggingStringTemplateAsArgument")
|
||||
|
||||
package com.highcapable.gropify.internal
|
||||
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.logging.Logger
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/**
|
||||
* Gropify logger.
|
||||
*/
|
||||
internal object Logger {
|
||||
|
||||
private var logger by Delegates.notNull<Logger>()
|
||||
|
||||
/**
|
||||
* Initialize logger with project.
|
||||
* @param project the project.
|
||||
* @return [Logger]
|
||||
*/
|
||||
fun init(project: Project) = apply {
|
||||
logger = project.logger
|
||||
}
|
||||
|
||||
internal fun debug(msg: Any) = logger.debug("[${Gropify.TAG}] $msg")
|
||||
internal fun info(msg: Any) = logger.info("[${Gropify.TAG}] $msg")
|
||||
internal fun warn(msg: Any) = logger.warn("[${Gropify.TAG}] $msg")
|
||||
internal fun error(msg: Any) = logger.error("[${Gropify.TAG}] $msg")
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/12.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin
|
||||
|
||||
import com.highcapable.gropify.gradle.api.entity.ProjectDescriptor
|
||||
import com.highcapable.gropify.internal.require
|
||||
import com.highcapable.gropify.plugin.config.proxy.GropifyConfig
|
||||
import com.highcapable.gropify.plugin.config.type.GropifyLocation
|
||||
import com.highcapable.gropify.plugin.deployer.BuildscriptDeployer
|
||||
import com.highcapable.gropify.plugin.deployer.SourceCodeDeployer
|
||||
import com.highcapable.gropify.plugin.generator.extension.PropertyMap
|
||||
import com.highcapable.gropify.utils.extension.hasInterpolation
|
||||
import com.highcapable.gropify.utils.extension.removeSurroundingQuotes
|
||||
import com.highcapable.gropify.utils.extension.replaceInterpolation
|
||||
import com.highcapable.gropify.utils.extension.toStringMap
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.initialization.Settings
|
||||
import java.io.File
|
||||
import java.io.FileReader
|
||||
import java.util.*
|
||||
import kotlin.collections.component1
|
||||
import kotlin.collections.component2
|
||||
import kotlin.collections.set
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/**
|
||||
* Default properties' key-values deployer.
|
||||
*/
|
||||
internal object DefaultDeployer {
|
||||
|
||||
private var config by Delegates.notNull<GropifyConfig>()
|
||||
|
||||
private var lastModifiedHashCode = 0
|
||||
private var configModified = true
|
||||
|
||||
private val deployers by lazy {
|
||||
listOf(
|
||||
BuildscriptDeployer { config },
|
||||
SourceCodeDeployer { config }
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize deployers.
|
||||
* @param settings the current Gradle settings.
|
||||
* @param config the gropify configuration.
|
||||
*/
|
||||
fun init(settings: Settings, config: GropifyConfig) {
|
||||
DefaultDeployer.config = config
|
||||
if (!config.isEnabled) return
|
||||
|
||||
checkingConfigModified(settings)
|
||||
|
||||
deployers.forEach { it.init(settings, configModified) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve deployers before project evaluation.
|
||||
* @param rootProject the current root project.
|
||||
*/
|
||||
fun resolve(rootProject: Project) {
|
||||
if (!config.isEnabled) return
|
||||
|
||||
deployers.forEach { it.resolve(rootProject, configModified) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy deployers after project evaluation.
|
||||
* @param rootProject the current root project.
|
||||
*/
|
||||
fun deploy(rootProject: Project) {
|
||||
if (!config.isEnabled) return
|
||||
|
||||
deployers.forEach { it.deploy(rootProject, configModified) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate properties' key-values map.
|
||||
* @param config the generate configuration.
|
||||
* @param descriptor the project descriptor.
|
||||
* @return [PropertyMap]
|
||||
*/
|
||||
fun generateMap(config: GropifyConfig.CommonGenerateConfig, descriptor: ProjectDescriptor): PropertyMap {
|
||||
val properties = mutableMapOf<String, Any>()
|
||||
val resolveProperties = mutableMapOf<Any?, Any?>()
|
||||
|
||||
config.permanentKeyValues.forEach { (key, value) -> properties[key] = value }
|
||||
config.locations.forEach { location ->
|
||||
when (location) {
|
||||
GropifyLocation.CurrentProject -> createProperties(config, descriptor.currentDir).forEach { resolveProperties.putAll(it) }
|
||||
GropifyLocation.RootProject -> createProperties(config, descriptor.rootDir).forEach { resolveProperties.putAll(it) }
|
||||
GropifyLocation.Global -> createProperties(config, descriptor.homeDir).forEach { resolveProperties.putAll(it) }
|
||||
GropifyLocation.System -> resolveProperties.putAll(System.getProperties())
|
||||
GropifyLocation.SystemEnv -> resolveProperties.putAll(System.getenv())
|
||||
}
|
||||
}
|
||||
|
||||
resolveProperties.filter { (key, value) ->
|
||||
if (config.excludeNonStringValue)
|
||||
key is CharSequence && key.isNotBlank() && value is CharSequence
|
||||
else key.toString().isNotBlank() && value != null
|
||||
}.toStringMap().filter { (key, _) ->
|
||||
config.includeKeys.ifEmpty { null }?.any { content ->
|
||||
when (content) {
|
||||
is Regex -> content.matches(key)
|
||||
else -> content.toString() == key
|
||||
}
|
||||
} ?: true
|
||||
}.filter { (key, _) ->
|
||||
config.excludeKeys.ifEmpty { null }?.none { content ->
|
||||
when (content) {
|
||||
is Regex -> content.matches(key)
|
||||
else -> content.toString() == key
|
||||
}
|
||||
} ?: true
|
||||
}.toMutableMap().also { resolveKeyValues ->
|
||||
resolveKeyValues.onEach { (key, value) ->
|
||||
val resolveKeys = mutableListOf<String>()
|
||||
|
||||
fun String.resolveValue(): String = replaceInterpolation { matchKey ->
|
||||
Gropify.require(resolveKeys.size <= 5) {
|
||||
"Key \"$key\" has been called recursively multiple times of those $resolveKeys."
|
||||
}
|
||||
|
||||
resolveKeys.add(matchKey)
|
||||
var resolveValue = if (config.useValueInterpolation)
|
||||
resolveKeyValues[matchKey] ?: ""
|
||||
else matchKey
|
||||
resolveValue = resolveValue.removeSurroundingQuotes()
|
||||
|
||||
if (resolveValue.hasInterpolation()) resolveValue.resolveValue()
|
||||
else resolveValue
|
||||
}
|
||||
|
||||
if (value.hasInterpolation()) resolveKeyValues[key] = value.resolveValue()
|
||||
}.takeIf { config.keyValuesRules.isNotEmpty() }?.forEach { (key, value) ->
|
||||
config.keyValuesRules[key]?.also { resolveKeyValues[key] = it(value) }
|
||||
}
|
||||
|
||||
properties.putAll(resolveKeyValues)
|
||||
}
|
||||
|
||||
// Replace all key-values if exists.
|
||||
config.replacementKeyValues.forEach { (key, value) -> properties[key] = value }
|
||||
|
||||
return properties
|
||||
}
|
||||
|
||||
private fun createProperties(config: GropifyConfig.CommonGenerateConfig, dir: File?) = runCatching {
|
||||
mutableListOf<Properties>().apply {
|
||||
config.existsPropertyFiles.forEach {
|
||||
val propertiesFile = dir?.resolve(it)
|
||||
if (propertiesFile?.exists() == true)
|
||||
add(Properties().apply { load(FileReader(propertiesFile.absolutePath)) })
|
||||
}
|
||||
}
|
||||
}.getOrNull() ?: mutableListOf()
|
||||
|
||||
private fun checkingConfigModified(settings: Settings) {
|
||||
settings.settingsDir.also { dir ->
|
||||
val groovyHashCode = dir.resolve("settings.gradle").takeIf { it.exists() }?.readText()?.hashCode()
|
||||
val kotlinHashCode = dir.resolve("settings.gradle.kts").takeIf { it.exists() }?.readText()?.hashCode()
|
||||
val gradleHashCode = groovyHashCode ?: kotlinHashCode ?: -1
|
||||
|
||||
configModified = gradleHashCode == -1 || lastModifiedHashCode != gradleHashCode
|
||||
lastModifiedHashCode = gradleHashCode
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/13.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin
|
||||
|
||||
import com.highcapable.gropify.generated.GropifyProperties
|
||||
|
||||
/**
|
||||
* Here is Gropify!
|
||||
*/
|
||||
object Gropify {
|
||||
|
||||
internal const val GROUP_NAME = GropifyProperties.PROJECT_GROUP_NAME
|
||||
|
||||
const val TAG = GropifyProperties.PROJECT_NAME
|
||||
const val VERSION = GropifyProperties.PROJECT_VERSION
|
||||
const val PROJECT_URL = GropifyProperties.PROJECT_URL
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin
|
||||
|
||||
import com.highcapable.gropify.gradle.api.GradleDescriptor
|
||||
import com.highcapable.gropify.gradle.api.extension.getOrCreate
|
||||
import com.highcapable.gropify.gradle.api.plugin.PluginLifecycle
|
||||
import com.highcapable.gropify.internal.Logger
|
||||
import com.highcapable.gropify.internal.error
|
||||
import com.highcapable.gropify.plugin.extension.dsl.configure.GropifyConfigureExtension
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.initialization.Settings
|
||||
|
||||
/**
|
||||
* Lifecycle for Gropify.
|
||||
*/
|
||||
internal class GropifyLifecycle : PluginLifecycle {
|
||||
|
||||
private var configure: GropifyConfigureExtension? = null
|
||||
|
||||
override fun onCreate(settings: Settings) {
|
||||
GradleDescriptor.init(settings)
|
||||
|
||||
configure = settings.getOrCreate<GropifyConfigureExtension>(GropifyConfigureExtension.NAME)
|
||||
}
|
||||
|
||||
override fun onSettingsEvaluated(settings: Settings) {
|
||||
val config = configure?.build(settings) ?: Gropify.error("Extension \"${GropifyConfigureExtension.NAME}\" create failed.")
|
||||
|
||||
DefaultDeployer.init(settings, config)
|
||||
}
|
||||
|
||||
override fun beforeProjectEvaluate(rootProject: Project) {
|
||||
Logger.init(rootProject)
|
||||
DefaultDeployer.resolve(rootProject)
|
||||
}
|
||||
|
||||
override fun afterProjectEvaluate(rootProject: Project) {
|
||||
DefaultDeployer.deploy(rootProject)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/8.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.gropify.plugin
|
||||
|
||||
import com.highcapable.gropify.internal.Logger
|
||||
import com.highcapable.gropify.internal.error
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.initialization.Settings
|
||||
import org.gradle.api.plugins.ExtensionAware
|
||||
|
||||
/**
|
||||
* Entry class for Gropify plugin.
|
||||
*/
|
||||
class GropifyPlugin<T : ExtensionAware> internal constructor() : Plugin<T> {
|
||||
|
||||
private val lifecycle = GropifyLifecycle()
|
||||
|
||||
override fun apply(target: T) = when (target) {
|
||||
is Settings -> {
|
||||
val lifecycle = this.lifecycle
|
||||
|
||||
lifecycle.onCreate(target)
|
||||
|
||||
target.gradle.settingsEvaluated {
|
||||
lifecycle.onSettingsEvaluated(target)
|
||||
}
|
||||
|
||||
target.gradle.projectsLoaded {
|
||||
rootProject.beforeEvaluate {
|
||||
lifecycle.beforeProjectEvaluate(rootProject = this)
|
||||
}
|
||||
rootProject.afterEvaluate {
|
||||
lifecycle.afterProjectEvaluate(rootProject = this)
|
||||
}
|
||||
}
|
||||
}
|
||||
is Project -> Logger.init(target).error(
|
||||
"Gropify can only applied in settings.gradle or settings.gradle.kts, but current is $target, stop loading.",
|
||||
)
|
||||
else -> Gropify.error("Gropify applied to an unknown target: $target, stop loading.")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/8.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.compiler
|
||||
|
||||
import com.highcapable.gropify.gradle.api.entity.Dependency
|
||||
import com.highcapable.gropify.internal.error
|
||||
import com.highcapable.gropify.internal.require
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import com.highcapable.gropify.utils.extension.deleteEmptyRecursively
|
||||
import com.highcapable.gropify.utils.extension.toFile
|
||||
import net.lingala.zip4j.ZipFile
|
||||
import net.lingala.zip4j.model.ZipParameters
|
||||
import java.io.File
|
||||
import javax.tools.DiagnosticCollector
|
||||
import javax.tools.JavaFileObject
|
||||
import javax.tools.StandardLocation
|
||||
import javax.tools.ToolProvider
|
||||
|
||||
/**
|
||||
* Java code compiler.
|
||||
*/
|
||||
internal object CodeCompiler {
|
||||
|
||||
private const val MAVEN_MODEL_VERSION = "4.0.0"
|
||||
|
||||
/**
|
||||
* Compile [JavaFileObject] as a dependency.
|
||||
* @param dependency the dependency entity.
|
||||
* @param outputDirPath the compile output directory path.
|
||||
* @param files the compile [JavaFileObject] array.
|
||||
* @param compileOnlyFiles the compile only [JavaFileObject] array.
|
||||
* @throws IllegalStateException if compilation fails.
|
||||
*/
|
||||
fun compile(
|
||||
dependency: Dependency,
|
||||
outputDirPath: String,
|
||||
files: List<JavaFileObject>,
|
||||
compileOnlyFiles: List<JavaFileObject> = mutableListOf()
|
||||
) {
|
||||
val outputDir = outputDirPath.toFile()
|
||||
|
||||
if (files.isEmpty()) {
|
||||
if (outputDir.exists()) outputDir.deleteRecursively()
|
||||
|
||||
return
|
||||
} else outputDir.also { if (!it.exists()) it.mkdirs() }
|
||||
|
||||
val outputBuildDir = "$outputDirPath/build".toFile().also {
|
||||
if (it.exists()) it.deleteRecursively()
|
||||
it.mkdirs()
|
||||
}
|
||||
|
||||
val outputClassesDir = "${outputBuildDir.absolutePath}/classes".toFile().apply { mkdirs() }
|
||||
val outputSourcesDir = "${outputBuildDir.absolutePath}/sources".toFile().apply { mkdirs() }
|
||||
|
||||
val compiler = ToolProvider.getSystemJavaCompiler()
|
||||
val diagnostics = DiagnosticCollector<JavaFileObject>()
|
||||
|
||||
val fileManager = compiler.getStandardFileManager(diagnostics, null, null)
|
||||
fileManager.setLocation(StandardLocation.CLASS_OUTPUT, listOf(outputClassesDir))
|
||||
|
||||
val task = compiler.getTask(null, fileManager, diagnostics, null, null, compileOnlyFiles + files)
|
||||
|
||||
val result = task.call()
|
||||
var diagnosticsMessage = ""
|
||||
|
||||
diagnostics.diagnostics?.forEach { diagnostic ->
|
||||
diagnosticsMessage += " > Error on line ${diagnostic.lineNumber} in ${diagnostic.source?.toUri()}\n"
|
||||
diagnosticsMessage += " ${diagnostic.getMessage(null)}\n"
|
||||
}
|
||||
|
||||
runCatching { fileManager.close() }
|
||||
|
||||
compileOnlyFiles.forEach {
|
||||
"${outputClassesDir.absolutePath}/${it.name}"
|
||||
.replace(".java", ".class")
|
||||
.toFile()
|
||||
.delete()
|
||||
}
|
||||
|
||||
files.forEach {
|
||||
it.toFiles(outputSourcesDir).also { (sourceDir, sourceFile) ->
|
||||
sourceDir.mkdirs()
|
||||
sourceFile.writeText(it.getCharContent(true).toString())
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
outputClassesDir.deleteEmptyRecursively()
|
||||
|
||||
writeMetaInf(outputClassesDir)
|
||||
writeMetaInf(outputSourcesDir)
|
||||
|
||||
createJar(dependency, outputDir, outputBuildDir, outputClassesDir, outputSourcesDir)
|
||||
} else Gropify.error("Failed to compile java files into path: $outputDirPath\n$diagnosticsMessage")
|
||||
}
|
||||
|
||||
private fun createJar(dependency: Dependency, outputDir: File, buildDir: File, classesDir: File, sourcesDir: File) {
|
||||
val dependencyDir = outputDir.resolve(dependency.relativePath).also { if (!it.exists()) it.mkdirs() }
|
||||
|
||||
packageJar(classesDir, dependencyDir, dependency, sourcesJar = false)
|
||||
packageJar(sourcesDir, dependencyDir, dependency, sourcesJar = true)
|
||||
writeDependency(dependencyDir, dependency)
|
||||
|
||||
buildDir.deleteRecursively()
|
||||
}
|
||||
|
||||
private fun writeMetaInf(dir: File) {
|
||||
val metaInfDir = dir.resolve("META-INF").apply { mkdirs() }
|
||||
metaInfDir.resolve("MANIFEST.MF").writeText("Manifest-Version: 1.0")
|
||||
}
|
||||
|
||||
private fun writeDependency(dir: File, dependency: Dependency) {
|
||||
dir.resolve("${dependency.artifactId}-${dependency.version}.pom").writeText(
|
||||
"""
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/$MAVEN_MODEL_VERSION"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/$MAVEN_MODEL_VERSION https://maven.apache.org/xsd/maven-$MAVEN_MODEL_VERSION.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>$MAVEN_MODEL_VERSION</modelVersion>
|
||||
<groupId>${dependency.groupId}</groupId>
|
||||
<artifactId>${dependency.artifactId}</artifactId>
|
||||
<version>${dependency.version}</version>
|
||||
</project>
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
private fun JavaFileObject.toFiles(outputDir: File): Pair<File, File> {
|
||||
val outputDirPath = outputDir.absolutePath
|
||||
val separator = if (name.contains("/")) "/" else "\\"
|
||||
val names = name.split(separator)
|
||||
|
||||
val fileName = names[names.lastIndex]
|
||||
val folderName = name.replace(fileName, "")
|
||||
|
||||
return "$outputDirPath/$folderName".toFile() to "$outputDirPath/$name".toFile()
|
||||
}
|
||||
|
||||
private fun packageJar(buildDir: File, outputDir: File, dependency: Dependency, sourcesJar: Boolean) {
|
||||
Gropify.require(buildDir.exists()) {
|
||||
"Build directory not found: ${buildDir.absolutePath}."
|
||||
}
|
||||
|
||||
val jarFile = outputDir.resolve("${dependency.artifactId}-${dependency.version}${if (sourcesJar) "-sources" else ""}.jar")
|
||||
if (jarFile.exists()) jarFile.delete()
|
||||
|
||||
ZipFile(jarFile).addFolder(buildDir, ZipParameters().apply { isIncludeRootFolder = false })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/8.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.gropify.plugin.compiler.extension
|
||||
|
||||
import com.highcapable.gropify.gradle.api.entity.Dependency
|
||||
import com.highcapable.gropify.plugin.compiler.CodeCompiler
|
||||
import com.palantir.javapoet.JavaFile
|
||||
import javax.tools.JavaFileObject
|
||||
|
||||
/**
|
||||
* Compile [JavaFile] as a dependency.
|
||||
* @receiver [JavaFile]
|
||||
* @param dependency the dependency entity.
|
||||
* @param outputDirPath the compile output directory path.
|
||||
* @param compileOnlyFiles the compile only [JavaFile] array.
|
||||
* @throws IllegalStateException if compilation fails.
|
||||
*/
|
||||
@JvmName("compileWithJavaFile")
|
||||
internal fun JavaFile.compile(
|
||||
dependency: Dependency,
|
||||
outputDirPath: String,
|
||||
compileOnlyFiles: List<JavaFile> = mutableListOf()
|
||||
) = CodeCompiler.compile(
|
||||
dependency = dependency,
|
||||
outputDirPath = outputDirPath,
|
||||
files = listOf(toJavaFileObject()),
|
||||
compileOnlyFiles = mutableListOf<JavaFileObject>().also {
|
||||
compileOnlyFiles.forEach { file ->
|
||||
it.add(file.toJavaFileObject())
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
/**
|
||||
* Compile [List]<[JavaFile]> as a dependency.
|
||||
* @receiver [List]<[JavaFile]>
|
||||
* @param dependency the dependency entity.
|
||||
* @param outputDirPath the compile output directory path.
|
||||
* @param compileOnlyFiles the compile only [JavaFile] array.
|
||||
* @throws IllegalStateException if compilation fails.
|
||||
*/
|
||||
@JvmName("compileWithJavaFile")
|
||||
internal fun List<JavaFile>.compile(
|
||||
dependency: Dependency,
|
||||
outputDirPath: String,
|
||||
compileOnlyFiles: List<JavaFile> = mutableListOf()
|
||||
) = CodeCompiler.compile(
|
||||
dependency = dependency,
|
||||
outputDirPath = outputDirPath,
|
||||
files = mutableListOf<JavaFileObject>().also {
|
||||
forEach { file ->
|
||||
it.add(file.toJavaFileObject())
|
||||
}
|
||||
},
|
||||
compileOnlyFiles = mutableListOf<JavaFileObject>().also {
|
||||
compileOnlyFiles.forEach { file ->
|
||||
it.add(file.toJavaFileObject())
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
/**
|
||||
* Compile [JavaFileObject] as a dependency.
|
||||
* @receiver [JavaFileObject]
|
||||
* @param dependency the dependency entity.
|
||||
* @param outputDirPath the compile output directory path.
|
||||
* @param compileOnlyFiles the compile only [JavaFileObject] array.
|
||||
* @throws IllegalStateException if compilation fails.
|
||||
*/
|
||||
@JvmName("compileWithJavaFileObject")
|
||||
internal fun JavaFileObject.compile(
|
||||
dependency: Dependency,
|
||||
outputDirPath: String,
|
||||
compileOnlyFiles: List<JavaFileObject> = mutableListOf()
|
||||
) = CodeCompiler.compile(dependency, outputDirPath, listOf(this), compileOnlyFiles)
|
||||
|
||||
/**
|
||||
* Compile [List]<[JavaFileObject]> as a dependency.
|
||||
* @receiver [List]<[JavaFileObject]>
|
||||
* @param dependency the dependency entity.
|
||||
* @param outputDirPath the compile output directory path.
|
||||
* @param compileOnlyFiles the compile only [JavaFileObject] array.
|
||||
* @throws IllegalStateException if compilation fails.
|
||||
*/
|
||||
@JvmName("compileWithJavaFileObject")
|
||||
internal fun List<JavaFileObject>.compile(
|
||||
dependency: Dependency,
|
||||
outputDirPath: String,
|
||||
compileOnlyFiles: List<JavaFileObject> = mutableListOf()
|
||||
) = CodeCompiler.compile(dependency, outputDirPath, files = this, compileOnlyFiles)
|
||||
@@ -0,0 +1,353 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.config
|
||||
|
||||
import com.highcapable.gropify.plugin.config.proxy.GropifyConfig
|
||||
import com.highcapable.gropify.plugin.extension.dsl.configure.GropifyConfigureExtension
|
||||
import com.highcapable.gropify.plugin.generator.extension.PropertyValueRule
|
||||
|
||||
/**
|
||||
* Default configuration for Gropify.
|
||||
*/
|
||||
internal object DefaultConfig {
|
||||
|
||||
fun createGenerateConfig(name: String, common: GropifyConfigureExtension.CommonGenerateConfigureScope? = null) =
|
||||
object : GropifyConfig.GenerateConfig {
|
||||
override val buildscript get() = createBuildscriptGenerateConfig(name, common)
|
||||
override val android get() = createAndroidGenerateConfig(name, common)
|
||||
override val jvm get() = createJvmGenerateConfig(name, common)
|
||||
override val kmp get() = createKmpGenerateConfig(name, common)
|
||||
}
|
||||
|
||||
fun createBuildscriptGenerateConfig(
|
||||
name: String,
|
||||
selfCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null,
|
||||
globalCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null
|
||||
) = object : GropifyConfig.BuildscriptGenerateConfig {
|
||||
|
||||
override val name get() = name
|
||||
|
||||
override val extensionName get() = GropifyConfig.DEFAULT_EXTENSION_NAME
|
||||
|
||||
override val isEnabled
|
||||
get() = selfCommon?.isEnabled
|
||||
?: globalCommon?.isEnabled
|
||||
?: createCommonGenerateConfig(name).isEnabled
|
||||
|
||||
override val existsPropertyFiles
|
||||
get() = selfCommon?.existsPropertyFiles
|
||||
?: globalCommon?.existsPropertyFiles
|
||||
?: createCommonGenerateConfig(name).existsPropertyFiles
|
||||
|
||||
override val permanentKeyValues
|
||||
get() = selfCommon?.permanentKeyValues
|
||||
?: globalCommon?.permanentKeyValues
|
||||
?: createCommonGenerateConfig(name).permanentKeyValues
|
||||
|
||||
override val replacementKeyValues
|
||||
get() = selfCommon?.permanentKeyValues
|
||||
?: globalCommon?.permanentKeyValues
|
||||
?: createCommonGenerateConfig(name).permanentKeyValues
|
||||
|
||||
override val excludeKeys
|
||||
get() = selfCommon?.excludeKeys
|
||||
?: globalCommon?.excludeKeys
|
||||
?: createCommonGenerateConfig(name).excludeKeys
|
||||
|
||||
override val includeKeys
|
||||
get() = selfCommon?.includeKeys
|
||||
?: globalCommon?.includeKeys
|
||||
?: createCommonGenerateConfig(name).includeKeys
|
||||
|
||||
override val keyValuesRules
|
||||
get() = selfCommon?.keyValuesRules
|
||||
?: globalCommon?.keyValuesRules
|
||||
?: createCommonGenerateConfig(name).keyValuesRules
|
||||
|
||||
override val excludeNonStringValue
|
||||
get() = selfCommon?.excludeNonStringValue
|
||||
?: globalCommon?.excludeNonStringValue
|
||||
?: createCommonGenerateConfig(name).excludeNonStringValue
|
||||
|
||||
override val useTypeAutoConversion
|
||||
get() = selfCommon?.useTypeAutoConversion
|
||||
?: globalCommon?.useTypeAutoConversion
|
||||
?: createCommonGenerateConfig(name).useTypeAutoConversion
|
||||
|
||||
override val useValueInterpolation
|
||||
get() = selfCommon?.useValueInterpolation
|
||||
?: globalCommon?.useValueInterpolation
|
||||
?: createCommonGenerateConfig(name).useValueInterpolation
|
||||
|
||||
override val locations
|
||||
get() = selfCommon?.locations
|
||||
?: globalCommon?.locations
|
||||
?: createCommonGenerateConfig(name).locations
|
||||
}
|
||||
|
||||
fun createAndroidGenerateConfig(
|
||||
name: String,
|
||||
selfCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null,
|
||||
globalCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null
|
||||
) = object : GropifyConfig.AndroidGenerateConfig {
|
||||
|
||||
override val name get() = name
|
||||
|
||||
override val generateDirPath get() = GropifyConfig.DEFAULT_COMMON_CODE_GENERATE_DIR_PATH
|
||||
|
||||
override val sourceSetName get() = GropifyConfig.DEFAULT_ANDROID_JVM_SOURCE_SET_NAME
|
||||
|
||||
override val useKotlin get() = true
|
||||
|
||||
override val packageName get() = ""
|
||||
|
||||
override val className get() = ""
|
||||
|
||||
override val isRestrictedAccessEnabled get() = false
|
||||
|
||||
override val isIsolationEnabled get() = true
|
||||
|
||||
override val isEnabled
|
||||
get() = selfCommon?.isEnabled
|
||||
?: globalCommon?.isEnabled
|
||||
?: createCommonGenerateConfig(name).isEnabled
|
||||
|
||||
override val existsPropertyFiles
|
||||
get() = selfCommon?.existsPropertyFiles
|
||||
?: globalCommon?.existsPropertyFiles
|
||||
?: createCommonGenerateConfig(name).existsPropertyFiles
|
||||
|
||||
override val permanentKeyValues
|
||||
get() = selfCommon?.permanentKeyValues
|
||||
?: globalCommon?.permanentKeyValues
|
||||
?: createCommonGenerateConfig(name).permanentKeyValues
|
||||
|
||||
override val replacementKeyValues
|
||||
get() = selfCommon?.permanentKeyValues
|
||||
?: globalCommon?.permanentKeyValues
|
||||
?: createCommonGenerateConfig(name).permanentKeyValues
|
||||
|
||||
override val excludeKeys
|
||||
get() = selfCommon?.excludeKeys
|
||||
?: globalCommon?.excludeKeys
|
||||
?: createCommonGenerateConfig(name).excludeKeys
|
||||
|
||||
override val includeKeys
|
||||
get() = selfCommon?.includeKeys
|
||||
?: globalCommon?.includeKeys
|
||||
?: createCommonGenerateConfig(name).includeKeys
|
||||
|
||||
override val keyValuesRules
|
||||
get() = selfCommon?.keyValuesRules
|
||||
?: globalCommon?.keyValuesRules
|
||||
?: createCommonGenerateConfig(name).keyValuesRules
|
||||
|
||||
override val excludeNonStringValue
|
||||
get() = selfCommon?.excludeNonStringValue
|
||||
?: globalCommon?.excludeNonStringValue
|
||||
?: createCommonGenerateConfig(name).excludeNonStringValue
|
||||
|
||||
override val useTypeAutoConversion
|
||||
get() = selfCommon?.useTypeAutoConversion
|
||||
?: globalCommon?.useTypeAutoConversion
|
||||
?: createCommonGenerateConfig(name).useTypeAutoConversion
|
||||
|
||||
override val useValueInterpolation
|
||||
get() = selfCommon?.useValueInterpolation
|
||||
?: globalCommon?.useValueInterpolation
|
||||
?: createCommonGenerateConfig(name).useValueInterpolation
|
||||
|
||||
override val locations
|
||||
get() = selfCommon?.locations
|
||||
?: globalCommon?.locations
|
||||
?: createCommonGenerateConfig(name).locations
|
||||
}
|
||||
|
||||
fun createJvmGenerateConfig(
|
||||
name: String,
|
||||
selfCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null,
|
||||
globalCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null
|
||||
) = object : GropifyConfig.JvmGenerateConfig {
|
||||
|
||||
override val name get() = name
|
||||
|
||||
override val generateDirPath get() = GropifyConfig.DEFAULT_COMMON_CODE_GENERATE_DIR_PATH
|
||||
|
||||
override val sourceSetName get() = GropifyConfig.DEFAULT_ANDROID_JVM_SOURCE_SET_NAME
|
||||
|
||||
override val useKotlin get() = true
|
||||
|
||||
override val packageName get() = ""
|
||||
|
||||
override val className get() = ""
|
||||
|
||||
override val isRestrictedAccessEnabled get() = false
|
||||
|
||||
override val isIsolationEnabled get() = true
|
||||
|
||||
override val isEnabled
|
||||
get() = selfCommon?.isEnabled
|
||||
?: globalCommon?.isEnabled
|
||||
?: createCommonGenerateConfig(name).isEnabled
|
||||
|
||||
override val existsPropertyFiles
|
||||
get() = selfCommon?.existsPropertyFiles
|
||||
?: globalCommon?.existsPropertyFiles
|
||||
?: createCommonGenerateConfig(name).existsPropertyFiles
|
||||
|
||||
override val permanentKeyValues
|
||||
get() = selfCommon?.permanentKeyValues
|
||||
?: globalCommon?.permanentKeyValues
|
||||
?: createCommonGenerateConfig(name).permanentKeyValues
|
||||
|
||||
override val replacementKeyValues
|
||||
get() = selfCommon?.permanentKeyValues
|
||||
?: globalCommon?.permanentKeyValues
|
||||
?: createCommonGenerateConfig(name).permanentKeyValues
|
||||
|
||||
override val excludeKeys
|
||||
get() = selfCommon?.excludeKeys
|
||||
?: globalCommon?.excludeKeys
|
||||
?: createCommonGenerateConfig(name).excludeKeys
|
||||
|
||||
override val includeKeys
|
||||
get() = selfCommon?.includeKeys
|
||||
?: globalCommon?.includeKeys
|
||||
?: createCommonGenerateConfig(name).includeKeys
|
||||
|
||||
override val keyValuesRules
|
||||
get() = selfCommon?.keyValuesRules
|
||||
?: globalCommon?.keyValuesRules
|
||||
?: createCommonGenerateConfig(name).keyValuesRules
|
||||
|
||||
override val excludeNonStringValue
|
||||
get() = selfCommon?.excludeNonStringValue
|
||||
?: globalCommon?.excludeNonStringValue
|
||||
?: createCommonGenerateConfig(name).excludeNonStringValue
|
||||
|
||||
override val useTypeAutoConversion
|
||||
get() = selfCommon?.useTypeAutoConversion
|
||||
?: globalCommon?.useTypeAutoConversion
|
||||
?: createCommonGenerateConfig(name).useTypeAutoConversion
|
||||
|
||||
override val useValueInterpolation
|
||||
get() = selfCommon?.useValueInterpolation
|
||||
?: globalCommon?.useValueInterpolation
|
||||
?: createCommonGenerateConfig(name).useValueInterpolation
|
||||
|
||||
override val locations
|
||||
get() = selfCommon?.locations
|
||||
?: globalCommon?.locations
|
||||
?: createCommonGenerateConfig(name).locations
|
||||
}
|
||||
|
||||
fun createKmpGenerateConfig(
|
||||
name: String,
|
||||
selfCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null,
|
||||
globalCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null
|
||||
) = object : GropifyConfig.KmpGenerateConfig {
|
||||
|
||||
override val name get() = name
|
||||
|
||||
override val generateDirPath get() = GropifyConfig.DEFAULT_COMMON_CODE_GENERATE_DIR_PATH
|
||||
|
||||
override val sourceSetName get() = GropifyConfig.DEFAULT_KMP_COMMON_SOURCE_SET_NAME
|
||||
|
||||
override val packageName get() = ""
|
||||
|
||||
override val className get() = ""
|
||||
|
||||
override val isRestrictedAccessEnabled get() = false
|
||||
|
||||
override val isIsolationEnabled get() = true
|
||||
|
||||
override val isEnabled
|
||||
get() = selfCommon?.isEnabled
|
||||
?: globalCommon?.isEnabled
|
||||
?: createCommonGenerateConfig(name).isEnabled
|
||||
|
||||
override val existsPropertyFiles
|
||||
get() = selfCommon?.existsPropertyFiles
|
||||
?: globalCommon?.existsPropertyFiles
|
||||
?: createCommonGenerateConfig(name).existsPropertyFiles
|
||||
|
||||
override val permanentKeyValues
|
||||
get() = selfCommon?.permanentKeyValues
|
||||
?: globalCommon?.permanentKeyValues
|
||||
?: createCommonGenerateConfig(name).permanentKeyValues
|
||||
|
||||
override val replacementKeyValues
|
||||
get() = selfCommon?.permanentKeyValues
|
||||
?: globalCommon?.permanentKeyValues
|
||||
?: createCommonGenerateConfig(name).permanentKeyValues
|
||||
|
||||
override val excludeKeys
|
||||
get() = selfCommon?.excludeKeys
|
||||
?: globalCommon?.excludeKeys
|
||||
?: createCommonGenerateConfig(name).excludeKeys
|
||||
|
||||
override val includeKeys
|
||||
get() = selfCommon?.includeKeys
|
||||
?: globalCommon?.includeKeys
|
||||
?: createCommonGenerateConfig(name).includeKeys
|
||||
|
||||
override val keyValuesRules
|
||||
get() = selfCommon?.keyValuesRules
|
||||
?: globalCommon?.keyValuesRules
|
||||
?: createCommonGenerateConfig(name).keyValuesRules
|
||||
|
||||
override val excludeNonStringValue
|
||||
get() = selfCommon?.excludeNonStringValue
|
||||
?: globalCommon?.excludeNonStringValue
|
||||
?: createCommonGenerateConfig(name).excludeNonStringValue
|
||||
|
||||
override val useTypeAutoConversion
|
||||
get() = selfCommon?.useTypeAutoConversion
|
||||
?: globalCommon?.useTypeAutoConversion
|
||||
?: createCommonGenerateConfig(name).useTypeAutoConversion
|
||||
|
||||
override val useValueInterpolation
|
||||
get() = selfCommon?.useValueInterpolation
|
||||
?: globalCommon?.useValueInterpolation
|
||||
?: createCommonGenerateConfig(name).useValueInterpolation
|
||||
|
||||
override val locations
|
||||
get() = selfCommon?.locations
|
||||
?: globalCommon?.locations
|
||||
?: createCommonGenerateConfig(name).locations
|
||||
}
|
||||
|
||||
private fun createCommonGenerateConfig(name: String) = object : GropifyConfig.CommonGenerateConfig {
|
||||
override val name get() = name
|
||||
override val isEnabled get() = true
|
||||
override val existsPropertyFiles get() = mutableListOf(GropifyConfig.DEFAULT_EXISTS_PROPERTY_FILE)
|
||||
override val permanentKeyValues get() = mutableMapOf<String, Any>()
|
||||
override val replacementKeyValues get() = mutableMapOf<String, Any>()
|
||||
override val excludeKeys get() = mutableListOf<Any>()
|
||||
override val includeKeys get() = mutableListOf<Any>()
|
||||
override val keyValuesRules get() = mutableMapOf<String, PropertyValueRule>()
|
||||
override val excludeNonStringValue get() = true
|
||||
override val useTypeAutoConversion get() = true
|
||||
override val useValueInterpolation get() = true
|
||||
override val locations get() = GropifyConfig.defaultLocations
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,461 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.config.extension
|
||||
|
||||
import com.highcapable.gropify.gradle.api.extension.getFullName
|
||||
import com.highcapable.gropify.plugin.config.DefaultConfig
|
||||
import com.highcapable.gropify.plugin.config.proxy.GropifyConfig
|
||||
import com.highcapable.gropify.plugin.extension.dsl.configure.GropifyConfigureExtension
|
||||
import org.gradle.api.Project
|
||||
|
||||
internal fun GropifyConfig.from(project: Project) = projects[project.getFullName()] ?: global
|
||||
|
||||
internal fun GropifyConfigureExtension.GenerateConfigureScope.create(
|
||||
name: String = "Global",
|
||||
global: GropifyConfigureExtension.GenerateConfigureScope = this
|
||||
) = object : GropifyConfig.GenerateConfig {
|
||||
|
||||
override val buildscript
|
||||
get() = this@create.buildscriptConfigure?.create(name, global.buildscriptConfigure, this@create.commonConfigure, global.commonConfigure)
|
||||
?: global.buildscriptConfigure?.create(name, this@create.buildscriptConfigure ?: global.buildscriptConfigure)
|
||||
?: DefaultConfig.createGenerateConfig(name, this@create.commonConfigure ?: global.commonConfigure).buildscript
|
||||
|
||||
override val android
|
||||
get() = this@create.androidConfigure?.create(name, global.androidConfigure, this@create.commonConfigure, global.commonConfigure)
|
||||
?: global.androidConfigure?.create(name, this@create.androidConfigure ?: global.androidConfigure)
|
||||
?: DefaultConfig.createGenerateConfig(name, this@create.commonConfigure ?: global.commonConfigure).android
|
||||
|
||||
override val jvm
|
||||
get() = this@create.jvmConfigure?.create(name, global.jvmConfigure, this@create.commonConfigure, global.commonConfigure)
|
||||
?: global.jvmConfigure?.create(name, this@create.jvmConfigure ?: global.jvmConfigure)
|
||||
?: DefaultConfig.createGenerateConfig(name, this@create.commonConfigure ?: global.commonConfigure).jvm
|
||||
|
||||
override val kmp
|
||||
get() = this@create.kmpConfigure?.create(name, global.kmpConfigure, this@create.commonConfigure, global.commonConfigure)
|
||||
?: global.kmpConfigure?.create(name, this@create.kmpConfigure ?: global.kmpConfigure)
|
||||
?: DefaultConfig.createGenerateConfig(name, this@create.commonConfigure ?: global.commonConfigure).kmp
|
||||
}
|
||||
|
||||
private fun GropifyConfigureExtension.BuildscriptGenerateConfigureScope.create(
|
||||
name: String,
|
||||
global: GropifyConfigureExtension.BuildscriptGenerateConfigureScope? = null,
|
||||
selfCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null,
|
||||
globalCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null
|
||||
) = object : GropifyConfig.BuildscriptGenerateConfig {
|
||||
|
||||
override val name get() = name
|
||||
|
||||
override val extensionName
|
||||
get() = this@create.extensionName.ifBlank { null }
|
||||
?: global?.extensionName?.ifBlank { null }
|
||||
?: DefaultConfig.createBuildscriptGenerateConfig(name, selfCommon, globalCommon).extensionName
|
||||
|
||||
override val isEnabled
|
||||
get() = this@create.isEnabled
|
||||
?: selfCommon?.isEnabled
|
||||
?: global?.isEnabled
|
||||
?: globalCommon?.isEnabled
|
||||
?: DefaultConfig.createBuildscriptGenerateConfig(name, selfCommon, globalCommon).isEnabled
|
||||
|
||||
override val existsPropertyFiles
|
||||
get() = this@create.existsPropertyFiles
|
||||
?: global?.existsPropertyFiles
|
||||
?: DefaultConfig.createBuildscriptGenerateConfig(name, selfCommon, globalCommon).existsPropertyFiles
|
||||
|
||||
override val permanentKeyValues
|
||||
get() = this@create.permanentKeyValues
|
||||
?: global?.permanentKeyValues
|
||||
?: DefaultConfig.createBuildscriptGenerateConfig(name, selfCommon, globalCommon).permanentKeyValues
|
||||
|
||||
override val replacementKeyValues
|
||||
get() = this@create.replacementKeyValues
|
||||
?: global?.replacementKeyValues
|
||||
?: DefaultConfig.createBuildscriptGenerateConfig(name, selfCommon, globalCommon).replacementKeyValues
|
||||
|
||||
override val excludeKeys
|
||||
get() = this@create.excludeKeys
|
||||
?: global?.excludeKeys
|
||||
?: DefaultConfig.createBuildscriptGenerateConfig(name, selfCommon, globalCommon).excludeKeys
|
||||
|
||||
override val includeKeys
|
||||
get() = this@create.includeKeys
|
||||
?: global?.includeKeys
|
||||
?: DefaultConfig.createBuildscriptGenerateConfig(name, selfCommon, globalCommon).includeKeys
|
||||
|
||||
override val keyValuesRules
|
||||
get() = this@create.keyValuesRules
|
||||
?: global?.keyValuesRules
|
||||
?: DefaultConfig.createBuildscriptGenerateConfig(name, selfCommon, globalCommon).keyValuesRules
|
||||
|
||||
override val excludeNonStringValue
|
||||
get() = this@create.excludeNonStringValue
|
||||
?: selfCommon?.excludeNonStringValue
|
||||
?: global?.excludeNonStringValue
|
||||
?: globalCommon?.excludeNonStringValue
|
||||
?: DefaultConfig.createBuildscriptGenerateConfig(name, selfCommon, globalCommon).excludeNonStringValue
|
||||
|
||||
override val useTypeAutoConversion
|
||||
get() = this@create.useTypeAutoConversion
|
||||
?: selfCommon?.useTypeAutoConversion
|
||||
?: global?.useTypeAutoConversion
|
||||
?: globalCommon?.useTypeAutoConversion
|
||||
?: DefaultConfig.createBuildscriptGenerateConfig(name, selfCommon, globalCommon).useTypeAutoConversion
|
||||
|
||||
override val useValueInterpolation
|
||||
get() = this@create.useValueInterpolation
|
||||
?: selfCommon?.useValueInterpolation
|
||||
?: global?.useValueInterpolation
|
||||
?: globalCommon?.useValueInterpolation
|
||||
?: DefaultConfig.createBuildscriptGenerateConfig(name, selfCommon, globalCommon).useValueInterpolation
|
||||
|
||||
override val locations
|
||||
get() = this@create.locations
|
||||
?: selfCommon?.locations
|
||||
?: global?.locations
|
||||
?: globalCommon?.locations
|
||||
?: DefaultConfig.createBuildscriptGenerateConfig(name, selfCommon, globalCommon).locations
|
||||
}
|
||||
|
||||
private fun GropifyConfigureExtension.AndroidGenerateConfigureScope.create(
|
||||
name: String,
|
||||
global: GropifyConfigureExtension.AndroidGenerateConfigureScope? = null,
|
||||
selfCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null,
|
||||
globalCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null
|
||||
) = object : GropifyConfig.AndroidGenerateConfig {
|
||||
|
||||
override val name get() = name
|
||||
|
||||
override val isEnabled
|
||||
get() = this@create.isEnabled
|
||||
?: selfCommon?.isEnabled
|
||||
?: global?.isEnabled
|
||||
?: globalCommon?.isEnabled
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).isEnabled
|
||||
|
||||
override val generateDirPath
|
||||
get() = this@create.generateDirPath.ifBlank { null }
|
||||
?: global?.generateDirPath?.ifBlank { null }
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).generateDirPath
|
||||
|
||||
override val sourceSetName
|
||||
get() = this@create.sourceSetName.ifBlank { null }
|
||||
?: global?.sourceSetName?.ifBlank { null }
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).sourceSetName
|
||||
|
||||
override val useKotlin
|
||||
get() = this@create.useKotlin
|
||||
?: global?.useKotlin
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).useKotlin
|
||||
|
||||
override val packageName
|
||||
get() = this@create.packageName.ifBlank { null }
|
||||
?: global?.packageName?.ifBlank { null }
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).packageName
|
||||
|
||||
override val className
|
||||
get() = this@create.className.ifBlank { null }
|
||||
?: global?.className?.ifBlank { null }
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).className
|
||||
|
||||
override val isRestrictedAccessEnabled
|
||||
get() = this@create.isRestrictedAccessEnabled
|
||||
?: global?.isRestrictedAccessEnabled
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).isRestrictedAccessEnabled
|
||||
|
||||
override val isIsolationEnabled
|
||||
get() = this@create.isIsolationEnabled
|
||||
?: global?.isIsolationEnabled
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).isIsolationEnabled
|
||||
|
||||
override val existsPropertyFiles
|
||||
get() = this@create.existsPropertyFiles
|
||||
?: global?.existsPropertyFiles
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).existsPropertyFiles
|
||||
|
||||
override val permanentKeyValues
|
||||
get() = this@create.permanentKeyValues
|
||||
?: global?.permanentKeyValues
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).permanentKeyValues
|
||||
|
||||
override val replacementKeyValues
|
||||
get() = this@create.replacementKeyValues
|
||||
?: global?.replacementKeyValues
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).replacementKeyValues
|
||||
|
||||
override val excludeKeys
|
||||
get() = this@create.excludeKeys
|
||||
?: global?.excludeKeys
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).excludeKeys
|
||||
|
||||
override val includeKeys
|
||||
get() = this@create.includeKeys
|
||||
?: global?.includeKeys
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).includeKeys
|
||||
|
||||
override val keyValuesRules
|
||||
get() = this@create.keyValuesRules
|
||||
?: global?.keyValuesRules
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).keyValuesRules
|
||||
|
||||
override val excludeNonStringValue
|
||||
get() = this@create.excludeNonStringValue
|
||||
?: selfCommon?.excludeNonStringValue
|
||||
?: global?.excludeNonStringValue
|
||||
?: globalCommon?.excludeNonStringValue
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).excludeNonStringValue
|
||||
|
||||
override val useTypeAutoConversion
|
||||
get() = this@create.useTypeAutoConversion
|
||||
?: selfCommon?.useTypeAutoConversion
|
||||
?: global?.useTypeAutoConversion
|
||||
?: globalCommon?.useTypeAutoConversion
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).useTypeAutoConversion
|
||||
|
||||
override val useValueInterpolation
|
||||
get() = this@create.useValueInterpolation
|
||||
?: selfCommon?.useValueInterpolation
|
||||
?: global?.useValueInterpolation
|
||||
?: globalCommon?.useValueInterpolation
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).useValueInterpolation
|
||||
|
||||
override val locations
|
||||
get() = this@create.locations
|
||||
?: selfCommon?.locations
|
||||
?: global?.locations
|
||||
?: globalCommon?.locations
|
||||
?: DefaultConfig.createAndroidGenerateConfig(name, selfCommon, globalCommon).locations
|
||||
}
|
||||
|
||||
private fun GropifyConfigureExtension.JvmGenerateConfigureScope.create(
|
||||
name: String,
|
||||
global: GropifyConfigureExtension.JvmGenerateConfigureScope? = null,
|
||||
selfCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null,
|
||||
globalCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null
|
||||
) = object : GropifyConfig.JvmGenerateConfig {
|
||||
|
||||
override val name get() = name
|
||||
|
||||
override val isEnabled
|
||||
get() = this@create.isEnabled
|
||||
?: selfCommon?.isEnabled
|
||||
?: global?.isEnabled
|
||||
?: globalCommon?.isEnabled
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).isEnabled
|
||||
|
||||
override val generateDirPath
|
||||
get() = this@create.generateDirPath.ifBlank { null }
|
||||
?: global?.generateDirPath?.ifBlank { null }
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).generateDirPath
|
||||
|
||||
override val sourceSetName
|
||||
get() = this@create.sourceSetName.ifBlank { null }
|
||||
?: global?.sourceSetName?.ifBlank { null }
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).sourceSetName
|
||||
|
||||
override val useKotlin
|
||||
get() = this@create.useKotlin
|
||||
?: global?.useKotlin
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).useKotlin
|
||||
|
||||
override val packageName
|
||||
get() = this@create.packageName.ifBlank { null }
|
||||
?: global?.packageName?.ifBlank { null }
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).packageName
|
||||
|
||||
override val className
|
||||
get() = this@create.className.ifBlank { null }
|
||||
?: global?.className?.ifBlank { null }
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).className
|
||||
|
||||
override val isRestrictedAccessEnabled
|
||||
get() = this@create.isRestrictedAccessEnabled
|
||||
?: global?.isRestrictedAccessEnabled
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).isRestrictedAccessEnabled
|
||||
|
||||
override val isIsolationEnabled
|
||||
get() = this@create.isIsolationEnabled
|
||||
?: global?.isIsolationEnabled
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).isIsolationEnabled
|
||||
|
||||
override val existsPropertyFiles
|
||||
get() = this@create.existsPropertyFiles
|
||||
?: global?.existsPropertyFiles
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).existsPropertyFiles
|
||||
|
||||
override val permanentKeyValues
|
||||
get() = this@create.permanentKeyValues
|
||||
?: global?.permanentKeyValues
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).permanentKeyValues
|
||||
|
||||
override val replacementKeyValues
|
||||
get() = this@create.replacementKeyValues
|
||||
?: global?.replacementKeyValues
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).replacementKeyValues
|
||||
|
||||
override val excludeKeys
|
||||
get() = this@create.excludeKeys
|
||||
?: global?.excludeKeys
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).excludeKeys
|
||||
|
||||
override val includeKeys
|
||||
get() = this@create.includeKeys
|
||||
?: global?.includeKeys
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).includeKeys
|
||||
|
||||
override val keyValuesRules
|
||||
get() = this@create.keyValuesRules
|
||||
?: global?.keyValuesRules
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).keyValuesRules
|
||||
|
||||
override val excludeNonStringValue
|
||||
get() = this@create.excludeNonStringValue
|
||||
?: selfCommon?.excludeNonStringValue
|
||||
?: global?.excludeNonStringValue
|
||||
?: globalCommon?.excludeNonStringValue
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).excludeNonStringValue
|
||||
|
||||
override val useTypeAutoConversion
|
||||
get() = this@create.useTypeAutoConversion
|
||||
?: selfCommon?.useTypeAutoConversion
|
||||
?: global?.useTypeAutoConversion
|
||||
?: globalCommon?.useTypeAutoConversion
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).useTypeAutoConversion
|
||||
|
||||
override val useValueInterpolation
|
||||
get() = this@create.useValueInterpolation
|
||||
?: selfCommon?.useValueInterpolation
|
||||
?: global?.useValueInterpolation
|
||||
?: globalCommon?.useValueInterpolation
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).useValueInterpolation
|
||||
|
||||
override val locations
|
||||
get() = this@create.locations
|
||||
?: selfCommon?.locations
|
||||
?: global?.locations
|
||||
?: globalCommon?.locations
|
||||
?: DefaultConfig.createJvmGenerateConfig(name, selfCommon, globalCommon).locations
|
||||
}
|
||||
|
||||
private fun GropifyConfigureExtension.KmpGenerateConfigureScope.create(
|
||||
name: String,
|
||||
global: GropifyConfigureExtension.KmpGenerateConfigureScope? = null,
|
||||
selfCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null,
|
||||
globalCommon: GropifyConfigureExtension.CommonGenerateConfigureScope? = null
|
||||
) = object : GropifyConfig.KmpGenerateConfig {
|
||||
|
||||
override val name get() = name
|
||||
|
||||
override val isEnabled
|
||||
get() = this@create.isEnabled
|
||||
?: selfCommon?.isEnabled
|
||||
?: global?.isEnabled
|
||||
?: globalCommon?.isEnabled
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).isEnabled
|
||||
|
||||
override val generateDirPath
|
||||
get() = this@create.generateDirPath.ifBlank { null }
|
||||
?: global?.generateDirPath?.ifBlank { null }
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).generateDirPath
|
||||
|
||||
override val sourceSetName
|
||||
get() = this@create.sourceSetName.ifBlank { null }
|
||||
?: global?.sourceSetName?.ifBlank { null }
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).sourceSetName
|
||||
|
||||
override val packageName
|
||||
get() = this@create.packageName.ifBlank { null }
|
||||
?: global?.packageName?.ifBlank { null }
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).packageName
|
||||
|
||||
override val className
|
||||
get() = this@create.className.ifBlank { null }
|
||||
?: global?.className?.ifBlank { null }
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).className
|
||||
|
||||
override val isRestrictedAccessEnabled
|
||||
get() = this@create.isRestrictedAccessEnabled
|
||||
?: global?.isRestrictedAccessEnabled
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).isRestrictedAccessEnabled
|
||||
|
||||
override val isIsolationEnabled
|
||||
get() = this@create.isIsolationEnabled
|
||||
?: global?.isIsolationEnabled
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).isIsolationEnabled
|
||||
|
||||
override val existsPropertyFiles
|
||||
get() = this@create.existsPropertyFiles
|
||||
?: global?.existsPropertyFiles
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).existsPropertyFiles
|
||||
|
||||
override val permanentKeyValues
|
||||
get() = this@create.permanentKeyValues
|
||||
?: global?.permanentKeyValues
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).permanentKeyValues
|
||||
|
||||
override val replacementKeyValues
|
||||
get() = this@create.replacementKeyValues
|
||||
?: global?.replacementKeyValues
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).replacementKeyValues
|
||||
|
||||
override val excludeKeys
|
||||
get() = this@create.excludeKeys
|
||||
?: global?.excludeKeys
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).excludeKeys
|
||||
|
||||
override val includeKeys
|
||||
get() = this@create.includeKeys
|
||||
?: global?.includeKeys
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).includeKeys
|
||||
|
||||
override val keyValuesRules
|
||||
get() = this@create.keyValuesRules
|
||||
?: global?.keyValuesRules
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).keyValuesRules
|
||||
|
||||
override val excludeNonStringValue
|
||||
get() = this@create.excludeNonStringValue
|
||||
?: selfCommon?.excludeNonStringValue
|
||||
?: global?.excludeNonStringValue
|
||||
?: globalCommon?.excludeNonStringValue
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).excludeNonStringValue
|
||||
|
||||
override val useTypeAutoConversion
|
||||
get() = this@create.useTypeAutoConversion
|
||||
?: selfCommon?.useTypeAutoConversion
|
||||
?: global?.useTypeAutoConversion
|
||||
?: globalCommon?.useTypeAutoConversion
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).useTypeAutoConversion
|
||||
|
||||
override val useValueInterpolation
|
||||
get() = this@create.useValueInterpolation
|
||||
?: selfCommon?.useValueInterpolation
|
||||
?: global?.useValueInterpolation
|
||||
?: globalCommon?.useValueInterpolation
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).useValueInterpolation
|
||||
|
||||
override val locations
|
||||
get() = this@create.locations
|
||||
?: selfCommon?.locations
|
||||
?: global?.locations
|
||||
?: globalCommon?.locations
|
||||
?: DefaultConfig.createKmpGenerateConfig(name, selfCommon, globalCommon).locations
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.config.proxy
|
||||
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import com.highcapable.gropify.plugin.config.type.GropifyLocation
|
||||
import com.highcapable.gropify.plugin.generator.extension.PropertyValueRule
|
||||
|
||||
/**
|
||||
* Configuration interface for Gropify.
|
||||
*/
|
||||
internal interface GropifyConfig {
|
||||
|
||||
companion object {
|
||||
|
||||
internal const val ARTIFACTS_NAME = "artifacts"
|
||||
internal const val ACCESSORS_NAME = "gropify-accessors"
|
||||
|
||||
internal const val DEFAULT_PACKAGE_NAME = "${Gropify.GROUP_NAME}.properties.default"
|
||||
|
||||
internal const val DEFAULT_COMMON_CODE_GENERATE_DIR_PATH = "build/generated/gropify"
|
||||
internal const val DEFAULT_ANDROID_JVM_SOURCE_SET_NAME = "main"
|
||||
internal const val DEFAULT_KMP_COMMON_SOURCE_SET_NAME = "commonMain"
|
||||
|
||||
internal const val DEFAULT_EXISTS_PROPERTY_FILE = "gradle.properties"
|
||||
internal const val DEFAULT_EXTENSION_NAME = "gropify"
|
||||
|
||||
internal val defaultLocations = listOf(GropifyLocation.CurrentProject, GropifyLocation.RootProject)
|
||||
}
|
||||
|
||||
/** Whether to enable this plugin. */
|
||||
val isEnabled: Boolean
|
||||
|
||||
/** Whether to enable debug mode. */
|
||||
val debugMode: Boolean
|
||||
|
||||
/** Configure global. */
|
||||
val global: GenerateConfig
|
||||
|
||||
/** Configure projects. */
|
||||
val projects: MutableMap<String, GenerateConfig>
|
||||
|
||||
/**
|
||||
* Generate configuration interface.
|
||||
*/
|
||||
interface GenerateConfig {
|
||||
|
||||
val buildscript: BuildscriptGenerateConfig
|
||||
|
||||
val android: AndroidGenerateConfig
|
||||
|
||||
val jvm: JvmGenerateConfig
|
||||
|
||||
val kmp: KmpGenerateConfig
|
||||
}
|
||||
|
||||
/**
|
||||
* Buildscript generation code configuration interface.
|
||||
*/
|
||||
interface BuildscriptGenerateConfig : CommonGenerateConfig {
|
||||
|
||||
/** Custom buildscript extension name. */
|
||||
val extensionName: String
|
||||
}
|
||||
|
||||
/**
|
||||
* Android project generate configuration interface.
|
||||
*/
|
||||
interface AndroidGenerateConfig : JvmGenerateConfig
|
||||
|
||||
/**
|
||||
* Jvm project generate configuration interface.
|
||||
*/
|
||||
interface JvmGenerateConfig : CommonCodeGenerateConfig {
|
||||
|
||||
/** Whether to use Kotlin language generation. */
|
||||
val useKotlin: Boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Kotlin Multiplatform project generate configuration interface.
|
||||
*/
|
||||
interface KmpGenerateConfig : CommonCodeGenerateConfig
|
||||
|
||||
/**
|
||||
* Project common code generate configuration interface.
|
||||
*/
|
||||
interface CommonCodeGenerateConfig : SourceCodeGenerateConfig {
|
||||
|
||||
/** Custom deployment `sourceSet` name. */
|
||||
val sourceSetName: String
|
||||
|
||||
/** Custom generated package name. */
|
||||
val packageName: String
|
||||
|
||||
/** Custom generated class name. */
|
||||
val className: String
|
||||
|
||||
/** Whether to enable restricted access. */
|
||||
val isRestrictedAccessEnabled: Boolean
|
||||
|
||||
/** Whether to enable code isolation. */
|
||||
val isIsolationEnabled: Boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Project code generate configuration interface.
|
||||
*/
|
||||
interface SourceCodeGenerateConfig : CommonGenerateConfig {
|
||||
|
||||
/** Custom generated directory path. */
|
||||
val generateDirPath: String
|
||||
}
|
||||
|
||||
/**
|
||||
* Common generate configuration interface.
|
||||
*/
|
||||
interface CommonGenerateConfig {
|
||||
|
||||
/** The config name (project name). */
|
||||
val name: String
|
||||
|
||||
/** Whether to generate code. */
|
||||
val isEnabled: Boolean
|
||||
|
||||
/** Exists property files. */
|
||||
val existsPropertyFiles: MutableList<String>
|
||||
|
||||
/** Permanent list of properties' key-values. */
|
||||
val permanentKeyValues: MutableMap<String, Any>
|
||||
|
||||
/** Replacement list of properties' key-values. */
|
||||
val replacementKeyValues: MutableMap<String, Any>
|
||||
|
||||
/** Key list of properties' key-values name that need to be excluded. */
|
||||
val excludeKeys: MutableList<Any>
|
||||
|
||||
/** Key list of properties' key-values name that need to be included. */
|
||||
val includeKeys: MutableList<Any>
|
||||
|
||||
/** Properties' key-values rules. */
|
||||
val keyValuesRules: MutableMap<String, PropertyValueRule>
|
||||
|
||||
/** Whether to exclude the non-string type key-values content. */
|
||||
val excludeNonStringValue: Boolean
|
||||
|
||||
/** Whether to use automatic type conversion. */
|
||||
val useTypeAutoConversion: Boolean
|
||||
|
||||
/** Whether to use key-values content interpolation. */
|
||||
val useValueInterpolation: Boolean
|
||||
|
||||
/** Locations. */
|
||||
val locations: List<GropifyLocation>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.gropify.plugin.config.type
|
||||
|
||||
/**
|
||||
* Properties' key-values location.
|
||||
*/
|
||||
enum class GropifyLocation {
|
||||
/** The current project. */
|
||||
CurrentProject,
|
||||
|
||||
/** The root project. */
|
||||
RootProject,
|
||||
|
||||
/** The Gradle home directory. */
|
||||
Global,
|
||||
|
||||
/** The system properties. */
|
||||
System,
|
||||
|
||||
/** The system environment variables. */
|
||||
SystemEnv
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/17.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.deployer
|
||||
|
||||
import com.highcapable.gropify.gradle.api.entity.Dependency
|
||||
import com.highcapable.gropify.gradle.api.entity.ProjectDescriptor
|
||||
import com.highcapable.gropify.gradle.api.extension.addDependencyToBuildscript
|
||||
import com.highcapable.gropify.gradle.api.extension.getOrCreate
|
||||
import com.highcapable.gropify.gradle.api.extension.toClassOrNull
|
||||
import com.highcapable.gropify.plugin.DefaultDeployer
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import com.highcapable.gropify.plugin.compiler.extension.compile
|
||||
import com.highcapable.gropify.plugin.config.extension.from
|
||||
import com.highcapable.gropify.plugin.config.proxy.GropifyConfig
|
||||
import com.highcapable.gropify.plugin.deployer.proxy.Deployer
|
||||
import com.highcapable.gropify.plugin.extension.dsl.configure.GropifyConfigureExtension
|
||||
import com.highcapable.gropify.plugin.generator.BuildscriptGenerator
|
||||
import com.highcapable.gropify.plugin.generator.extension.PropertyMap
|
||||
import com.highcapable.gropify.utils.extension.camelcase
|
||||
import com.highcapable.gropify.utils.extension.isEmpty
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.initialization.Settings
|
||||
import java.io.File
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/**
|
||||
* Buildscript deployer.
|
||||
*/
|
||||
internal class BuildscriptDeployer(private val _config: () -> GropifyConfig) : Deployer {
|
||||
|
||||
private val config get() = _config()
|
||||
|
||||
private val buildscriptGenerator = BuildscriptGenerator()
|
||||
|
||||
private var buildscriptAccessorsDir by Delegates.notNull<File>()
|
||||
private val buildscriptAccessorsDependency = Dependency(Gropify.GROUP_NAME, GropifyConfig.ACCESSORS_NAME, Gropify.VERSION)
|
||||
|
||||
private var cachedSettingsProperties = mutableListOf<PropertyMap>()
|
||||
|
||||
override fun init(settings: Settings, configModified: Boolean) {
|
||||
buildscriptAccessorsDir = generatedBuildscriptAccessorsDir(settings)
|
||||
|
||||
val allConfig = mutableListOf<GropifyConfig.BuildscriptGenerateConfig>()
|
||||
val allProperties = mutableListOf<PropertyMap>()
|
||||
|
||||
if (config.global.buildscript.isEnabled) {
|
||||
val map = DefaultDeployer.generateMap(config.global.buildscript, ProjectDescriptor.create(settings))
|
||||
allProperties.add(map)
|
||||
allConfig.add(config.global.buildscript)
|
||||
}
|
||||
|
||||
config.projects.forEach { (name, subConfig) ->
|
||||
if (!subConfig.buildscript.isEnabled) return@forEach
|
||||
|
||||
val map = DefaultDeployer.generateMap(subConfig.buildscript, ProjectDescriptor.create(settings, name))
|
||||
allProperties.add(map)
|
||||
allConfig.add(subConfig.buildscript)
|
||||
}
|
||||
|
||||
if (!configModified &&
|
||||
allProperties == cachedSettingsProperties &&
|
||||
!buildscriptAccessorsDir.resolve(buildscriptAccessorsDependency.relativePath).isEmpty()
|
||||
) return
|
||||
|
||||
cachedSettingsProperties = allProperties
|
||||
buildscriptGenerator.build(allConfig, allProperties).compile(
|
||||
buildscriptAccessorsDependency,
|
||||
buildscriptAccessorsDir.absolutePath,
|
||||
buildscriptGenerator.compileStubFiles
|
||||
)
|
||||
}
|
||||
|
||||
override fun resolve(rootProject: Project, configModified: Boolean) {
|
||||
if (!buildscriptAccessorsDir.resolve(buildscriptAccessorsDependency.relativePath).isEmpty())
|
||||
rootProject.addDependencyToBuildscript(buildscriptAccessorsDir.absolutePath, buildscriptAccessorsDependency)
|
||||
}
|
||||
|
||||
override fun deploy(rootProject: Project, configModified: Boolean) {
|
||||
fun Project.deploy() {
|
||||
val config = config.from(this).buildscript
|
||||
if (!config.isEnabled) return
|
||||
|
||||
val className = buildscriptGenerator.propertiesClass(config.name)
|
||||
val accessorsClass = className.toClassOrNull(this) ?: throw RuntimeException(
|
||||
"""
|
||||
Generated class "$className" not found, stop loading $this.
|
||||
Please check whether the initialization process is interrupted and re-run Gradle sync.
|
||||
If this doesn't work, please manually delete the entire "${buildscriptAccessorsDir.absolutePath}" directory.
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
getOrCreate(config.extensionName.camelcase(), accessorsClass)
|
||||
}
|
||||
|
||||
rootProject.deploy()
|
||||
rootProject.subprojects.forEach { it.deploy() }
|
||||
}
|
||||
|
||||
private fun generatedBuildscriptAccessorsDir(settings: Settings) =
|
||||
settings.rootDir.resolve(".gradle")
|
||||
.resolve(GropifyConfigureExtension.NAME)
|
||||
.resolve(GropifyConfig.ARTIFACTS_NAME)
|
||||
.apply { mkdirs() }
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/17.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.deployer
|
||||
|
||||
import com.highcapable.gropify.gradle.api.entity.ProjectDescriptor
|
||||
import com.highcapable.gropify.gradle.api.extension.getFullName
|
||||
import com.highcapable.gropify.gradle.api.extension.getOrNull
|
||||
import com.highcapable.gropify.internal.Logger
|
||||
import com.highcapable.gropify.internal.error
|
||||
import com.highcapable.gropify.plugin.DefaultDeployer.generateMap
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import com.highcapable.gropify.plugin.config.extension.from
|
||||
import com.highcapable.gropify.plugin.config.proxy.GropifyConfig
|
||||
import com.highcapable.gropify.plugin.deployer.extension.ExtensionName
|
||||
import com.highcapable.gropify.plugin.deployer.extension.ProjectType
|
||||
import com.highcapable.gropify.plugin.deployer.extension.resolveType
|
||||
import com.highcapable.gropify.plugin.deployer.proxy.Deployer
|
||||
import com.highcapable.gropify.plugin.generator.SourceCodeGenerator
|
||||
import com.highcapable.gropify.plugin.generator.config.GenerateConfig
|
||||
import com.highcapable.gropify.plugin.generator.config.SourceCodeSpec
|
||||
import com.highcapable.gropify.plugin.generator.extension.PropertyMap
|
||||
import com.highcapable.gropify.plugin.helper.AndroidProjectHelper
|
||||
import com.highcapable.gropify.utils.extension.flatted
|
||||
import com.highcapable.gropify.utils.extension.isEmpty
|
||||
import com.highcapable.gropify.utils.extension.upperCamelcase
|
||||
import com.highcapable.kavaref.KavaRef.Companion.asResolver
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.initialization.Settings
|
||||
import java.io.File
|
||||
import kotlin.collections.set
|
||||
|
||||
/**
|
||||
* Source code deployer.
|
||||
*/
|
||||
internal class SourceCodeDeployer(private val _config: () -> GropifyConfig) : Deployer {
|
||||
|
||||
private val config get() = _config()
|
||||
|
||||
private val debugMode get() = config.debugMode
|
||||
|
||||
private val sourceCodeGenerator = SourceCodeGenerator()
|
||||
|
||||
private var cachedProjectProperties = mutableMapOf<String, PropertyMap>()
|
||||
|
||||
override fun init(settings: Settings, configModified: Boolean) {
|
||||
// No initialization required.
|
||||
}
|
||||
|
||||
override fun resolve(rootProject: Project, configModified: Boolean) {
|
||||
// No resolution required.
|
||||
}
|
||||
|
||||
override fun deploy(rootProject: Project, configModified: Boolean) {
|
||||
fun Project.generate() {
|
||||
val projectType = resolveType()
|
||||
|
||||
val config = config.from(this).let {
|
||||
when (projectType) {
|
||||
ProjectType.Android -> it.android
|
||||
ProjectType.Kotlin, ProjectType.Java -> it.jvm
|
||||
ProjectType.KMP -> it.kmp
|
||||
else -> null
|
||||
} ?: return
|
||||
}
|
||||
|
||||
val sourceCodeType = decideSourceCodeType(config, projectType)
|
||||
val generateDirPath = resolveGenerateDirPath(config)
|
||||
|
||||
if (!config.isEnabled) return
|
||||
|
||||
val outputDir = file(generateDirPath)
|
||||
val properties = generateMap(config, ProjectDescriptor.create(project = this))
|
||||
|
||||
if (!configModified && properties == cachedProjectProperties[getFullName()] && !outputDir.isEmpty()) {
|
||||
if (config.isEnabled) configureSourceSets(project = this)
|
||||
return
|
||||
}
|
||||
|
||||
outputDir.apply { if (exists()) deleteRecursively() }
|
||||
|
||||
// The directory will be re-created every time.
|
||||
outputDir.mkdirs()
|
||||
|
||||
cachedProjectProperties[getFullName()] = properties
|
||||
|
||||
val packageName = generatedPackageName(config)
|
||||
val className = generatedClassName(config)
|
||||
|
||||
val generateConfig = GenerateConfig(packageName, className)
|
||||
|
||||
sourceCodeGenerator.build(config, generateConfig, properties).let { generator ->
|
||||
generator.first { it.type == sourceCodeType }
|
||||
}.writeTo(outputDir)
|
||||
configureSourceSets(project = this)
|
||||
}
|
||||
|
||||
rootProject.generate()
|
||||
rootProject.subprojects.forEach {
|
||||
it.afterEvaluate {
|
||||
generate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun configureSourceSets(project: Project) {
|
||||
val projectType = project.resolveType()
|
||||
|
||||
val config = config.from(project).let {
|
||||
when (projectType) {
|
||||
ProjectType.Android -> it.android
|
||||
ProjectType.Kotlin, ProjectType.Java -> it.jvm
|
||||
ProjectType.KMP -> it.kmp
|
||||
else -> null
|
||||
} ?: return
|
||||
}
|
||||
|
||||
val sourceCodeType = decideSourceCodeType(config, projectType)
|
||||
val resolveSourceCodeType = if (projectType == ProjectType.Java) SourceCodeSpec.Type.Java else sourceCodeType
|
||||
val generateDirPath = resolveGenerateDirPath(config)
|
||||
|
||||
val androidExtension = project.getOrNull(ExtensionName.ANDROID)
|
||||
val kotlinExtension = project.getOrNull(ExtensionName.KOTLIN)
|
||||
val javaExtension = project.getOrNull(ExtensionName.JAVA)
|
||||
|
||||
val extension = when (projectType) {
|
||||
ProjectType.Android -> androidExtension
|
||||
ProjectType.Kotlin -> if (sourceCodeType == SourceCodeSpec.Type.Kotlin) kotlinExtension else javaExtension
|
||||
ProjectType.Java -> javaExtension
|
||||
ProjectType.KMP -> kotlinExtension
|
||||
else -> return
|
||||
} ?: return
|
||||
|
||||
val collection = extension.asResolver().optional(!debugMode).firstMethodOrNull {
|
||||
name = "getSourceSets"
|
||||
}?.invokeQuietly<Iterable<*>>()
|
||||
|
||||
val sourceSet = collection?.firstOrNull {
|
||||
it?.asResolver()?.optional(!debugMode)?.firstMethodOrNull {
|
||||
name = "getName"
|
||||
}?.invokeQuietly<String>() == config.sourceSetName
|
||||
} ?: return Logger.warn(
|
||||
"Could not found source sets \"${config.sourceSetName}\" in project '${project.getFullName()}' ($projectType)."
|
||||
)
|
||||
|
||||
val directorySet = sourceSet.asResolver().optional(!debugMode).firstMethodOrNull {
|
||||
name = when (resolveSourceCodeType) {
|
||||
SourceCodeSpec.Type.Java -> "getJava"
|
||||
SourceCodeSpec.Type.Kotlin -> "getKotlin"
|
||||
}
|
||||
superclass()
|
||||
}?.invokeQuietly()
|
||||
val srcDirs = directorySet?.asResolver()?.optional(!debugMode)?.firstMethodOrNull {
|
||||
name = "getSrcDirs"
|
||||
}?.invokeQuietly<Set<*>>()
|
||||
|
||||
val alreadyAdded = srcDirs?.any { it is File && it.canonicalPath.endsWith(generateDirPath) } == true
|
||||
if (!alreadyAdded) {
|
||||
val resolver = directorySet?.asResolver()?.optional(!debugMode)?.firstMethodOrNull {
|
||||
name = "srcDir"
|
||||
parameters(Any::class)
|
||||
superclass()
|
||||
}
|
||||
resolver?.invokeQuietly(generateDirPath) ?: Logger.error(
|
||||
"Project '${project.getFullName()}' source sets deployed failed, method \"srcDir\" maybe failed during the processing."
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun decideSourceCodeType(config: GropifyConfig.CommonCodeGenerateConfig, type: ProjectType) = when (type) {
|
||||
ProjectType.Android, ProjectType.Kotlin ->
|
||||
if (config is GropifyConfig.JvmGenerateConfig && !config.useKotlin)
|
||||
SourceCodeSpec.Type.Java
|
||||
else SourceCodeSpec.Type.Kotlin
|
||||
ProjectType.Java -> SourceCodeSpec.Type.Java
|
||||
ProjectType.KMP -> SourceCodeSpec.Type.Kotlin
|
||||
else -> Gropify.error("Unsupported project type for source code generation.")
|
||||
}
|
||||
|
||||
private fun resolveGenerateDirPath(config: GropifyConfig.CommonCodeGenerateConfig) = "${config.generateDirPath}/src/main"
|
||||
|
||||
private fun Project.generatedPackageName(config: GropifyConfig.CommonCodeGenerateConfig): String {
|
||||
val packageName = config.packageName.ifBlank { null }
|
||||
?: AndroidProjectHelper.getNamespace(this)
|
||||
?: group.toString().ifBlank { null }
|
||||
?: "${GropifyConfig.DEFAULT_PACKAGE_NAME}.${getFullName(useColon = false).replace(":", "").flatted()}"
|
||||
|
||||
return if (config.isIsolationEnabled) "$packageName.generated" else packageName
|
||||
}
|
||||
|
||||
private fun Project.generatedClassName(config: GropifyConfig.CommonCodeGenerateConfig): String {
|
||||
val className = config.className.ifBlank { null }
|
||||
?: getFullName(useColon = false).replace(":", "_").upperCamelcase().ifBlank { null }
|
||||
?: "Undefined"
|
||||
|
||||
return "${className.upperCamelcase()}Properties"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/17.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.deployer.extension
|
||||
|
||||
import com.highcapable.gropify.gradle.api.extension.get
|
||||
import com.highcapable.gropify.gradle.api.extension.hasExtension
|
||||
import com.highcapable.gropify.gradle.api.extension.toClassOrNull
|
||||
import com.highcapable.kavaref.extension.isSubclassOf
|
||||
import org.gradle.api.Project
|
||||
|
||||
/**
|
||||
* Resolve current project type.
|
||||
* @receiver [Project]
|
||||
* @return [ProjectType]
|
||||
*/
|
||||
internal fun Project.resolveType() = when {
|
||||
hasKmpPlugin() -> ProjectType.KMP
|
||||
hasExtension(ExtensionName.ANDROID) -> ProjectType.Android
|
||||
hasExtension(ExtensionName.KOTLIN) -> ProjectType.Kotlin
|
||||
hasExtension(ExtensionName.JAVA) -> ProjectType.Java
|
||||
else -> ProjectType.Unknown
|
||||
}
|
||||
|
||||
/**
|
||||
* Project extension names.
|
||||
*/
|
||||
internal object ExtensionName {
|
||||
|
||||
const val ANDROID = "android"
|
||||
const val JAVA = "java"
|
||||
const val KOTLIN = "kotlin"
|
||||
|
||||
const val KMP_EXTENSION_CLASS = "org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension"
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current project has Kotlin Multiplatform plugin applied.
|
||||
* @receiver [Project]
|
||||
* @return [Boolean]
|
||||
*/
|
||||
internal fun Project.hasKmpPlugin(): Boolean {
|
||||
// The extension names of Kotlin and KMP are the same.
|
||||
val hasKotlin = hasExtension(ExtensionName.KOTLIN)
|
||||
// The KMP extensions must inherit from [KMP_EXTENSION_CLASS].
|
||||
val kmpClass = ExtensionName.KMP_EXTENSION_CLASS.toClassOrNull(this)
|
||||
val hasKmpExtension = if (hasKotlin && kmpClass != null)
|
||||
get(ExtensionName.KOTLIN).javaClass isSubclassOf kmpClass
|
||||
else false
|
||||
|
||||
return hasKmpExtension
|
||||
}
|
||||
|
||||
internal enum class ProjectType {
|
||||
Android,
|
||||
Kotlin,
|
||||
Java,
|
||||
KMP, // Kotlin Multiplatform
|
||||
Unknown
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/17.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.deployer.proxy
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.initialization.Settings
|
||||
|
||||
/**
|
||||
* Deployer interface for Gropify.
|
||||
*/
|
||||
internal interface Deployer {
|
||||
|
||||
/**
|
||||
* Initialize with settings.
|
||||
*/
|
||||
fun init(settings: Settings, configModified: Boolean)
|
||||
|
||||
/**
|
||||
* Resolve for root project.
|
||||
*/
|
||||
fun resolve(rootProject: Project, configModified: Boolean)
|
||||
|
||||
/**
|
||||
* Deploy to root project.
|
||||
*/
|
||||
fun deploy(rootProject: Project, configModified: Boolean)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/11.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.extension.accessors.proxy
|
||||
|
||||
/**
|
||||
* Extension accessible [Class] defines spatial interface.
|
||||
*/
|
||||
internal interface ExtensionAccessors
|
||||
@@ -0,0 +1,590 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "PropertyName", "DeprecatedCallableAddReplaceWith", "FunctionName")
|
||||
|
||||
package com.highcapable.gropify.plugin.extension.dsl.configure
|
||||
|
||||
import com.highcapable.gropify.gradle.api.extension.isUnSafeExtName
|
||||
import com.highcapable.gropify.internal.error
|
||||
import com.highcapable.gropify.internal.require
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import com.highcapable.gropify.plugin.config.extension.create
|
||||
import com.highcapable.gropify.plugin.config.proxy.GropifyConfig
|
||||
import com.highcapable.gropify.plugin.config.type.GropifyLocation
|
||||
import com.highcapable.gropify.plugin.generator.extension.PropertyValueRule
|
||||
import com.highcapable.gropify.utils.KeywordsDetector
|
||||
import com.highcapable.gropify.utils.extension.isStartsWithLetter
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.initialization.Settings
|
||||
|
||||
/**
|
||||
* Configure extension for Gropify.
|
||||
*/
|
||||
open class GropifyConfigureExtension internal constructor() {
|
||||
|
||||
companion object {
|
||||
|
||||
/** Extension name. */
|
||||
const val NAME = "gropify"
|
||||
|
||||
private const val ROOT_PROJECT_TAG = "<ROOT_PROJECT>"
|
||||
}
|
||||
|
||||
private val globalConfigure = GenerateConfigureScope()
|
||||
private val projectConfigures = mutableMapOf<String, GenerateConfigureScope>()
|
||||
|
||||
/**
|
||||
* Whether to enable this plugin.
|
||||
*
|
||||
* If you want to disable this plugin, just set it here.
|
||||
*/
|
||||
var isEnabled = true
|
||||
@JvmName("enabled") set
|
||||
|
||||
/**
|
||||
* Whether to enable debug mode.
|
||||
*
|
||||
* You can help us identify the problem by enabling this option
|
||||
* to print more debugging information in the logs.
|
||||
*/
|
||||
var debugMode = false
|
||||
@JvmName("debugMode") set
|
||||
|
||||
/**
|
||||
* Configure global.
|
||||
*/
|
||||
fun global(action: Action<GenerateConfigureScope>) = action.execute(globalConfigure)
|
||||
|
||||
/**
|
||||
* Configure root project.
|
||||
*/
|
||||
fun rootProject(action: Action<GenerateConfigureScope>) = configureProject(ROOT_PROJECT_TAG, action)
|
||||
|
||||
/**
|
||||
* Configure each project.
|
||||
* @param names the project names.
|
||||
*/
|
||||
fun projects(vararg names: String, action: Action<GenerateConfigureScope>) = names.forEach { configureProject(it, action) }
|
||||
|
||||
private fun configureProject(name: String, action: Action<GenerateConfigureScope>) =
|
||||
action.execute(GenerateConfigureScope().also { projectConfigures[name] = it })
|
||||
|
||||
open inner class GenerateConfigureScope internal constructor(
|
||||
internal var commonConfigure: CommonGenerateConfigureScope? = null,
|
||||
internal var buildscriptConfigure: BuildscriptGenerateConfigureScope? = null,
|
||||
internal var androidConfigure: AndroidGenerateConfigureScope? = null,
|
||||
internal var jvmConfigure: JvmGenerateConfigureScope? = null,
|
||||
internal var kmpConfigure: KmpGenerateConfigureScope? = null
|
||||
) {
|
||||
|
||||
/**
|
||||
* Please use [common], [buildscript], [android], [jvm], [kmp] to configure it.
|
||||
* @throws IllegalStateException
|
||||
*/
|
||||
@Suppress("unused")
|
||||
@Deprecated(
|
||||
message = "Please use `common`, `buildscript`, `android`, `jvm`, `kmp` to configure it.",
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
val isEnabled: Boolean get() = Gropify.error("No getter available.")
|
||||
|
||||
/**
|
||||
* Configure common.
|
||||
*
|
||||
* The configuration here will be applied downward to [buildscript], [android], [jvm], [kmp].
|
||||
*/
|
||||
fun common(action: Action<CommonGenerateConfigureScope>) {
|
||||
commonConfigure = CommonGenerateConfigureScope().also { action.execute(it) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure buildscript.
|
||||
*/
|
||||
fun buildscript(action: Action<BuildscriptGenerateConfigureScope>) {
|
||||
buildscriptConfigure = BuildscriptGenerateConfigureScope().also { action.execute(it) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure if this is an Android project.
|
||||
*/
|
||||
fun android(action: Action<AndroidGenerateConfigureScope>) {
|
||||
androidConfigure = AndroidGenerateConfigureScope().also { action.execute(it) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure if this is a Java or Kotlin project.
|
||||
*/
|
||||
fun jvm(action: Action<JvmGenerateConfigureScope>) {
|
||||
jvmConfigure = JvmGenerateConfigureScope().also { action.execute(it) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure if this is a Kotlin Multiplatform project.
|
||||
*/
|
||||
fun kmp(action: Action<KmpGenerateConfigureScope>) {
|
||||
kmpConfigure = KmpGenerateConfigureScope().also { action.execute(it) }
|
||||
}
|
||||
}
|
||||
|
||||
open inner class BuildscriptGenerateConfigureScope internal constructor() : CommonGenerateConfigureScope() {
|
||||
|
||||
/**
|
||||
* Custom buildscript extension name.
|
||||
*
|
||||
* Default is "gropify".
|
||||
*/
|
||||
var extensionName = ""
|
||||
@JvmName("extensionName") set
|
||||
}
|
||||
|
||||
open inner class AndroidGenerateConfigureScope internal constructor() : JvmGenerateConfigureScope()
|
||||
|
||||
open inner class JvmGenerateConfigureScope internal constructor() : CommonCodeGenerateConfigureScope() {
|
||||
|
||||
/**
|
||||
* Whether to use Kotlin language generation.
|
||||
*
|
||||
* Enabled by default, when enabled will generate Kotlin code, disabled will generate Java code.
|
||||
*
|
||||
* - Note: This option will be disabled when this project is a pure Java project.
|
||||
*/
|
||||
var useKotlin: Boolean? = null
|
||||
@JvmName("useKotlin") set
|
||||
}
|
||||
|
||||
open inner class KmpGenerateConfigureScope internal constructor() : CommonCodeGenerateConfigureScope()
|
||||
|
||||
abstract inner class CommonCodeGenerateConfigureScope internal constructor() : SourceCodeGenerateConfigureExtension() {
|
||||
|
||||
/**
|
||||
* Custom deployment `sourceSet` name.
|
||||
*
|
||||
* If your project source code deployment name is not default, you can customize it here.
|
||||
*
|
||||
* Default is "main", if this project is a Kotlin Multiplatform project, the default is "commonMain".
|
||||
*/
|
||||
var sourceSetName = ""
|
||||
@JvmName("sourceSetName") set
|
||||
|
||||
/**
|
||||
* Custom generated package name.
|
||||
*
|
||||
* Android projects use the `namespace` in the `android` configuration method block by default.
|
||||
*
|
||||
* Java, Kotlin or Kotlin Multiplatform projects use the `project.group` of the project settings by default.
|
||||
*
|
||||
* In a Kotlin Multiplatform project, if the AGP plugin is also applied,
|
||||
* the `namespace` will still be used as the package name by default.
|
||||
*
|
||||
* The "generated" is a fixed suffix that avoids conflicts with your own namespaces,
|
||||
* if you don't want this suffix, you can refer to [isIsolationEnabled].
|
||||
*/
|
||||
var packageName = ""
|
||||
@JvmName("packageName") set
|
||||
|
||||
/**
|
||||
* Custom generated class name.
|
||||
*
|
||||
* Default is use the name of the current project.
|
||||
*
|
||||
* The "Properties" is a fixed suffix to distinguish it from your own class names.
|
||||
*/
|
||||
var className = ""
|
||||
@JvmName("className") set
|
||||
|
||||
/**
|
||||
* Whether to enable restricted access.
|
||||
*
|
||||
* Disabled by default, when enabled will add the `internal` modifier to generated Kotlin classes or
|
||||
* remove the `public` modifier to generated Java classes.
|
||||
*/
|
||||
var isRestrictedAccessEnabled: Boolean? = null
|
||||
@JvmName("restrictedAccessEnabled") set
|
||||
|
||||
/**
|
||||
* Whether to enable code isolation.
|
||||
*
|
||||
* Enabled by default, when enabled will generate code in an isolated package suffix "generated"
|
||||
* to avoid conflicts with other projects that also use or not only Gropify to generate code.
|
||||
*
|
||||
* - Note: If you disable this option, please make sure that there are no other projects
|
||||
* that also use or not only Gropify to generate code to avoid conflicts.
|
||||
*/
|
||||
var isIsolationEnabled: Boolean? = null
|
||||
@JvmName("isolationEnabled") set
|
||||
}
|
||||
|
||||
abstract inner class SourceCodeGenerateConfigureExtension internal constructor() : CommonGenerateConfigureScope() {
|
||||
|
||||
/**
|
||||
* Custom generated directory path.
|
||||
*
|
||||
* You can fill in the path relative to the current project.
|
||||
*
|
||||
* Format example: "path/to/your/src/main", the "src/main" is a fixed suffix.
|
||||
*
|
||||
* The `android`, `jvm` and `kmp` default is "build/generated/gropify/src/main".
|
||||
*
|
||||
* We recommend that you set the generated path under the "build" directory,
|
||||
* which is ignored by version control systems by default.
|
||||
*/
|
||||
var generateDirPath = ""
|
||||
@JvmName("generateDirPath") set
|
||||
}
|
||||
|
||||
open inner class CommonGenerateConfigureScope internal constructor(
|
||||
internal var existsPropertyFiles: MutableList<String>? = null,
|
||||
internal var permanentKeyValues: MutableMap<String, Any>? = null,
|
||||
internal var replacementKeyValues: MutableMap<String, Any>? = null,
|
||||
internal var excludeKeys: MutableList<Any>? = null,
|
||||
internal var includeKeys: MutableList<Any>? = null,
|
||||
internal var keyValuesRules: MutableMap<String, PropertyValueRule>? = null,
|
||||
internal var locations: List<GropifyLocation>? = null
|
||||
) {
|
||||
|
||||
/**
|
||||
* Whether to generate code.
|
||||
*
|
||||
* Enabled by default.
|
||||
*/
|
||||
var isEnabled: Boolean? = null
|
||||
@JvmName("enabled") set
|
||||
|
||||
/**
|
||||
* Whether to exclude the non-string type key-values content.
|
||||
*
|
||||
* Enabled by default, when enabled, key-values and content that are not string types will be excluded from properties' key-values.
|
||||
*/
|
||||
var excludeNonStringValue: Boolean? = null
|
||||
@JvmName("excludeNonStringValue") set
|
||||
|
||||
/**
|
||||
* Whether to use type auto conversion.
|
||||
*
|
||||
* Enabled by default, when enabled, the type in the properties' key-values will be
|
||||
* automatically identified and converted to the corresponding type.
|
||||
*
|
||||
* After enabling, if you want to force the content of a key-values to be a string type,
|
||||
* you can use single quotes or double quotes to wrap the entire string.
|
||||
*
|
||||
* - Note: After disabled this function, the functions mentioned above will also be invalid.
|
||||
*/
|
||||
var useTypeAutoConversion: Boolean? = null
|
||||
@JvmName("useTypeAutoConversion") set
|
||||
|
||||
/**
|
||||
* Whether to use key-values content interpolation.
|
||||
*
|
||||
* Enabled by default, after enabling it will automatically identify
|
||||
* the `${...}` content in the properties' key-values content and replace it.
|
||||
*
|
||||
* Note: The interpolated content will only be looked up from the
|
||||
* current (current configuration file) properties' key-values list.
|
||||
*/
|
||||
var useValueInterpolation: Boolean? = null
|
||||
@JvmName("useValueInterpolation") set
|
||||
|
||||
/**
|
||||
* Set exists property files.
|
||||
*
|
||||
* The property files will be automatically obtained from the root directory
|
||||
* of the current root project, subproject and user directory according to the file name you set.
|
||||
*
|
||||
* By default, will add "gradle.properties" if [addDefault] is `true`.
|
||||
*
|
||||
* You can add multiple sets of property files name, they will be read in order.
|
||||
*
|
||||
* - Note: Generally there is no need to modify this setting,
|
||||
* an incorrect file name will result in obtaining empty key-values content.
|
||||
* @param fileNames the file names.
|
||||
* @param addDefault whether to add a default property file name, default is true.
|
||||
*/
|
||||
@JvmOverloads
|
||||
fun existsPropertyFiles(vararg fileNames: String, addDefault: Boolean = true) {
|
||||
Gropify.require(fileNames.isNotEmpty() && fileNames.all { it.isNotBlank() }) {
|
||||
"Property file names must not be empty or have blank contents."
|
||||
}
|
||||
|
||||
existsPropertyFiles = fileNames.distinct().toMutableList()
|
||||
if (addDefault) existsPropertyFiles?.add(0, GropifyConfig.DEFAULT_EXISTS_PROPERTY_FILE)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a permanent list of properties' key-values.
|
||||
*
|
||||
* Here you can set some key-values that must exist, these key-values will be generated regardless of
|
||||
* whether they can be obtained from the properties' key-values.
|
||||
*
|
||||
* These keys use the content of the properties' key if it exists, use the content set here if it does not exist.
|
||||
*
|
||||
* - Note: Special symbols and spaces cannot exist in properties' key names, otherwise the generation may fail.
|
||||
* @param pairs the key-values array.
|
||||
*/
|
||||
@JvmName("`kotlin-dsl-only-permanentKeyValues`")
|
||||
fun permanentKeyValues(vararg pairs: Pair<String, Any>) {
|
||||
Gropify.require(pairs.isNotEmpty() && pairs.all { it.first.isNotBlank() }) {
|
||||
"Permanent key-values must not be empty or have blank contents."
|
||||
}
|
||||
|
||||
permanentKeyValues = mutableMapOf(*pairs)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a permanent list of properties' key-values. (Groovy compatible function)
|
||||
*
|
||||
* Here you can set some key-values that must exist, these key-values will be generated regardless of
|
||||
* whether they can be obtained from the properties' key-values.
|
||||
*
|
||||
* These keys use the content of the properties' key if it exists, use the content set here if it does not exist.
|
||||
*
|
||||
* - Note: Special symbols and spaces cannot exist in properties' key names, otherwise the generation may fail.
|
||||
* @param keyValues the key-value array.
|
||||
*/
|
||||
fun permanentKeyValues(keyValues: Map<String, Any>) {
|
||||
Gropify.require(keyValues.isNotEmpty() && keyValues.all { it.key.isNotBlank() }) {
|
||||
"Permanent key-values must not be empty or have blank contents."
|
||||
}
|
||||
|
||||
permanentKeyValues = keyValues.toMutableMap()
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a replacement list of properties' key-values.
|
||||
*
|
||||
* Here you can set some key-values that need to be replaced, these key-values will be replaced
|
||||
* the existing properties' key-values, if not exist, they will be ignored.
|
||||
*
|
||||
* The key-values set here will also overwrite the key-values set in [permanentKeyValues].
|
||||
* @param pairs the key-values array.
|
||||
*/
|
||||
@JvmName("`kotlin-dsl-only-replacementKeyValues`")
|
||||
fun replacementKeyValues(vararg pairs: Pair<String, Any>) {
|
||||
Gropify.require(pairs.isNotEmpty() && pairs.all { it.first.isNotBlank() }) {
|
||||
"Replacement key-values must not be empty or have blank contents."
|
||||
}
|
||||
|
||||
replacementKeyValues = mutableMapOf(*pairs)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a replacement list of properties' key-values. (Groovy compatible function)
|
||||
*
|
||||
* Here you can set some key-values that need to be replaced, these key-values will be replaced
|
||||
* the existing properties' key-values, if not exist, they will be ignored.
|
||||
*
|
||||
* The key-values set here will also overwrite the key-values set in [permanentKeyValues].
|
||||
* @param keyValues the key-value array.
|
||||
*/
|
||||
fun replacementKeyValues(keyValues: Map<String, Any>) {
|
||||
Gropify.require(keyValues.isNotEmpty() && keyValues.all { it.key.isNotBlank() }) {
|
||||
"Replacement key-values must not be empty or have blank contents."
|
||||
}
|
||||
|
||||
replacementKeyValues = keyValues.toMutableMap()
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a key list of properties' key-values name that need to be excluded.
|
||||
*
|
||||
* Here you can set some key names that you want to exclude from known properties' key-values.
|
||||
*
|
||||
* These keys are excluded if they are present in the properties' key, will not appear in the generated code.
|
||||
*
|
||||
* - Note: If you exclude key-values set in [permanentKeyValues], then they will only change to the
|
||||
* initial key-values content you set and continue to exist.
|
||||
* @param keys the key names, you can pass in [Regex] or use [String.toRegex] to use regex functionality.
|
||||
*/
|
||||
fun excludeKeys(vararg keys: Any) {
|
||||
Gropify.require(keys.isNotEmpty() && keys.all { it.toString().isNotBlank() }) {
|
||||
"Excluded keys must not be empty or have blank contents."
|
||||
}
|
||||
|
||||
excludeKeys = keys.distinct().toMutableList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a key list of properties' key-values name that need to be included.
|
||||
*
|
||||
* Here you can set some key value names that you want to include from known properties' key-values.
|
||||
*
|
||||
* These keys are included if the properties' key exists, unincluded keys will not appear in the generated code.
|
||||
* @param keys the key names, you can pass in [Regex] or use [String.toRegex] to use regex functionality.
|
||||
*/
|
||||
fun includeKeys(vararg keys: Any) {
|
||||
Gropify.require(keys.isNotEmpty() && keys.all { it.toString().isNotBlank() }) {
|
||||
"Included keys must not be empty or have blank contents."
|
||||
}
|
||||
|
||||
includeKeys = keys.distinct().toMutableList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Set properties' key-values rules.
|
||||
*
|
||||
* You can set up a set of key-values rules,
|
||||
* use [ValueRule] to create new rule for parsing the obtained key-values content.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* ```kotlin
|
||||
* keyValuesRules(
|
||||
* "some.key1" to createValueRule { if (it.contains("_")) it.replace("_", "-") else it },
|
||||
* "some.key2" to createValueRule { "$it-value" }
|
||||
* )
|
||||
* ```
|
||||
*
|
||||
* These key-values rules are applied when properties' keys exist.
|
||||
* @param pairs the key-values array.
|
||||
*/
|
||||
@JvmName("`kotlin-dsl-only-keyValuesRules`")
|
||||
fun keyValuesRules(vararg pairs: Pair<String, PropertyValueRule>) {
|
||||
Gropify.require(pairs.isNotEmpty() && pairs.all { it.first.isNotBlank() }) {
|
||||
"Key-values rules must not be empty or have blank contents."
|
||||
}
|
||||
|
||||
keyValuesRules = mutableMapOf(*pairs)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set properties' key-values rules. (Groovy compatible function)
|
||||
*
|
||||
* You can set up a set of key-values rules,
|
||||
* use [ValueRule] to create new rule for parsing the obtained key-values content.
|
||||
*
|
||||
* These key-values rules are applied when properties' keys exist.
|
||||
* @param rules the key-values array.
|
||||
*/
|
||||
fun keyValuesRules(rules: Map<String, PropertyValueRule>) {
|
||||
Gropify.require(rules.isNotEmpty() && rules.all { it.key.isNotBlank() }) {
|
||||
"Key-values rules must not be empty or have blank contents."
|
||||
}
|
||||
|
||||
keyValuesRules = rules.toMutableMap()
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new properties' values rule.
|
||||
* @param rule callback current rule.
|
||||
* @return [PropertyValueRule]
|
||||
*/
|
||||
fun ValueRule(rule: PropertyValueRule) = rule
|
||||
|
||||
/**
|
||||
* Set where to find properties' key-values.
|
||||
*
|
||||
* Defaults are [GropifyLocation.CurrentProject], [GropifyLocation.RootProject].
|
||||
*
|
||||
* You can set this up using the following types.
|
||||
*
|
||||
* - [GropifyLocation.CurrentProject]
|
||||
* - [GropifyLocation.RootProject]
|
||||
* - [GropifyLocation.Global]
|
||||
* - [GropifyLocation.System]
|
||||
* - [GropifyLocation.SystemEnv]
|
||||
*
|
||||
* We will generate properties' key-values in sequence from the locations you set,
|
||||
* the order of the generation locations follows the order you set.
|
||||
*
|
||||
* - Risk warning: [GropifyLocation.Global], [GropifyLocation.System],
|
||||
* [GropifyLocation.SystemEnv] may have keys and certificates,
|
||||
* please manage the generated code carefully.
|
||||
* @param types the location type array.
|
||||
*/
|
||||
fun locations(vararg types: GropifyLocation) {
|
||||
locations = types.toList()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build [GropifyConfig] from current extension.
|
||||
* @param settings the Gradle [Settings] instance.
|
||||
* @return [GropifyConfig]
|
||||
*/
|
||||
internal fun build(settings: Settings): GropifyConfig {
|
||||
fun String.checkingStartWithLetter(description: String) {
|
||||
Gropify.require(isStartsWithLetter()) {
|
||||
"$description name \"$this\" must start with a letter."
|
||||
}
|
||||
}
|
||||
|
||||
fun String.checkingPackageName() {
|
||||
Gropify.require(isBlank() || KeywordsDetector.verifyPackage(this)) {
|
||||
"Illegal package name \"$this\"."
|
||||
}
|
||||
}
|
||||
|
||||
fun String.checkingClassName() {
|
||||
Gropify.require(isBlank() || KeywordsDetector.verifyClass(this)) {
|
||||
"Illegal class name \"$this\"."
|
||||
}
|
||||
}
|
||||
|
||||
fun String.checkingValidExtensionName() {
|
||||
checkingStartWithLetter(description = "Extension")
|
||||
if (isNotBlank() && isUnSafeExtName()) Gropify.error("This name \"$this\" is a Gradle built-in extension。")
|
||||
}
|
||||
|
||||
fun GenerateConfigureScope.checkingNames() {
|
||||
buildscriptConfigure?.extensionName?.checkingValidExtensionName()
|
||||
|
||||
androidConfigure?.packageName?.checkingPackageName()
|
||||
androidConfigure?.className?.checkingClassName()
|
||||
|
||||
jvmConfigure?.packageName?.checkingPackageName()
|
||||
jvmConfigure?.className?.checkingClassName()
|
||||
|
||||
kmpConfigure?.packageName?.checkingPackageName()
|
||||
kmpConfigure?.className?.checkingClassName()
|
||||
}
|
||||
|
||||
val currentEnabled = isEnabled
|
||||
val currentDebugMode = debugMode
|
||||
val currentGlobal = globalConfigure.create()
|
||||
val currentProjects = mutableMapOf<String, GropifyConfig.GenerateConfig>()
|
||||
val rootName = settings.rootProject.name
|
||||
|
||||
globalConfigure.checkingNames()
|
||||
|
||||
Gropify.require(projectConfigures.none { (name, _) -> name.lowercase() == rootName.lowercase() }) {
|
||||
"This project name '$rootName' is a root project, please use `rootProject` function to configure it, not `projects(\"$rootName\")`."
|
||||
}
|
||||
|
||||
if (projectConfigures.containsKey(ROOT_PROJECT_TAG)) {
|
||||
projectConfigures[rootName] = projectConfigures[ROOT_PROJECT_TAG]!!
|
||||
projectConfigures.remove(ROOT_PROJECT_TAG)
|
||||
}
|
||||
|
||||
projectConfigures.forEach { (name, subConfigure) ->
|
||||
name.replaceFirst(":", "").checkingStartWithLetter(description = "Project")
|
||||
subConfigure.checkingNames()
|
||||
|
||||
currentProjects[name] = subConfigure.create(name, globalConfigure)
|
||||
}
|
||||
|
||||
return object : GropifyConfig {
|
||||
override val isEnabled get() = currentEnabled
|
||||
override val debugMode get() = currentDebugMode
|
||||
override val global get() = currentGlobal
|
||||
override val projects get() = currentProjects
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/12.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.generator
|
||||
|
||||
import com.highcapable.gropify.gradle.api.GradleDescriptor
|
||||
import com.highcapable.gropify.internal.error
|
||||
import com.highcapable.gropify.internal.require
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import com.highcapable.gropify.plugin.config.proxy.GropifyConfig
|
||||
import com.highcapable.gropify.plugin.extension.accessors.proxy.ExtensionAccessors
|
||||
import com.highcapable.gropify.plugin.generator.extension.PropertyMap
|
||||
import com.highcapable.gropify.plugin.generator.extension.createTypedValue
|
||||
import com.highcapable.gropify.plugin.generator.extension.toOptimize
|
||||
import com.highcapable.gropify.plugin.generator.extension.toPoetNoEscape
|
||||
import com.highcapable.gropify.utils.extension.capitalize
|
||||
import com.highcapable.gropify.utils.extension.firstNumberToLetter
|
||||
import com.highcapable.gropify.utils.extension.uncapitalize
|
||||
import com.highcapable.gropify.utils.extension.upperCamelcase
|
||||
import com.highcapable.kavaref.extension.classOf
|
||||
import com.palantir.javapoet.ClassName
|
||||
import com.palantir.javapoet.FieldSpec
|
||||
import com.palantir.javapoet.JavaFile
|
||||
import com.palantir.javapoet.MethodSpec
|
||||
import com.palantir.javapoet.TypeSpec
|
||||
import javax.lang.model.element.Modifier
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/**
|
||||
* Generator for buildscript accessors classes.
|
||||
*/
|
||||
internal class BuildscriptGenerator {
|
||||
|
||||
private companion object {
|
||||
|
||||
private const val ACCESSORS_PACKAGE_NAME = "${Gropify.GROUP_NAME}.plugin.extension.accessors.generated"
|
||||
|
||||
private const val CLASS_SUFFIX_NAME = "Accessors"
|
||||
|
||||
private const val TOP_CLASS_SUFFIX_NAME = "Properties$CLASS_SUFFIX_NAME"
|
||||
private const val TOP_SUCCESSIVE_NAME = "_top_successive_name"
|
||||
|
||||
private val NonNullApiClass = ClassName.get("org.gradle.api", "NonNullApi")
|
||||
private val NullMarkedClass = ClassName.get("org.jspecify.annotations", "NullMarked")
|
||||
|
||||
private val NonNullClass get() = when {
|
||||
// At least Gradle 9.x/10.x, use `@NullMarked` annotation.
|
||||
GradleDescriptor.version.let { it.startsWith("9.") || it.startsWith("10.") } -> NullMarkedClass
|
||||
// Below Gradle 9.x, use `@NonNullApi` annotation.
|
||||
else -> NonNullApiClass
|
||||
}
|
||||
}
|
||||
|
||||
private var config by Delegates.notNull<GropifyConfig.BuildscriptGenerateConfig>()
|
||||
|
||||
private val classSpecs = mutableMapOf<String, TypeSpec.Builder>()
|
||||
private val constructorSpecs = mutableMapOf<String, MethodSpec.Builder>()
|
||||
private val preAddConstructorSpecNames = mutableListOf<Pair<String, String>>()
|
||||
private val memoryExtensionClasses = mutableMapOf<String, String>()
|
||||
private val grandSuccessiveNames = mutableListOf<String>()
|
||||
private val grandSuccessiveDuplicateIndexes = mutableMapOf<String, Int>()
|
||||
private val usedSuccessiveMethods = mutableMapOf<String, MutableList<String>>()
|
||||
private val usedSuccessiveTags = mutableSetOf<String>()
|
||||
|
||||
private inline fun noRepeated(vararg tags: String, block: () -> Unit) {
|
||||
val allTag = tags.joinToString("-")
|
||||
|
||||
if (!usedSuccessiveTags.contains(allTag)) block()
|
||||
usedSuccessiveTags.add(allTag)
|
||||
}
|
||||
|
||||
private fun String.capitalized() = "${capitalize()}$CLASS_SUFFIX_NAME"
|
||||
private fun String.uncapitalized() = "${uncapitalize()}$CLASS_SUFFIX_NAME"
|
||||
|
||||
private fun String.asClassType(packageName: String = "") = ClassName.get(packageName, this)
|
||||
|
||||
private fun TypeSpec.createJavaFile(packageName: String) = JavaFile.builder(packageName, this).build()
|
||||
|
||||
private fun createClassSpec(name: String, accessorsName: String = "", isInner: Boolean = true) =
|
||||
TypeSpec.classBuilder(if (isInner) name.capitalized() else name).apply {
|
||||
if (isInner) {
|
||||
addJavadoc("The \"$accessorsName\" accessors.")
|
||||
|
||||
addSuperinterface(classOf<ExtensionAccessors>())
|
||||
addModifiers(Modifier.PUBLIC, Modifier.STATIC)
|
||||
} else {
|
||||
addJavadoc(
|
||||
"""
|
||||
This class is auto generated by Gropify.
|
||||
<br/>
|
||||
You can visit <a href="${Gropify.PROJECT_URL}">here</a> for more help.
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
addAnnotation(NonNullClass)
|
||||
addModifiers(Modifier.PUBLIC)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createConstructorSpec() = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC)
|
||||
|
||||
private fun TypeSpec.Builder.addSuccessiveField(accessorsName: String, className: String) = addField(
|
||||
FieldSpec.builder(className.capitalized().asClassType(), className.uncapitalized(), Modifier.PRIVATE, Modifier.FINAL).apply {
|
||||
addJavadoc("Create the \"$accessorsName\" accessors.")
|
||||
}.build()
|
||||
)
|
||||
|
||||
private fun TypeSpec.Builder.addSuccessiveMethod(accessorsName: String, methodName: String, className: String) =
|
||||
addMethod(
|
||||
MethodSpec.methodBuilder("get${getOrCreateUsedSuccessiveMethodName(methodName, className).capitalize()}").apply {
|
||||
addJavadoc("Resolve the \"$accessorsName\" accessors.")
|
||||
|
||||
addModifiers(Modifier.PUBLIC, Modifier.FINAL)
|
||||
returns(className.capitalized().asClassType())
|
||||
addStatement("return ${className.uncapitalized()}")
|
||||
}.build()
|
||||
)
|
||||
|
||||
private fun TypeSpec.Builder.addFinalValueMethod(accessorsName: String, methodName: String, className: String, value: Any) =
|
||||
addMethod(
|
||||
MethodSpec.methodBuilder("get${getOrCreateUsedSuccessiveMethodName(methodName, className).capitalize()}").apply {
|
||||
val typedValue = value.createTypedValue(config.useTypeAutoConversion)
|
||||
val safeValueForJavadoc = typedValue.second.replace("$", "$$")
|
||||
|
||||
addJavadoc("Resolve the \"$accessorsName\" value \"${value.toString().toPoetNoEscape()}\".")
|
||||
|
||||
addModifiers(Modifier.PUBLIC, Modifier.FINAL)
|
||||
returns(typedValue.first.java)
|
||||
addStatement("return $safeValueForJavadoc")
|
||||
}.build()
|
||||
)
|
||||
|
||||
private fun MethodSpec.Builder.addSuccessiveStatement(className: String) =
|
||||
addStatement("${className.uncapitalized()} = new ${className.capitalized()}()")
|
||||
|
||||
private fun getOrCreateUsedSuccessiveMethodName(methodName: String, className: String): String {
|
||||
if (usedSuccessiveMethods[className] == null) usedSuccessiveMethods[className] = mutableListOf()
|
||||
|
||||
val methods = usedSuccessiveMethods[className]!!
|
||||
val finalName = if (methods.contains(methodName)) "$methodName${methods.filter { it == methodName }.size + 1}" else methodName
|
||||
methods.add(methodName)
|
||||
|
||||
return finalName
|
||||
}
|
||||
|
||||
private fun getOrCreateClassSpec(name: String, accessorsName: String = "") =
|
||||
classSpecs[name] ?: createClassSpec(name, accessorsName).also { classSpecs[name] = it }
|
||||
|
||||
private fun getOrCreateConstructorSpec(name: String) = constructorSpecs[name]
|
||||
?: createConstructorSpec().also { constructorSpecs[name] = it }
|
||||
|
||||
/**
|
||||
* Parse and generate builders for all classes (core function).
|
||||
*
|
||||
* Before starting the parsing, we need to ensure that [createTopClassSpec]
|
||||
* has been called and [clearGeneratedData] has been called once to prevent data confusion.
|
||||
*
|
||||
* After the parsing is completed, we need to call [releaseParseTypeSpec] to complete the parsing.
|
||||
*/
|
||||
private fun parseTypeSpec(successiveName: String, key: String, value: Any) {
|
||||
fun String.duplicateGrandSuccessiveIndex() = lowercase().let { name ->
|
||||
if (grandSuccessiveDuplicateIndexes.contains(name)) {
|
||||
grandSuccessiveDuplicateIndexes[name] = (grandSuccessiveDuplicateIndexes[name] ?: 1) + 1
|
||||
grandSuccessiveDuplicateIndexes[name] ?: 2
|
||||
} else 2.also { grandSuccessiveDuplicateIndexes[name] = it }
|
||||
}
|
||||
|
||||
fun String.withoutJavaKeywords() = if (lowercase() == "class") "clazz" else this
|
||||
|
||||
/**
|
||||
* Parse (split) names into arrays.
|
||||
*
|
||||
* Likes "com.foobar" → "ComFoobar" → "foobar".
|
||||
*/
|
||||
fun String.parseSuccessiveNames(): List<Triple<String, String, String>> {
|
||||
var grandAccessorsName = ""
|
||||
var grandSuccessiveName = ""
|
||||
val successiveNames = mutableListOf<Triple<String, String, String>>()
|
||||
|
||||
// Like "com_foobar" or "com__foobar" will be split to ["com", "foobar"].
|
||||
val splitNames = split("_").filter { it.isNotBlank() }.ifEmpty { listOf(this) }
|
||||
|
||||
splitNames.forEach { eachName ->
|
||||
val name = eachName.capitalize().withoutJavaKeywords().firstNumberToLetter()
|
||||
|
||||
grandAccessorsName += if (grandAccessorsName.isNotBlank()) ".$eachName" else eachName
|
||||
grandSuccessiveName += name
|
||||
|
||||
if (grandSuccessiveNames.any { it != grandSuccessiveName && it.lowercase() == grandSuccessiveName.lowercase() })
|
||||
grandSuccessiveName += duplicateGrandSuccessiveIndex().toString()
|
||||
grandSuccessiveNames.add(grandSuccessiveName)
|
||||
|
||||
successiveNames.add(Triple(grandAccessorsName, grandSuccessiveName, name))
|
||||
}
|
||||
|
||||
return successiveNames.distinct()
|
||||
}
|
||||
|
||||
val successiveNames = successiveName.parseSuccessiveNames()
|
||||
successiveNames.forEachIndexed { index, (accessorsName, className, methodName) ->
|
||||
val nextItem = successiveNames.getOrNull(index + 1)
|
||||
val lastItem = successiveNames.getOrNull(successiveNames.lastIndex)
|
||||
|
||||
val nextAccessorsName = nextItem?.first ?: ""
|
||||
val nextClassName = nextItem?.second ?: ""
|
||||
val nextMethodName = nextItem?.third ?: ""
|
||||
|
||||
val lastClassName = lastItem?.second ?: ""
|
||||
val lastMethodName = lastItem?.third ?: ""
|
||||
|
||||
val isPreLastIndex = index == successiveNames.lastIndex - 1
|
||||
|
||||
if (successiveNames.size == 1) getOrCreateClassSpec(TOP_SUCCESSIVE_NAME).apply {
|
||||
addFinalValueMethod(key, methodName, className, value)
|
||||
}
|
||||
if (index == successiveNames.lastIndex) return@forEachIndexed
|
||||
|
||||
if (index == 0) noRepeated(TOP_SUCCESSIVE_NAME, methodName, className) {
|
||||
getOrCreateClassSpec(TOP_SUCCESSIVE_NAME, accessorsName).apply {
|
||||
addSuccessiveField(accessorsName, className)
|
||||
addSuccessiveMethod(accessorsName, methodName, className)
|
||||
}
|
||||
getOrCreateConstructorSpec(TOP_SUCCESSIVE_NAME).addSuccessiveStatement(className)
|
||||
}
|
||||
|
||||
noRepeated(className, nextMethodName, nextClassName) {
|
||||
getOrCreateClassSpec(className, accessorsName).apply {
|
||||
if (!isPreLastIndex) {
|
||||
addSuccessiveField(nextAccessorsName, nextClassName)
|
||||
addSuccessiveMethod(nextAccessorsName, nextMethodName, nextClassName)
|
||||
} else addFinalValueMethod(key, lastMethodName, lastClassName, value)
|
||||
}
|
||||
|
||||
if (!isPreLastIndex) preAddConstructorSpecNames.add(className to nextClassName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun releaseParseTypeSpec() =
|
||||
preAddConstructorSpecNames.onEach { (topClassName, innerClassName) ->
|
||||
getOrCreateConstructorSpec(topClassName)?.addSuccessiveStatement(innerClassName)
|
||||
}.clear()
|
||||
|
||||
private fun buildTypeSpec(): TypeSpec {
|
||||
classSpecs.forEach { (name, typeSpec) ->
|
||||
constructorSpecs[name]?.build()?.let { typeSpec.addMethod(it) }
|
||||
if (name != TOP_SUCCESSIVE_NAME) classSpecs[TOP_SUCCESSIVE_NAME]?.addType(typeSpec.build())
|
||||
}
|
||||
|
||||
return classSpecs[TOP_SUCCESSIVE_NAME]?.build() ?: Gropify.error("Merging accessors class failed.")
|
||||
}
|
||||
|
||||
private fun createTopClassSpec(config: GropifyConfig.BuildscriptGenerateConfig) {
|
||||
Gropify.require(config.name.isNotBlank()) {
|
||||
"Class name cannot be empty or blank."
|
||||
}
|
||||
|
||||
this.config = config
|
||||
|
||||
val topClassName = "${config.name.replace(":", "_").upperCamelcase()}$TOP_CLASS_SUFFIX_NAME"
|
||||
|
||||
memoryExtensionClasses[config.name] = "$ACCESSORS_PACKAGE_NAME.$topClassName"
|
||||
classSpecs[TOP_SUCCESSIVE_NAME] = createClassSpec(topClassName, isInner = false)
|
||||
constructorSpecs[TOP_SUCCESSIVE_NAME] = createConstructorSpec()
|
||||
}
|
||||
|
||||
private fun clearGeneratedData(clearAll: Boolean = false) {
|
||||
classSpecs.clear()
|
||||
constructorSpecs.clear()
|
||||
preAddConstructorSpecNames.clear()
|
||||
grandSuccessiveNames.clear()
|
||||
grandSuccessiveDuplicateIndexes.clear()
|
||||
usedSuccessiveMethods.clear()
|
||||
usedSuccessiveTags.clear()
|
||||
if (clearAll) memoryExtensionClasses.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate [JavaFile] array.
|
||||
*
|
||||
* - Note: [allConfig] and [allKeyValues] must be equal in number.
|
||||
*/
|
||||
fun build(
|
||||
allConfig: MutableList<GropifyConfig.BuildscriptGenerateConfig>,
|
||||
allKeyValues: MutableList<PropertyMap>
|
||||
) = runCatching {
|
||||
Gropify.require(allConfig.size == allKeyValues.size) {
|
||||
"The number of configurations must be equal to the number of key-value pairs."
|
||||
}
|
||||
|
||||
val files = mutableListOf<JavaFile>()
|
||||
if (allConfig.isEmpty()) return@runCatching files
|
||||
|
||||
clearGeneratedData(clearAll = true)
|
||||
allConfig.forEachIndexed { index, configs ->
|
||||
val keyValues = allKeyValues[index]
|
||||
|
||||
clearGeneratedData()
|
||||
createTopClassSpec(configs)
|
||||
|
||||
keyValues.toOptimize().forEach { (key, value) ->
|
||||
parseTypeSpec(key, value.first, value.second)
|
||||
releaseParseTypeSpec()
|
||||
}
|
||||
|
||||
files.add(buildTypeSpec().createJavaFile(ACCESSORS_PACKAGE_NAME))
|
||||
}
|
||||
|
||||
files
|
||||
}.getOrElse { Gropify.error("Failed to generated accessors classes.\n$it") }
|
||||
|
||||
/**
|
||||
* Generate compile only stub files for buildscript accessors.
|
||||
* @return [List]<[JavaFile]>
|
||||
*/
|
||||
val compileStubFiles get(): List<JavaFile> {
|
||||
val stubFiles = mutableListOf<JavaFile>()
|
||||
|
||||
val nonNullFile =
|
||||
TypeSpec.annotationBuilder(NonNullClass.simpleName())
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.build().createJavaFile(NonNullClass.packageName())
|
||||
val extensionAccessorsFile =
|
||||
TypeSpec.interfaceBuilder(classOf<ExtensionAccessors>().simpleName)
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.build().createJavaFile(classOf<ExtensionAccessors>().packageName)
|
||||
|
||||
stubFiles.add(nonNullFile)
|
||||
stubFiles.add(extensionAccessorsFile)
|
||||
|
||||
return stubFiles
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generated buildscript extension class full name by extension name.
|
||||
* @param name the extension name.
|
||||
* @return [String]
|
||||
* @throws IllegalStateException if the class is not found.
|
||||
*/
|
||||
fun propertiesClass(name: String) = memoryExtensionClasses[name] ?: Gropify.error("Could not found class \"$name\".")
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/11.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.generator
|
||||
|
||||
import com.highcapable.gropify.internal.error
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import com.highcapable.gropify.plugin.config.proxy.GropifyConfig
|
||||
import com.highcapable.gropify.plugin.generator.config.GenerateConfig
|
||||
import com.highcapable.gropify.plugin.generator.config.SourceCodeSpec
|
||||
import com.highcapable.gropify.plugin.generator.extension.PropertyMap
|
||||
import com.highcapable.gropify.plugin.generator.extension.createTypedValue
|
||||
import com.highcapable.gropify.plugin.generator.extension.toOptimize
|
||||
import com.highcapable.gropify.plugin.generator.extension.toPoetNoEscape
|
||||
import com.highcapable.gropify.plugin.generator.extension.toPoetSpace
|
||||
import com.highcapable.gropify.plugin.generator.extension.toUnderscores
|
||||
import com.highcapable.gropify.utils.extension.firstNumberToLetter
|
||||
import com.palantir.javapoet.ClassName
|
||||
import com.palantir.javapoet.FieldSpec
|
||||
import com.palantir.javapoet.JavaFile
|
||||
import com.palantir.javapoet.TypeSpec
|
||||
import javax.lang.model.element.Modifier
|
||||
|
||||
/**
|
||||
* Generator for Java code.
|
||||
*/
|
||||
internal class JavaCodeGenerator {
|
||||
|
||||
/**
|
||||
* Build Java source code.
|
||||
* @return [SourceCodeSpec]
|
||||
*/
|
||||
fun build(config: GropifyConfig.CommonCodeGenerateConfig, generateConfig: GenerateConfig, keyValues: PropertyMap) = runCatching {
|
||||
val className = ClassName.get(generateConfig.packageName, generateConfig.className)
|
||||
|
||||
val typeSpec = TypeSpec.classBuilder(className).apply {
|
||||
addJavadoc(
|
||||
"""
|
||||
This class is auto generated by Gropify.
|
||||
<br/>
|
||||
You can visit <a href="${Gropify.PROJECT_URL}">here</a> for more help.
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
if (!config.isRestrictedAccessEnabled) addModifiers(Modifier.PUBLIC)
|
||||
keyValues.toOptimize().toUnderscores().forEach { (key, value) ->
|
||||
val typedValue = value.second.createTypedValue(config.useTypeAutoConversion)
|
||||
|
||||
addField(
|
||||
FieldSpec.builder(typedValue.first.java, key.firstNumberToLetter()).apply {
|
||||
addJavadoc("Resolve the \"${value.first.toPoetNoEscape()}\" value \"${value.second.toString().toPoetNoEscape()}\".")
|
||||
|
||||
if (!config.isRestrictedAccessEnabled)
|
||||
addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
|
||||
else addModifiers(Modifier.STATIC, Modifier.FINAL)
|
||||
|
||||
initializer(typedValue.second.toPoetNoEscape().toPoetSpace())
|
||||
}.build()
|
||||
)
|
||||
}
|
||||
}.build()
|
||||
|
||||
val javaFile = JavaFile.builder(generateConfig.packageName, typeSpec).apply {
|
||||
addFileComment(
|
||||
"""
|
||||
This file is auto generated by Gropify.
|
||||
You can visit ${Gropify.PROJECT_URL} for more help.
|
||||
**DO NOT EDIT THIS FILE MANUALLY**
|
||||
""".trimIndent()
|
||||
)
|
||||
}.build()
|
||||
SourceCodeSpec(SourceCodeSpec.Type.Java, javaFile)
|
||||
}.getOrElse { Gropify.error("Failed to generated Java file.\n$it") }
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/11.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.generator
|
||||
|
||||
import com.highcapable.gropify.internal.error
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import com.highcapable.gropify.plugin.config.proxy.GropifyConfig
|
||||
import com.highcapable.gropify.plugin.generator.config.GenerateConfig
|
||||
import com.highcapable.gropify.plugin.generator.config.SourceCodeSpec
|
||||
import com.highcapable.gropify.plugin.generator.extension.PropertyMap
|
||||
import com.highcapable.gropify.plugin.generator.extension.createTypedValue
|
||||
import com.highcapable.gropify.plugin.generator.extension.toOptimize
|
||||
import com.highcapable.gropify.plugin.generator.extension.toPoetNoEscape
|
||||
import com.highcapable.gropify.plugin.generator.extension.toPoetSpace
|
||||
import com.highcapable.gropify.plugin.generator.extension.toUnderscores
|
||||
import com.highcapable.gropify.utils.extension.firstNumberToLetter
|
||||
import com.squareup.kotlinpoet.FileSpec
|
||||
import com.squareup.kotlinpoet.KModifier
|
||||
import com.squareup.kotlinpoet.PropertySpec
|
||||
import com.squareup.kotlinpoet.TypeSpec
|
||||
|
||||
/**
|
||||
* Generator for Kotlin code.
|
||||
*/
|
||||
internal class KotlinCodeGenerator {
|
||||
|
||||
/**
|
||||
* Build Kotlin source code.
|
||||
* @return [SourceCodeSpec]
|
||||
*/
|
||||
fun build(config: GropifyConfig.CommonCodeGenerateConfig, generateConfig: GenerateConfig, keyValues: PropertyMap) = runCatching {
|
||||
val fileSpec = FileSpec.builder(generateConfig.packageName, generateConfig.className).apply {
|
||||
addType(TypeSpec.objectBuilder(generateConfig.className).apply {
|
||||
addFileComment(
|
||||
"""
|
||||
This file is auto generated by Gropify.
|
||||
You can visit ${Gropify.PROJECT_URL} for more help.
|
||||
**DO NOT EDIT THIS FILE MANUALLY**
|
||||
""".trimIndent()
|
||||
)
|
||||
addKdoc(
|
||||
"""
|
||||
This class is auto generated by Gropify.
|
||||
You can visit [here](${Gropify.PROJECT_URL}) for more help.
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
if (config.isRestrictedAccessEnabled) addModifiers(KModifier.INTERNAL)
|
||||
keyValues.toOptimize().toUnderscores().forEach { (key, value) ->
|
||||
val typedValue = value.second.createTypedValue(config.useTypeAutoConversion)
|
||||
|
||||
addProperty(PropertySpec.builder(key.firstNumberToLetter(), typedValue.first).apply {
|
||||
addKdoc("Resolve the \"${value.first.toPoetNoEscape()}\" value \"${value.second.toString().toPoetNoEscape()}\".")
|
||||
|
||||
if (config.isRestrictedAccessEnabled) addModifiers(KModifier.INTERNAL)
|
||||
addModifiers(KModifier.CONST)
|
||||
initializer(typedValue.second.toPoetNoEscape().toPoetSpace())
|
||||
}.build())
|
||||
}
|
||||
}.build())
|
||||
}.build()
|
||||
|
||||
SourceCodeSpec(SourceCodeSpec.Type.Kotlin, fileSpec)
|
||||
}.getOrElse { Gropify.error("Failed to generated Kotlin file.\n$it") }
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/11.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.generator
|
||||
|
||||
import com.highcapable.gropify.internal.require
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import com.highcapable.gropify.plugin.config.proxy.GropifyConfig
|
||||
import com.highcapable.gropify.plugin.generator.config.GenerateConfig
|
||||
import com.highcapable.gropify.plugin.generator.config.SourceCodeSpec
|
||||
import com.highcapable.gropify.plugin.generator.extension.PropertyMap
|
||||
|
||||
/**
|
||||
* Source code generator.
|
||||
*/
|
||||
internal class SourceCodeGenerator {
|
||||
|
||||
private val java = JavaCodeGenerator()
|
||||
private val kotlin = KotlinCodeGenerator()
|
||||
|
||||
/**
|
||||
* Build source code specs.
|
||||
* @param config the current generate config.
|
||||
* @param generateConfig the generate config.
|
||||
* @param keyValues the properties' key-values map.
|
||||
* @return [List]<[SourceCodeSpec]>
|
||||
*/
|
||||
fun build(config: GropifyConfig.SourceCodeGenerateConfig, generateConfig: GenerateConfig, keyValues: PropertyMap): List<SourceCodeSpec> {
|
||||
Gropify.require(config is GropifyConfig.CommonCodeGenerateConfig) {
|
||||
"Only Android, Jvm, Kotlin Multiplatform project is supported for now."
|
||||
}
|
||||
|
||||
return listOf(
|
||||
java.build(config, generateConfig, keyValues),
|
||||
kotlin.build(config, generateConfig, keyValues)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/13.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.generator.config
|
||||
|
||||
/**
|
||||
* Configuration for source code generation.
|
||||
*/
|
||||
internal data class GenerateConfig(
|
||||
val packageName: String,
|
||||
val className: String
|
||||
)
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/13.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.generator.config
|
||||
|
||||
import com.highcapable.gropify.internal.error
|
||||
import com.highcapable.gropify.plugin.Gropify
|
||||
import com.palantir.javapoet.JavaFile
|
||||
import com.squareup.kotlinpoet.FileSpec
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
* Source code specification.
|
||||
*/
|
||||
internal class SourceCodeSpec(val type: Type, private val codeSpec: Any) {
|
||||
|
||||
/**
|
||||
* Source code type.
|
||||
*/
|
||||
enum class Type {
|
||||
Java,
|
||||
Kotlin
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the source code to the specified directory.
|
||||
* @param directory the target directory.
|
||||
*/
|
||||
@Throws(IOException::class)
|
||||
fun writeTo(directory: File) {
|
||||
when (codeSpec) {
|
||||
is JavaFile -> codeSpec.writeTo(directory)
|
||||
is FileSpec -> codeSpec.writeTo(directory)
|
||||
else -> Gropify.error("Unsupported code specification type: ${codeSpec.javaClass.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.generator.extension
|
||||
|
||||
import com.highcapable.gropify.utils.extension.isNumeric
|
||||
import com.highcapable.gropify.utils.extension.underscore
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
internal typealias PropertyMap = MutableMap<String, Any>
|
||||
internal typealias PropertyOptimizeMap = MutableMap<String, Pair<String, Any>>
|
||||
internal typealias PropertyValueRule = (value: String) -> String
|
||||
|
||||
/**
|
||||
* Create typed value from [Any] value.
|
||||
* @param autoConversion whether to enable auto conversion.
|
||||
* @return [Pair]<[KClass], [String]>
|
||||
*/
|
||||
internal fun Any.createTypedValue(autoConversion: Boolean): Pair<KClass<*>, String> {
|
||||
var isStringType = false
|
||||
val valueString = toString()
|
||||
.replace("\n", "\\n")
|
||||
.replace("\r", "\\r")
|
||||
.replace("\\", "\\\\")
|
||||
.let {
|
||||
if (autoConversion && (it.startsWith("\"") && it.endsWith("\"") || it.startsWith("'") && it.endsWith("'"))) {
|
||||
isStringType = true
|
||||
it.drop(1).dropLast(1)
|
||||
} else it.replace("\"", "\\\"")
|
||||
}
|
||||
|
||||
if (!autoConversion) return String::class to "\"$valueString\""
|
||||
|
||||
val trimmed = valueString.trim()
|
||||
val typeSpec = when {
|
||||
isStringType -> String::class
|
||||
trimmed.toBooleanStrictOrNull() != null -> Boolean::class
|
||||
trimmed.isNumeric() ->
|
||||
if (!trimmed.contains(".")) {
|
||||
val longValue = trimmed.toLongOrNull()
|
||||
when {
|
||||
longValue == null -> String::class
|
||||
longValue > Int.MAX_VALUE -> Long::class
|
||||
else -> Int::class
|
||||
}
|
||||
} else Double::class
|
||||
else -> String::class
|
||||
}
|
||||
val finalValue = when (typeSpec) {
|
||||
String::class -> "\"$valueString\""
|
||||
Long::class -> if (trimmed.endsWith("L")) trimmed else "${trimmed}L"
|
||||
else -> trimmed
|
||||
}
|
||||
|
||||
return typeSpec to finalValue
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimize property keys for code generation.
|
||||
* @receiver [PropertyMap]
|
||||
* @return [PropertyOptimizeMap]
|
||||
*/
|
||||
internal fun PropertyMap.toOptimize(): PropertyOptimizeMap {
|
||||
val newMap: PropertyOptimizeMap = mutableMapOf()
|
||||
var uniqueNumber = 1
|
||||
|
||||
forEach { (key, value) ->
|
||||
var newKey = key.replace("\\W".toRegex(), "_")
|
||||
while (newMap.containsKey(newKey))
|
||||
newKey = "$newKey${++uniqueNumber}"
|
||||
|
||||
newMap[newKey] = key to value
|
||||
}
|
||||
|
||||
return newMap
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimize property keys to underscores for code generation.
|
||||
* @receiver [PropertyOptimizeMap]
|
||||
* @return [PropertyOptimizeMap]
|
||||
*/
|
||||
internal fun PropertyOptimizeMap.toUnderscores(): PropertyOptimizeMap {
|
||||
val newMap: PropertyOptimizeMap = mutableMapOf()
|
||||
var uniqueNumber = 1
|
||||
|
||||
forEach { (key, value) ->
|
||||
var newKey = key.underscore()
|
||||
while (newMap.containsKey(newKey))
|
||||
newKey = "$newKey${++uniqueNumber}"
|
||||
|
||||
newMap[newKey] = value.first to value.second
|
||||
}
|
||||
|
||||
return newMap
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace spaces to middle dot for code generation.
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.toPoetSpace() = replace(" ", "·")
|
||||
|
||||
/**
|
||||
* Escape percentage signs for code generation.
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.toPoetNoEscape() = replace("%", "%%")
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/23.
|
||||
*/
|
||||
package com.highcapable.gropify.plugin.helper
|
||||
|
||||
import com.highcapable.gropify.gradle.api.extension.getFullName
|
||||
import com.highcapable.gropify.gradle.api.extension.getOrNull
|
||||
import com.highcapable.gropify.gradle.api.extension.hasExtension
|
||||
import com.highcapable.gropify.internal.Logger
|
||||
import com.highcapable.gropify.plugin.deployer.extension.ExtensionName
|
||||
import com.highcapable.gropify.plugin.extension.dsl.configure.GropifyConfigureExtension
|
||||
import com.highcapable.kavaref.KavaRef.Companion.asResolver
|
||||
import org.gradle.api.Project
|
||||
import tools.jackson.module.kotlin.jacksonObjectMapper
|
||||
import tools.jackson.module.kotlin.readValue
|
||||
|
||||
/**
|
||||
* Android (AGP) project helper.
|
||||
*
|
||||
* Why we need this? Because the namespace provided by AGP may become unstable
|
||||
* after the Gradle daemon is restarted, we manually maintain a file-level cache.
|
||||
*/
|
||||
internal object AndroidProjectHelper {
|
||||
|
||||
private const val ANDROID_PROJECT_NAMESPACES_FILE = "android-project-namespaces.json"
|
||||
|
||||
private val jsonMapper = jacksonObjectMapper()
|
||||
|
||||
/**
|
||||
* Get Android project namespace.
|
||||
* @receiver [Project]
|
||||
* @param project the current project.
|
||||
* @return [String] or null.
|
||||
*/
|
||||
fun getNamespace(project: Project): String? {
|
||||
// If not an Android project, return null directly.
|
||||
if (!project.hasExtension(ExtensionName.ANDROID)) return null
|
||||
|
||||
return project.getConfigNamespace()
|
||||
}
|
||||
|
||||
private fun Project.resolveNamespacesFile() =
|
||||
rootProject.file(".gradle")
|
||||
.resolve(GropifyConfigureExtension.NAME)
|
||||
.resolve(ANDROID_PROJECT_NAMESPACES_FILE)
|
||||
|
||||
private fun Project.getConfigNamespace(): String? {
|
||||
val namespacesFile = resolveNamespacesFile()
|
||||
|
||||
if (namespacesFile.parentFile?.exists() == false) namespacesFile.parentFile.mkdirs()
|
||||
if (!namespacesFile.exists()) namespacesFile.writeText("{}")
|
||||
|
||||
val namespaces = runCatching {
|
||||
jsonMapper.readValue<HashMap<String, String>>(namespacesFile)
|
||||
}.onFailure {
|
||||
// If file broken, reset it.
|
||||
namespacesFile.writeText("{}")
|
||||
Logger.warn("Android project namespaces file was broken and has been reset.")
|
||||
}.getOrDefault(hashMapOf())
|
||||
|
||||
val namespace = getExtensionNamespace()
|
||||
if (namespace != null) {
|
||||
namespaces[getFullName()] = namespace
|
||||
jsonMapper.writeValue(namespacesFile, namespaces)
|
||||
}
|
||||
|
||||
return namespace ?: namespaces[getFullName()]
|
||||
}
|
||||
|
||||
private fun Project.getExtensionNamespace(): String? {
|
||||
val extension = getOrNull(ExtensionName.ANDROID)
|
||||
|
||||
return extension?.asResolver()?.optional(silent = true)?.firstMethodOrNull {
|
||||
name = "getNamespace"
|
||||
}?.invokeQuietly<String>()?.ifBlank { null }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/20.
|
||||
*/
|
||||
package com.highcapable.gropify.utils
|
||||
|
||||
/**
|
||||
* Java keywords detector.
|
||||
*/
|
||||
internal object KeywordsDetector {
|
||||
|
||||
private val javaKeywords = setOf(
|
||||
"abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class",
|
||||
"const", "continue", "default", "do", "double", "else", "enum", "extends", "final",
|
||||
"finally", "float", "for", "goto", "if", "implements", "import", "instanceof", "int",
|
||||
"interface", "long", "native", "new", "package", "private", "protected", "public",
|
||||
"return", "short", "static", "strictfp", "super", "switch", "synchronized", "this",
|
||||
"throw", "throws", "transient", "try", "void", "volatile", "while"
|
||||
)
|
||||
|
||||
private val invalidPattern = "^(\\d.*|.*[^A-Za-z0-9_\$].*)$".toRegex()
|
||||
|
||||
/**
|
||||
* Verify if the name is a valid Java package name.
|
||||
* @param name the name to verify.
|
||||
* @return [Boolean] `true` if valid, `false` otherwise.
|
||||
*/
|
||||
fun verifyPackage(name: String) = name !in javaKeywords && !invalidPattern.matches(name) ||
|
||||
(name.contains(".") && !name.contains("..") &&
|
||||
name.split(".").all { it !in javaKeywords && !invalidPattern.matches(it) })
|
||||
|
||||
/**
|
||||
* Verify if the name is a valid Java class name.
|
||||
* @param name the name to verify.
|
||||
* @return [Boolean] `true` if valid, `false` otherwise.
|
||||
*/
|
||||
fun verifyClass(name: String) = name !in javaKeywords && !invalidPattern.matches(name)
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.gropify.utils.extension
|
||||
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Convert string path to file.
|
||||
*
|
||||
* Auto called by [parseFileSeparator].
|
||||
* @receiver [String]
|
||||
* @return [File]
|
||||
*/
|
||||
internal fun String.toFile() = File(parseFileSeparator())
|
||||
|
||||
/**
|
||||
* Format to the file delimiter of the current operating system.
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.parseFileSeparator() = replace("/", File.separator).replace("\\", File.separator)
|
||||
|
||||
/**
|
||||
* File delimiters formatted to Unix operating systems.
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.parseUnixFileSeparator() = replace("\\", "/")
|
||||
|
||||
/**
|
||||
* Check if directory is empty.
|
||||
*
|
||||
* If not a directory (possibly a file), returns true.
|
||||
*
|
||||
* If the file does not exist, returns true.
|
||||
* @receiver [File]
|
||||
* @return [Boolean]
|
||||
*/
|
||||
internal fun File.isEmpty() = !exists() || !isDirectory || listFiles().isNullOrEmpty()
|
||||
|
||||
/**
|
||||
* Delete empty subdirectories under a directory.
|
||||
* @receiver [File]
|
||||
*/
|
||||
internal fun File.deleteEmptyRecursively() {
|
||||
listFiles { file -> file.isDirectory }?.forEach { subDir ->
|
||||
subDir.deleteEmptyRecursively()
|
||||
if (subDir.listFiles()?.isEmpty() == true) subDir.delete()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
package com.highcapable.gropify.utils.extension
|
||||
|
||||
private val numericRegex = """^-?(\d+(\.\d+)?|\.\d+)$""".toRegex()
|
||||
|
||||
/**
|
||||
* Convert the current [Map] key value to string type.
|
||||
* @receiver [Map]<[K], [V]>
|
||||
* @return [Map]<[String], [String]>
|
||||
*/
|
||||
internal inline fun <reified K, V> Map<K, V>.toStringMap() = mapKeys { e -> e.key.toString() }.mapValues { e -> e.value.toString() }
|
||||
|
||||
/**
|
||||
* Remove surrounding single and double quotes from a string.
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.removeSurroundingQuotes() = removeSurrounding("\"").removeSurrounding("'")
|
||||
|
||||
/**
|
||||
* Flatten string processing.
|
||||
*
|
||||
* Remove all spaces and convert to lowercase letters.
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.flatted() = replace(" ", "").lowercase()
|
||||
|
||||
/**
|
||||
* Camelcase, "-", "." are converted to uppercase and underline names.
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.underscore() = replace(".", "_")
|
||||
.replace("-", "_")
|
||||
.replace(" ", "_")
|
||||
.replace("([a-z])([A-Z]+)".toRegex(), "$1_$2")
|
||||
.uppercase()
|
||||
|
||||
/**
|
||||
* Convert underline, separator, dot, and space named strings to camelcase named strings.
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.camelcase() = runCatching {
|
||||
split("_", ".", "-", " ").map { it.replaceFirstChar { e -> e.titlecase() } }.let { words ->
|
||||
words.first().replaceFirstChar { it.lowercase() } + words.drop(1).joinToString("")
|
||||
}
|
||||
}.getOrNull() ?: this
|
||||
|
||||
/**
|
||||
* Convert underline, separator, dot, and space named strings to camelCase named string.
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.upperCamelcase() = camelcase().capitalize()
|
||||
|
||||
/**
|
||||
* Capitalize the first letter of a string.
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.capitalize() = replaceFirstChar { it.uppercaseChar() }
|
||||
|
||||
/**
|
||||
* Lowercase the first letter of string.
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.uncapitalize() = replaceFirstChar { it.lowercaseChar() }
|
||||
|
||||
/**
|
||||
* Converts the first digit of a string to approximately uppercase letters.
|
||||
* @receiver [String]
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.firstNumberToLetter() =
|
||||
if (isNotBlank()) (mapOf(
|
||||
'0' to 'O', '1' to 'I',
|
||||
'2' to 'Z', '3' to 'E',
|
||||
'4' to 'A', '5' to 'S',
|
||||
'6' to 'G', '7' to 'T',
|
||||
'8' to 'B', '9' to 'P'
|
||||
)[first()] ?: first()) + substring(1)
|
||||
else this
|
||||
|
||||
/**
|
||||
* Whether the string is a numeric type.
|
||||
* @receiver [String]
|
||||
* @return [Boolean]
|
||||
*/
|
||||
internal fun String.isNumeric() = numericRegex.matches(this)
|
||||
|
||||
/**
|
||||
* Whether the first character of the string is a letter.
|
||||
* @receiver [String]
|
||||
* @return [Boolean]
|
||||
*/
|
||||
internal fun String.isStartsWithLetter() = firstOrNull()?.let {
|
||||
it in 'A'..'Z' || it in 'a'..'z'
|
||||
} == true
|
||||
|
||||
/**
|
||||
* Whether the interpolation symbol `${...}` exists in the string.
|
||||
* @receiver [String]
|
||||
* @return [Boolean]
|
||||
*/
|
||||
internal fun String.hasInterpolation() = contains("\${") && contains("}")
|
||||
|
||||
/**
|
||||
* Replace interpolation symbols `${...}` in a string.
|
||||
* @receiver [String]
|
||||
* @param result call the result.
|
||||
* @return [String]
|
||||
*/
|
||||
internal fun String.replaceInterpolation(result: (groupValue: String) -> CharSequence) =
|
||||
"\\$\\{(.+?)}".toRegex().replace(this) { result(it.groupValues[1]) }
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/9.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package org.gradle.kotlin.dsl
|
||||
|
||||
import com.highcapable.gropify.gradle.api.extension.configure
|
||||
import com.highcapable.gropify.gradle.api.extension.get
|
||||
import com.highcapable.gropify.plugin.extension.dsl.configure.GropifyConfigureExtension
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.initialization.Settings
|
||||
|
||||
// WORKAROUND: for some reason a type-safe accessor is not generated for the extension,
|
||||
// even though it is present in the extension container where the plugin is applied.
|
||||
// This seems to work fine, and the extension methods are only available when the plugin
|
||||
// is actually applied.
|
||||
//
|
||||
// See related link [here](https://stackoverflow.com/questions/72627792/gradle-settings-plugin-extension)
|
||||
|
||||
/**
|
||||
* Retrieves the [GropifyConfigureExtension] extension.
|
||||
* @return [GropifyConfigureExtension]
|
||||
*/
|
||||
val Settings.gropify get() = get<GropifyConfigureExtension>(GropifyConfigureExtension.NAME)
|
||||
|
||||
/**
|
||||
* Configures the [GropifyConfigureExtension] extension.
|
||||
* @param configure
|
||||
*/
|
||||
fun Settings.gropify(configure: Action<GropifyConfigureExtension>) = configure(GropifyConfigureExtension.NAME, configure)
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Gropify - A type-safe and modern properties plugin for Gradle.
|
||||
* Copyright (C) 2019 HighCapable
|
||||
* https://github.com/HighCapable/Gropify
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2025/10/18.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package org.gradle.kotlin.dsl
|
||||
|
||||
/**
|
||||
* Typealias for [com.highcapable.gropify.plugin.config.type.GropifyLocation].
|
||||
*/
|
||||
typealias GropifyLocation = com.highcapable.gropify.plugin.config.type.GropifyLocation
|
||||
16
img-src/icon.svg
Normal file
16
img-src/icon.svg
Normal file
@@ -0,0 +1,16 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="512" height="512" rx="128" fill="#434256"/>
|
||||
<path d="M165.49 165.49C215.477 115.503 296.523 115.503 346.51 165.49C396.497 215.477 396.497 296.523 346.51 346.51C334.685 358.335 321.121 367.362 306.642 373.592C303.452 374.965 299.999 372.555 299.999 369.082V339.791C299.999 337.961 301.005 336.286 302.583 335.358C309.178 331.482 315.393 326.714 321.054 321.054C356.982 285.126 356.982 226.874 321.054 190.946C285.126 155.018 226.874 155.018 190.946 190.946C155.018 226.874 155.018 285.126 190.946 321.054C196.607 326.714 202.821 331.482 209.415 335.358C210.993 336.286 211.999 337.961 211.999 339.791V369.082C211.999 372.555 208.546 374.964 205.356 373.592C190.878 367.362 177.315 358.334 165.49 346.51C115.503 296.523 115.503 215.477 165.49 165.49Z" fill="white"/>
|
||||
<path d="M235.361 102.5H276.639C280.539 102.5 283.789 105.49 284.113 109.377L286.779 141.377C287.144 145.75 283.693 149.5 279.306 149.5H232.694C228.307 149.5 224.856 145.75 225.221 141.377L227.887 109.377C228.211 105.49 231.461 102.5 235.361 102.5Z" fill="white" stroke="white"/>
|
||||
<path d="M133.661 163.046L163.046 133.661C165.765 130.942 170.101 130.72 173.084 133.147L191.006 147.735C194.453 150.541 194.719 155.712 191.576 158.855L158.854 191.576C155.712 194.719 150.541 194.454 147.735 191.006L133.147 173.084C130.72 170.101 130.942 165.765 133.661 163.046Z" fill="white" stroke="white"/>
|
||||
<path d="M378.339 163.046L348.954 133.661C346.235 130.942 341.899 130.72 338.916 133.147L320.994 147.735C317.547 150.541 317.281 155.712 320.424 158.855L353.146 191.576C356.288 194.719 361.459 194.454 364.265 191.006L378.853 173.084C381.28 170.101 381.058 165.765 378.339 163.046Z" fill="white" stroke="white"/>
|
||||
<path d="M133.659 348.96L163.044 378.345C165.763 381.064 170.098 381.286 173.081 378.859L191.004 364.271C194.451 361.465 194.716 356.294 191.574 353.151L158.852 320.43C155.709 317.287 150.538 317.552 147.732 321L133.145 338.922C130.717 341.905 130.939 346.241 133.659 348.96Z" fill="white" stroke="white"/>
|
||||
<path d="M378.336 348.96L348.951 378.345C346.231 381.064 341.896 381.286 338.913 378.858L320.989 364.27C317.542 361.464 317.277 356.293 320.42 353.15L353.141 320.429C356.284 317.286 361.455 317.551 364.261 320.998L378.849 338.922C381.277 341.905 381.055 346.24 378.336 348.96Z" fill="white" stroke="white"/>
|
||||
<path d="M409.5 235.361V276.639C409.5 280.539 406.51 283.789 402.623 284.113L370.623 286.779C366.25 287.144 362.5 283.693 362.5 279.306V232.694C362.5 228.307 366.25 224.856 370.623 225.221L402.623 227.887C406.51 228.211 409.5 231.461 409.5 235.361Z" fill="white" stroke="white"/>
|
||||
<path d="M102.5 276.639V235.361C102.5 231.461 105.49 228.211 109.377 227.887L141.377 225.221C145.75 224.856 149.5 228.307 149.5 232.694V279.306C149.5 283.693 145.75 287.144 141.377 286.779L109.377 284.113C105.49 283.789 102.5 280.539 102.5 276.639Z" fill="white" stroke="white"/>
|
||||
<path opacity="0.6" d="M280.3 398C280.3 401.727 280.3 403.591 279.691 405.062C278.879 407.022 277.322 408.579 275.361 409.391C273.891 410 272.027 410 268.3 410H243.7C239.973 410 238.109 410 236.639 409.391C234.678 408.579 233.121 407.022 232.309 405.062C231.7 403.591 231.7 401.727 231.7 398H280.3Z" fill="white"/>
|
||||
<path d="M280.3 398H231.7V263.391C236.076 267.895 245.313 271 256 271C266.687 271 275.924 267.895 280.3 263.391V398Z" fill="white"/>
|
||||
<path opacity="0.8" d="M276.976 249C278.273 249.8 279.391 250.674 280.3 251.61V263.39C275.924 267.894 266.688 271 256 271C245.313 271 236.076 267.895 231.7 263.391V251.609C232.609 250.674 233.727 249.799 235.023 249H276.976Z" fill="white"/>
|
||||
<path d="M243.315 225.463C246.767 228.298 251.185 230.001 256 230.001C260.815 230.001 265.233 228.298 268.685 225.464L277.42 244.375C279.513 248.906 280.559 251.173 280.248 253.006C280.077 254.011 279.653 254.945 279.031 255.729C278.789 256.126 278.504 256.518 278.173 256.901C276.967 258.296 275.199 259.564 272.971 260.632C270.742 261.7 268.095 262.547 265.184 263.125C262.272 263.703 259.151 264 256 264C252.848 264 249.727 263.703 246.815 263.125C243.904 262.547 241.258 261.7 239.029 260.632C236.801 259.564 235.032 258.296 233.826 256.901C233.495 256.518 233.209 256.125 232.967 255.728C232.345 254.945 231.923 254.01 231.752 253.006C231.441 251.173 232.487 248.906 234.58 244.375L243.315 225.463Z" fill="white"/>
|
||||
<path opacity="0.6" d="M253.361 206.92C255.026 206.105 256.972 206.106 258.637 206.92C260.552 207.858 261.94 210.861 264.715 216.868L268.684 225.462C265.232 228.297 260.815 229.999 256 229.999C251.184 229.999 246.766 228.297 243.314 225.461L247.284 216.868C250.059 210.861 251.446 207.858 253.361 206.92Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.6 KiB |
46
settings.gradle.kts
Normal file
46
settings.gradle.kts
Normal file
@@ -0,0 +1,46 @@
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
}
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.highcapable.gropify") version "1.0.0"
|
||||
}
|
||||
|
||||
gropify {
|
||||
global {
|
||||
jvm {
|
||||
includeKeys(
|
||||
"^project\\..*\$".toRegex(),
|
||||
"^gradle\\..*\$".toRegex()
|
||||
)
|
||||
|
||||
className = rootProject.name
|
||||
isRestrictedAccessEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
rootProject {
|
||||
common {
|
||||
isEnabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "Gropify"
|
||||
|
||||
include(":gropify-gradle-plugin")
|
||||
Reference in New Issue
Block a user