62 Commits

Author SHA1 Message Date
283444e0d5 chore: bump gradle to 8.14.3 2025-08-19 13:55:27 +08:00
b4fdbe6ad9 refactor: some tweaks in HttpFactory 2025-08-19 13:55:16 +08:00
0ae3f9a748 chore: update project files 2025-08-19 13:48:44 +08:00
a836ad9289 chore: bump dependencies 2025-08-19 13:48:36 +08:00
d04a57c549 Bump version to 1.0.8 2025-08-19 13:29:34 +08:00
308f1618ab refactor: change update checking url in PluginUpdateHelper 2025-08-19 13:25:51 +08:00
36c7af3c52 docs: update changelog, changelog-zh-CN 2025-08-19 13:05:23 +08:00
34b11eb5b7 Bump version to 1.0.7 2025-08-19 12:56:18 +08:00
72037d6f08 Merge remote-tracking branch 'origin/master' 2025-08-19 12:46:33 +08:00
cf4b59db1a Bump version to 1.0.6 2025-08-19 12:42:51 +08:00
74da386f49 refactor(fix): add custom sourceSetName and fix sourceSets conflict in PropertiesDeployHelper 2025-08-19 12:37:26 +08:00
ceccd2e2cf fix: some number type will be consistent to String in GeneratorFactory 2025-08-19 12:36:41 +08:00
Fankesyooni
22b0a1be2c Merge pull request #1 from Doddddd/master
fix: 转义属性值中的 $,避免 Javadoc 格式化异常
2025-06-27 01:28:24 +08:00
Doddddd
a16da731cf fix: 转义属性值中的 $,避免 Javadoc 格式化异常 2025-06-27 00:54:46 +08:00
99a6e02d1d docs: update README 2025-06-24 15:37:07 +08:00
9e7d5ec574 chore: bump dependencies 2025-03-17 01:07:01 +08:00
f00c6e718c chore: bump gradle to 8.13 2025-03-17 01:06:58 +08:00
1e513489c8 chore: update project files 2025-03-17 01:06:52 +08:00
fdab590578 chore: update .editorconfig 2025-03-17 01:06:48 +08:00
dd85954691 chore: update .gitignore 2025-03-17 01:06:39 +08:00
37644fcd8d docs: update license 2025-01-13 10:40:46 +08:00
341a7497ec chore: update project files 2024-11-10 19:39:52 +08:00
138551dd44 chore: bump dependencies 2024-11-10 19:39:31 +08:00
d54aebefca chore: bump gradle to 8.10.2 2024-11-10 19:39:23 +08:00
7b24cd442e chore: update .editorconfig 2024-06-21 10:17:59 +08:00
77c374d6b6 chore: update project files 2024-06-21 10:17:55 +08:00
f2bdbb8124 chore: bump dependencies 2024-06-20 13:05:16 +08:00
21d4857d5c chore: bump gradle to 8.7 2024-06-20 13:05:12 +08:00
f5ab29e6b6 chore: update .editorconfig 2024-06-20 13:05:05 +08:00
255bd4035e chore: bump dependencies 2024-02-20 10:05:19 +08:00
98ca5dbc29 chore: bump gradle to 8.6 2024-02-20 10:05:10 +08:00
91cfa2f30a chore: update .editorconfig 2024-01-13 21:32:50 +08:00
68bfcc9b5a docs: update contacts 2024-01-02 03:32:43 +08:00
3481495626 docs: update copyright date to 2024 for all existing files 2024-01-01 01:46:51 +08:00
7acba690fb style: merge to new ktlint version & rules 2023-12-29 21:26:22 +08:00
c7ec2ab836 chore: add included properties for build 2023-12-29 21:17:47 +08:00
89626aeca7 chore: specify project name in properties 2023-12-28 23:29:38 +08:00
59453292f3 chore: update .gitignore 2023-12-28 22:30:08 +08:00
c12e55dbc1 chore: merge and update to java 21 2023-12-28 21:32:05 +08:00
192d3c9a5e chore: bump gradle to 8.5 2023-12-28 21:32:00 +08:00
e5e5915618 chore: merge to new maven publish way 2023-12-28 21:05:31 +08:00
e28c9feb20 chore: update project files 2023-12-28 20:56:16 +08:00
595e3768f7 chore: bump dependencies 2023-12-28 20:56:11 +08:00
179462c0ae docs: use relative link 2023-12-11 02:29:00 +08:00
90f36ac825 chore: update project files 2023-12-11 02:23:36 +08:00
8a71e739c0 chore: bump dependency versions 2023-12-11 01:05:01 +08:00
4eaaf82430 docs: update README-zh-CN 2023-12-11 01:03:35 +08:00
ef19ea07a5 docs: update promotion 2023-11-18 18:21:56 +08:00
c98dfb6b3d chore: bump "com.highcapable.sweetdependency" version to 1.0.4 2023-11-14 00:39:20 +08:00
a978baa1fe Bump version to 1.0.5 2023-11-08 14:52:10 +08:00
93c8107e76 fix: special or repeat chars cause code generation failed 2023-11-08 14:50:49 +08:00
5d5c3af69a Bump version to 1.0.4 2023-11-04 02:19:28 +08:00
87143b99c4 chore: update project files 2023-11-04 02:19:00 +08:00
ec03595552 chore: bump "com.highcapable.sweetdependency" version to 1.0.3 2023-11-04 02:18:02 +08:00
33abb4bafa refactor: replace not to ! 2023-11-04 02:10:46 +08:00
2337d5710b docs: update guide 2023-11-04 02:10:46 +08:00
1bf1a030dc feat: add multiple projects configure function 2023-11-04 02:10:45 +08:00
6c5835bc72 feat: remove auto conversion if it's an interpolation 2023-11-04 02:10:45 +08:00
d9c8c5dc84 fix: like "a=some", "a_b=some" style's property key name will fail on build 2023-11-04 02:10:44 +08:00
d2aed2120e feat: use @Nonnull better for Kotlin code 2023-11-03 23:10:53 +08:00
67c79a591c chore: update dependencies 2023-11-03 23:03:37 +08:00
fe1c8594c8 docs: update promotion 2023-10-24 22:23:53 +08:00
50 changed files with 521 additions and 363 deletions

View File

@@ -10,6 +10,24 @@ 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

117
.gitignore vendored
View File

@@ -1,13 +1,110 @@
## 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
.gradle
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
*.ipr
# Kotlin
.kotlin
# Misc
.idea/misc.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
**/local.properties
/captures
.externalNativeBuild
.cxx
.cxx
# Gradle projects
.gradle
build/
# Mkdocs temporary serving folder
docs-gen
site
*.bak
.idea/appInsightsSettings.xml
# Mac OS
.DS_Store

10
.idea/.gitignore generated vendored
View File

@@ -1,10 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
/gradle.xml
/misc.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

6
.idea/compiler.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="17" />
</component>
</project>

View File

@@ -1,6 +1,7 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="CheckImageSize" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ReplaceUntilWithRangeUntil" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenRepo" />
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
</component>
</project>

2
.idea/kotlinc.xml generated
View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="1.9.10" />
<option name="version" value="2.2.10" />
</component>
</project>

7
.idea/ktlint-plugin.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KtLint plugin">
<ktlintMode>MANUAL</ktlintMode>
<formatOnSave>false</formatOnSave>
</component>
</project>

6
.idea/markdown.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownSettings">
<option name="showProblemsInCodeBlocks" value="false" />
</component>
</project>

124
.idea/uiDesigner.xml generated
View File

@@ -1,124 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@@ -1,14 +1,20 @@
# Sweet Property
[![GitHub license](https://img.shields.io/github/license/HighCapable/SweetProperty?color=blue)](https://github.com/HighCapable/SweetProperty/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/v/release/HighCapable/SweetProperty?display_name=release&logo=github&color=green)](https://github.com/HighCapable/SweetProperty/releases)
[![Telegram](https://img.shields.io/badge/discussion-Telegram-blue.svg?logo=telegram)](https://t.me/HighCapable_Dev)
[![GitHub license](https://img.shields.io/github/license/HighCapable/SweetProperty?color=blue&style=flat-square)](https://github.com/HighCapable/SweetProperty/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/v/release/HighCapable/SweetProperty?display_name=release&logo=github&color=green&style=flat-square)](https://github.com/HighCapable/SweetProperty/releases)
[![Telegram](https://img.shields.io/badge/discussion-Telegram-blue.svg?logo=telegram&style=flat-square)](https://t.me/HighCapable_Dev)
[![QQ](https://img.shields.io/badge/discussion-QQ-blue.svg?logo=tencent-qq&logoColor=red&style=flat-square)](https://qm.qq.com/cgi-bin/qm/qr?k=Pnsc5RY6N2mBKFjOLPiYldbAbprAU3V7&jump_from=webapi&authKey=X5EsOVzLXt1dRunge8ryTxDRrh9/IiW1Pua75eDLh9RE3KXE+bwXIYF5cWri/9lf)
<img src="https://github.com/HighCapable/SweetProperty/blob/master/img-src/icon.png?raw=true" width = "100" height = "100" alt="LOGO"/>
<img src="img-src/icon.png" width = "100" height = "100" alt="LOGO"/>
一个轻松在任意地方获取项目属性的 Gradle 插件。
[English](https://github.com/HighCapable/SweetProperty/blob/master/README.md) | 简体中文
[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) |
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
这个项目属于上述组织,**点击上方链接关注这个组织**,发现更多好项目。
## 这是什么
@@ -38,11 +44,11 @@
## 开始使用
- [点击这里](https://github.com/HighCapable/SweetProperty/blob/master/docs/guide-zh-CN.md) 查看使用文档
- [点击这里](docs/guide-zh-CN.md) 查看使用文档
## 更新日志
- [点击这里](https://github.com/HighCapable/SweetProperty/blob/master/docs/changelog-zh-CN.md) 查看历史更新日志
- [点击这里](docs/changelog-zh-CN.md) 查看历史更新日志
## 项目推广
@@ -50,11 +56,14 @@
本项目同样使用了 **SweetDependency**
## 捐赠支持
工作不易,无意外情况此项目将继续维护下去,提供更多可能,欢迎打赏。
<img src="https://github.com/fankes/fankes/blob/main/img-src/payment_code.jpg?raw=true" width = "500" alt="Payment Code"/>
<!--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
@@ -67,7 +76,7 @@
```
Apache License Version 2.0
Copyright (C) 2019-2023 HighCapable
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.
@@ -82,4 +91,4 @@ See the License for the specific language governing permissions and
limitations under the License.
```
版权所有 © 2019-2023 HighCapable
版权所有 © 2019 HighCapable

View File

@@ -1,14 +1,20 @@
# Sweet Property
[![GitHub license](https://img.shields.io/github/license/HighCapable/SweetProperty?color=blue)](https://github.com/HighCapable/SweetProperty/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/v/release/HighCapable/SweetProperty?display_name=release&logo=github&color=green)](https://github.com/HighCapable/SweetProperty/releases)
[![Telegram](https://img.shields.io/badge/discussion-Telegram-blue.svg?logo=telegram)](https://t.me/HighCapable_Dev)
[![GitHub license](https://img.shields.io/github/license/HighCapable/SweetProperty?color=blue&style=flat-square)](https://github.com/HighCapable/SweetProperty/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/v/release/HighCapable/SweetProperty?display_name=release&logo=github&color=green&style=flat-square)](https://github.com/HighCapable/SweetProperty/releases)
[![Telegram](https://img.shields.io/badge/discussion-Telegram-blue.svg?logo=telegram&style=flat-square)](https://t.me/HighCapable_Dev)
[![QQ](https://img.shields.io/badge/discussion-QQ-blue.svg?logo=tencent-qq&logoColor=red&style=flat-square)](https://qm.qq.com/cgi-bin/qm/qr?k=Pnsc5RY6N2mBKFjOLPiYldbAbprAU3V7&jump_from=webapi&authKey=X5EsOVzLXt1dRunge8ryTxDRrh9/IiW1Pua75eDLh9RE3KXE+bwXIYF5cWri/9lf)
<img src="https://github.com/HighCapable/SweetProperty/blob/master/img-src/icon.png?raw=true" width = "100" height = "100" alt="LOGO"/>
<img src="img-src/icon.png" width = "100" height = "100" alt="LOGO"/>
An easy get project properties anywhere Gradle plugin.
English | [简体中文](https://github.com/HighCapable/SweetProperty/blob/master/README-zh-CN.md)
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
@@ -43,11 +49,11 @@ Some functions may be incompatible, support will be gradually dropped in the fut
## Get Started
- [Click here](https://github.com/HighCapable/SweetProperty/blob/master/docs/guide.md) to view the documentation
- [Click here](docs/guide.md) to view the documentation
## Changelog
- [Click here](https://github.com/HighCapable/SweetProperty/blob/master/docs/changelog.md) to view the historical changelog
- [Click here](docs/changelog.md) to view the historical changelog
## Promotion
@@ -56,6 +62,15 @@ you can check out the [SweetDependency](https://github.com/HighCapable/SweetDepe
This project also uses **SweetDependency**.
<!--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
![Star History Chart](https://api.star-history.com/svg?repos=HighCapable/SweetProperty&type=Date)
@@ -67,7 +82,7 @@ This project also uses **SweetDependency**.
```
Apache License Version 2.0
Copyright (C) 2019-2023 HighCapable
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.
@@ -82,4 +97,4 @@ See the License for the specific language governing permissions and
limitations under the License.
```
Copyright © 2019-2023 HighCapable
Copyright © 2019 HighCapable

View File

@@ -1,16 +1,4 @@
plugins {
autowire(libs.plugins.kotlin.jvm) apply false
}
allprojects {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = listOf(
"-Xno-param-assertions",
"-Xno-call-assertions",
"-Xno-receiver-assertions"
)
}
}
autowire(libs.plugins.maven.publish) apply false
}

View File

@@ -26,4 +26,25 @@
- 修复在全局配置中使用过其它配置方法后,子项目的 `all` 方法失效问题
- 改进并采用 Gradle 项目命名规范
- 新增插件自身检查更新功能
- 一些其它功能性的改进
- 一些其它功能性的改进
## 1.0.4 | 2023.11.04
- 修复类似 `a=some``a_b=some` 的属性键值名称会造成重复方法名称的问题
- 修复使用 `${...}` 生成的插值内容依然会携带字符串类型引号问题
- 生成的代码使用 `@Nonnull` 标记以使其能够在 Kotlin DSL 脚本中识别为非空返回值类型
- 新增 `project(...)` 配置方法支持同时配置多个项目
- 一些其它功能性的改进
## 1.0.5 | 2023.11.08
- 修复遇到特殊字符和重复键值名称造成代码生成失败的严重问题
## 1.0.8 | 2025.08.19
- 修复在新版 Android Gradle Plugin 及 Android Studio/IDEA 中部署源码路径时的错误
`removeContentEntry: removed content entry url 'build/generated/sweet-property' still exists after removing`
- 新增 `sourceSetName` 方法,允许自定义要部署的源集名称
- 修复在类型自动转换过程中某些 `commit id` 和 Hash 可能被识别为数值类型的问题
- 合并 [#1](https://github.com/HighCapable/SweetProperty/pull/1) 并重新发布版本 (1.0.6)
- 修复由于 OSS 存储库被弃用导致重复提示检查更新的问题 (1.0.7)

View File

@@ -27,4 +27,25 @@
- Fix `all` function of the sub-project fails after using other configuration functions in the global configuration
- Improve and adopt Gradle project naming convention
- Added plugin own update function
- Some other functional improvements
- Some other functional improvements
## 1.0.4 | 2023.11.04
- Fix the issue where attribute key value names like `a=some` and `a_b=some` would cause duplicate method names
- Fix the problem that the interpolation content generated using `${...}` still carries string type quotes
- Generated code is marked with `@Nonnull` to make it recognized as a non-null return type in Kotlin DSL scripts
- Added `project(...)` configuration method to support configuring multiple projects at the same time
- Some other functional improvements
## 1.0.5 | 2023.11.08
- Fix a serious issue that caused code generation failure when encountering special characters and duplicate key-value names
## 1.0.8 | 2025.08.19
- Fix errors when deploying source code paths in the new version of Android Gradle Plugin and Android Studio/IDEA
`removeContentEntry: removed content entry url 'build/generated/sweet-property' still exists after removing`
- Added the `sourceSetName` method to allow customization of the source set name to be deployed
- Fix an issue where some `commit id` and Hash might be recognized as numeric types during the automatic type conversion process
- Merge [#1](https://github.com/HighCapable/SweetProperty/pull/1) and re-release version (1.0.6)
- Fix a duplicate prompt for updates due to deprecating the OSS repository (1.0.7)

View File

@@ -155,6 +155,10 @@ sweetProperty {
// 默认为 "build/generated/sweet-property"
// 建议将生成的代码放置于 "build" 目录下,因为生成的代码不建议去修改它
generateDirPath = "build/generated/sweet-property"
// 自定义部署的 `sourceSet` 名称
// 如果你的项目源码部署名称不是默认值,可以在这里自定义
// 默认为 "main"
sourceSetName = "main"
// 自定义生成的包名
// Android 项目默认使用 "android" 配置方法块中的 "namespace"
// 普通的 Kotlin on Jvm 项目默认使用项目设置的 "project.group"
@@ -213,6 +217,19 @@ sweetProperty {
// 配置 "buildScript"
}
}
// 同时进行多个项目与子项目配置
// 在方法参数中填入需要配置的项目完整名称数组来配置每个对应的项目
project(":modules:library1", ":modules:library2") {
all {
// 配置 "all"
}
sourcesCode {
// 配置 "sourcesCode"
}
buildScript {
// 配置 "buildScript"
}
}
}
```

View File

@@ -168,6 +168,10 @@ sweetProperty {
// It is recommended to place the generated code in the "build" directory,
// because the generated code is not recommended to be modified
generateDirPath = "build/generated/sweet-property"
// Custom deployed `sourceSet` name
// If your project source code deployment name is not the default value, you can customize it here
// Defaults to "main"
sourceSetName = "main"
// Custom generated package name
// Android projects use the "namespace" in the "android" configuration method block by default
// Ordinary Kotlin on Jvm projects use the "project.group" of the project settings by default
@@ -227,7 +231,20 @@ sweetProperty {
// Configure "buildScript"
}
}
}
// Configure multiple projects and sub-projects at the same time
// Fill in the method parameters with the array of complete names of the projects that need to be configured
// to configure each corresponding project
project(":modules:library1", ":modules:library2") {
all {
// Configure "all"
}
sourcesCode {
// Configure "sourcesCode"
}
buildScript {
// Configure "buildScript"
}
}
```
If you want to use it in Groovy DSL, please change the `=` of all variables to spaces, delete the `is` in front of `Enable` and lowercase `E`.

View File

@@ -1,19 +1,27 @@
# Project Configuration
project.name=SweetProperty
project.description=An easy get project properties anywhere Gradle plugin.
project.url=https://github.com/HighCapable/SweetProperty
project.groupName=com.highcapable.sweetproperty
project.moduleName=sweet-property
project.version=1.0.3
project.licence.name=Apache License 2.0
project.licence.url=https://github.com/HighCapable/SweetProperty/blob/master/LICENSE
project.developer.id="0"
project.developer.name=fankes
project.developer.email=qzmmcn@163.com
project.version=1.0.8
# Gradle Plugin Configuration
gradle.plugin.moduleName=${project.groupName}.gradle.plugin
gradle.plugin.implementationClass=${project.groupName}.plugin.SweetPropertyPlugin
# Maven Publish Configuration
maven.publish.scm.connection=scm:git:git://github.com/HighCapable/SweetProperty
maven.publish.scm.developerConnection=scm:git:ssh://github.com/HighCapable/SweetProperty
maven.publish.scm.url=https://github.com/HighCapable/SweetProperty
SONATYPE_HOST=CENTRAL_PORTAL
RELEASE_SIGNING_ENABLED=true
# Maven POM Configuration
POM_NAME=SweetProperty
POM_ARTIFACT_ID=sweet-property
POM_DESCRIPTION=An easy get project properties anywhere Gradle plugin.
POM_URL=https://github.com/HighCapable/SweetProperty
POM_LICENSE_NAME=Apache License 2.0
POM_LICENSE_URL=https://github.com/HighCapable/SweetProperty/blob/master/LICENSE
POM_LICENSE_DIST=repo
POM_SCM_URL=https://github.com/HighCapable/SweetProperty
POM_SCM_CONNECTION=scm:git:git://github.com/HighCapable/SweetProperty
POM_SCM_DEV_CONNECTION=scm:git:ssh://github.com/HighCapable/SweetProperty
POM_DEVELOPER_ID=0
POM_DEVELOPER_NAME=fankes
POM_DEVELOPER_EMAIL=qzmmcn@163.com
POM_DEVELOPER_URL=https://github.com/fankes

View File

@@ -12,18 +12,18 @@ repositories:
plugins:
org.jetbrains.kotlin.jvm:
alias: kotlin-jvm
version: 1.9.10
version: 2.2.10
com.vanniktech.maven.publish:
alias: maven-publish
version: 0.25.3
version: 0.34.0
libraries:
com.squareup.okhttp3:
okhttp:
version: 4.11.0
version: 5.1.0
com.squareup:
kotlinpoet:
version: 1.14.2
version: 2.2.0
javapoet:
version: 1.13.0
net.lingala.zip4j:

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -7,8 +7,8 @@ pluginManagement {
}
}
plugins {
id("com.highcapable.sweetdependency") version "1.0.2"
id("com.highcapable.sweetproperty") version "1.0.3"
id("com.highcapable.sweetdependency") version "1.0.4"
id("com.highcapable.sweetproperty") version "1.0.8"
}
sweetDependency {
isEnableVerboseMode = false
@@ -17,6 +17,10 @@ sweetProperty {
global {
sourcesCode {
className = rootProject.name
includeKeys(
"^project\\..*\$".toRegex(),
"^gradle\\..*\$".toRegex()
)
isEnableRestrictedAccess = true
}
}

View File

@@ -1,2 +0,0 @@
.gradle
build/

View File

@@ -4,20 +4,25 @@ plugins {
autowire(libs.plugins.maven.publish)
}
allprojects {
group = property.project.groupName
version = property.project.version
}
group = property.project.groupName
version = property.project.version
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
withSourcesJar()
}
kotlin {
jvmToolchain(17)
jvmToolchain(21)
sourceSets.all { languageSettings { languageVersion = "2.0" } }
compilerOptions {
freeCompilerArgs = listOf(
"-Xno-param-assertions",
"-Xno-call-assertions",
"-Xno-receiver-assertions"
)
}
}
dependencies {
@@ -34,34 +39,4 @@ gradlePlugin {
implementationClass = property.gradle.plugin.implementationClass
}
}
}
mavenPublishing {
coordinates(property.project.groupName, property.project.moduleName, property.project.version)
pom {
name = property.project.name
description = property.project.description
url = property.project.url
licenses {
license {
name = property.project.licence.name
url = property.project.licence.url
distribution = property.project.licence.url
}
}
developers {
developer {
id = property.project.developer.id
name = property.project.developer.name
email = property.project.developer.email
}
}
scm {
url = property.maven.publish.scm.url
connection = property.maven.publish.scm.connection
developerConnection = property.maven.publish.scm.developerConnection
}
}
publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.S01)
signAllPublications()
}

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -48,7 +48,7 @@ internal class ProjectDescriptor private constructor() {
it.type = Type.SETTINGS
it.name = name.noBlank() ?: settings.rootProject.name
it.currentDir = (if (isRootProject) settings.rootProject else settings.findProject(name))?.projectDir
?: SError.make("Project \"$name\" not found${if (name.startsWith(":").not()) ", $subProjectNotice" else ""}")
?: SError.make("Project \"$name\" not found${if (!name.startsWith(":")) ", $subProjectNotice" else ""}")
it.rootDir = settings.rootDir
it.homeDir = settings.gradle.gradleUserHomeDir
}

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -37,7 +37,7 @@ import org.gradle.api.plugins.ExtensionAware
*/
internal fun ExtensionAware.getOrCreate(name: String, clazz: Class<*>, vararg args: Any?) = name.toSafeExtName().let { sName ->
runCatching { extensions.create(sName, clazz, *args).asExtension() }.getOrElse {
if ((it is IllegalArgumentException && it.message?.startsWith("Cannot add extension with name") == true).not()) throw it
if (!(it is IllegalArgumentException && it.message?.startsWith("Cannot add extension with name") == true)) throw it
runCatching { extensions.getByName(sName).asExtension() }.getOrNull() ?: SError.make("Create or get extension failed with name \"$sName\"")
}
}
@@ -50,7 +50,7 @@ internal fun ExtensionAware.getOrCreate(name: String, clazz: Class<*>, vararg ar
*/
internal inline fun <reified T> ExtensionAware.getOrCreate(name: String, vararg args: Any?) = name.toSafeExtName().let { sName ->
runCatching { extensions.create(sName, T::class.java, *args) as T }.getOrElse {
if ((it is IllegalArgumentException && it.message?.startsWith("Cannot add extension with name") == true).not()) throw it
if (!(it is IllegalArgumentException && it.message?.startsWith("Cannot add extension with name") == true)) throw it
runCatching { extensions.getByName(sName) as? T? }.getOrNull() ?: SError.make("Create or get extension failed with name \"$sName\"")
}
}

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -44,7 +44,7 @@ internal fun Project.fullName(isUseColon: Boolean = true): String {
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 (isUseColon && isRoot.not()) it else it.drop(1) }
return buildString { baseNames.onEach { append(":$it") }.clear() }.let { if (isUseColon && !isRoot) it else it.drop(1) }
}
/**

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -56,6 +56,7 @@ internal object DefaultConfigs {
) = object : ISweetPropertyConfigs.ISourcesCodeGenerateConfigs {
override val name get() = name
override val generateDirPath get() = ISweetPropertyConfigs.DEFAULT_GENERATE_DIR_PATH
override val sourceSetName get() = ISweetPropertyConfigs.DEFAULT_SOURCE_SET_NAME
override val packageName get() = ""
override val className get() = ""
override val isEnableRestrictedAccess get() = false

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -74,6 +74,10 @@ private fun SweetPropertyConfigureExtension.SourcesCodeGenerateConfigureExtensio
get() = this@create.generateDirPath.noBlank()
?: global?.generateDirPath?.noBlank()
?: DefaultConfigs.sourcesCodeGenerateConfigs(name, selfBase, globalBase).generateDirPath
override val sourceSetName
get() = this@create.sourceSetName.noBlank()
?: global?.sourceSetName?.noBlank()
?: DefaultConfigs.sourcesCodeGenerateConfigs(name, selfBase, globalBase).sourceSetName
override val packageName
get() = this@create.packageName.noBlank()
?: global?.packageName?.noBlank()

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -40,6 +40,11 @@ internal interface ISweetPropertyConfigs {
*/
internal const val DEFAULT_GENERATE_DIR_PATH = "build/generated/${SweetPropertyProperties.PROJECT_MODULE_NAME}"
/**
* 默认的部署 `sourceSet` 名称
*/
internal const val DEFAULT_SOURCE_SET_NAME = "main"
/**
* 默认的属性配置文件名称
*
@@ -91,6 +96,9 @@ internal interface ISweetPropertyConfigs {
/** 自定义生成的目录路径 */
val generateDirPath: String
/** 自定义部署的 `sourceSet` 名称 */
val sourceSetName: String
/** 自定义生成的包名 */
val packageName: String

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -95,11 +95,11 @@ open class SweetPropertyConfigureExtension internal constructor() {
fun rootProject(action: Action<SubConfigureExtension>) = configureProject(ROOT_PROJECT_TAG, action)
/**
* 配置指定项目
* @param name 项目完整名称
* 配置指定项目 (数组)
* @param names 项目完整名称 (数组)
* @param action 配置方法体
*/
fun project(name: String, action: Action<SubConfigureExtension>) = configureProject(name, action)
fun project(vararg names: String, action: Action<SubConfigureExtension>) = names.forEach { configureProject(it, action) }
/**
* 配置项目
@@ -173,6 +173,16 @@ open class SweetPropertyConfigureExtension internal constructor() {
var generateDirPath = ""
@JvmName("generateDirPath") set
/**
* 自定义部署的 `sourceSet` 名称
*
* 如果你的项目源码部署名称不是默认值 - 可以在这里自定义
*
* 默认为 [ISweetPropertyConfigs.DEFAULT_SOURCE_SET_NAME]
*/
var sourceSetName = ""
@JvmName("sourceSetName") set
/**
* 自定义生成的包名
*
@@ -474,13 +484,13 @@ open class SweetPropertyConfigureExtension internal constructor() {
/** 检查合法包名 */
fun String.checkingValidPackageName() {
if (isNotBlank() && matches("^[a-zA-Z_][a-zA-Z0-9_]*(\\.[a-zA-Z_][a-zA-Z0-9_]*)*$".toRegex()).not())
if (isNotBlank() && !matches("^[a-zA-Z_][a-zA-Z0-9_]*(\\.[a-zA-Z_][a-zA-Z0-9_]*)*$".toRegex()))
SError.make("Invalid package name \"$this\"")
}
/** 检查合法类名 */
fun String.checkingValidClassName() {
if (isNotBlank() && matches("^[a-zA-Z][a-zA-Z0-9_]*$".toRegex()).not())
if (isNotBlank() && !matches("^[a-zA-Z][a-zA-Z0-9_]*$".toRegex()))
SError.make("Invalid class name \"$this\"")
}

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -27,6 +27,7 @@ import com.highcapable.sweetproperty.plugin.config.proxy.ISweetPropertyConfigs
import com.highcapable.sweetproperty.plugin.extension.accessors.proxy.IExtensionAccessors
import com.highcapable.sweetproperty.plugin.generator.factory.PropertyMap
import com.highcapable.sweetproperty.plugin.generator.factory.parseTypedValue
import com.highcapable.sweetproperty.plugin.generator.factory.toOptimize
import com.highcapable.sweetproperty.utils.capitalize
import com.highcapable.sweetproperty.utils.debug.SError
import com.highcapable.sweetproperty.utils.firstNumberToLetter
@@ -40,6 +41,7 @@ import com.squareup.javapoet.MethodSpec
import com.squareup.javapoet.TypeSpec
import java.text.SimpleDateFormat
import java.util.*
import javax.annotation.Nonnull
import javax.lang.model.element.Modifier
import kotlin.properties.Delegates
@@ -84,6 +86,9 @@ internal class PropertiesAccessorsGenerator {
/** 生成的属性键值连续名称重复次数数组 */
private val grandSuccessiveDuplicateIndexs = mutableMapOf<String, Int>()
/** 生成的属性键值不重复调用方法数组 */
private val usedSuccessiveMethods = mutableMapOf<String, MutableList<String>>()
/** 生成的属性键值不重复 TAG 数组 */
private val usedSuccessiveTags = mutableSetOf<String>()
@@ -94,7 +99,7 @@ internal class PropertiesAccessorsGenerator {
*/
private inline fun noRepeated(vararg tags: String, block: () -> Unit) {
val allTag = tags.joinToString("-")
if (usedSuccessiveTags.contains(allTag).not()) block()
if (!usedSuccessiveTags.contains(allTag)) block()
usedSuccessiveTags.add(allTag)
}
@@ -177,9 +182,10 @@ internal class PropertiesAccessorsGenerator {
*/
private fun TypeSpec.Builder.addSuccessiveMethod(accessorsName: String, methodName: String, className: String) =
addMethod(
MethodSpec.methodBuilder("get${methodName.capitalize()}")
MethodSpec.methodBuilder("get${getOrCreateUsedSuccessiveMethodName(methodName, className).capitalize()}")
.addJavadoc("Resolve the \"$accessorsName\" accessors")
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addAnnotation(Nonnull::class.java)
.returns(className.capitalized().asClassType())
.addStatement("return ${className.uncapitalized()}")
.build()
@@ -189,17 +195,20 @@ internal class PropertiesAccessorsGenerator {
* 向通用构建器描述类添加最终键值方法
* @param accessorsName 接续名
* @param methodName 方法名
* @param className 类名
* @param value 键值内容
* @return [TypeSpec.Builder]
*/
private fun TypeSpec.Builder.addFinalValueMethod(accessorsName: String, methodName: String, value: Any) =
private fun TypeSpec.Builder.addFinalValueMethod(accessorsName: String, methodName: String, className: String, value: Any) =
addMethod(
MethodSpec.methodBuilder("get${methodName.capitalize()}").apply {
MethodSpec.methodBuilder("get${getOrCreateUsedSuccessiveMethodName(methodName, className).capitalize()}").apply {
val typedValue = value.parseTypedValue(configs.isEnableTypeAutoConversion)
addJavadoc("Resolve the \"$accessorsName\" value ${typedValue.second}")
val safeValueForJavadoc = typedValue.second.replace("$", "$$")
addJavadoc("Resolve the \"$accessorsName\" value $safeValueForJavadoc")
addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addAnnotation(Nonnull::class.java)
.returns(typedValue.first.java)
.addStatement("return ${typedValue.second}")
.addStatement("return $safeValueForJavadoc")
}.build()
)
@@ -211,6 +220,20 @@ internal class PropertiesAccessorsGenerator {
private fun MethodSpec.Builder.addSuccessiveStatement(className: String) =
addStatement("${className.uncapitalized()} = new ${className.capitalized()}()")
/**
* 获取不重复调用方法名称
* @param methodName 方法名
* @param className 类名
* @return [String]
*/
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
}
/**
* 获取、创建通用构建器描述类
* @param name 名称
@@ -234,9 +257,10 @@ internal class PropertiesAccessorsGenerator {
*
* 解析完成后需要调用 [releaseParseTypeSpec] 完成解析
* @param successiveName 连续的名称
* @param key 键值名称 (原始名称)
* @param value 键值内容
*/
private fun parseTypeSpec(successiveName: String, value: Any) {
private fun parseTypeSpec(successiveName: String, key: String, value: Any) {
/**
* 获取生成的属性键值连续名称重复次数
* @return [Int]
@@ -258,10 +282,7 @@ internal class PropertiesAccessorsGenerator {
var grandAcccessorsName = ""
var grandSuccessiveName = ""
val successiveNames = mutableListOf<Triple<String, String, String>>()
val splitNames = replace(".", "|").replace("-", "|")
.replace("_", "|").replace(" ", "_")
.split("|").dropWhile { it.isBlank() }
.ifEmpty { listOf(this) }
val splitNames = split("_").dropWhile { it.isBlank() }.ifEmpty { listOf(this) }
splitNames.forEach { eachName ->
val name = eachName.capitalize().toNonJavaName().firstNumberToLetter()
grandAcccessorsName += if (grandAcccessorsName.isNotBlank()) ".$eachName" else eachName
@@ -279,9 +300,10 @@ internal class PropertiesAccessorsGenerator {
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).addFinalValueMethod(successiveName, methodName, value)
if (successiveNames.size == 1) getOrCreateClassSpec(TOP_SUCCESSIVE_NAME).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)
@@ -291,12 +313,12 @@ internal class PropertiesAccessorsGenerator {
}
noRepeated(className, nextMethodName, nextClassName) {
getOrCreateClassSpec(className, accessorsName).apply {
if (isPreLastIndex.not()) {
if (!isPreLastIndex) {
addSuccessiveField(nextAccessorsName, nextClassName)
addSuccessiveMethod(nextAccessorsName, nextMethodName, nextClassName)
} else addFinalValueMethod(successiveName, lastMethodName, value)
} else addFinalValueMethod(key, lastMethodName, lastClassName, value)
}
if (isPreLastIndex.not()) preAddConstructorSpecNames.add(className to nextClassName)
if (!isPreLastIndex) preAddConstructorSpecNames.add(className to nextClassName)
}
}
}
@@ -342,6 +364,7 @@ internal class PropertiesAccessorsGenerator {
preAddConstructorSpecNames.clear()
grandSuccessiveNames.clear()
grandSuccessiveDuplicateIndexs.clear()
usedSuccessiveMethods.clear()
usedSuccessiveTags.clear()
if (isClearAll) memoryExtensionClasses.clear()
}
@@ -367,8 +390,8 @@ internal class PropertiesAccessorsGenerator {
val keyValues = allKeyValues[index]
clearGeneratedData()
createTopClassSpec(configs)
keyValues.forEach { (key, value) ->
parseTypeSpec(key, value)
keyValues.toOptimize().forEach { (key, value) ->
parseTypeSpec(key, value.first, value.second)
releaseParseTypeSpec()
}; files.add(buildTypeSpec().createJavaFile(ACCESSORS_PACKAGE_NAME))
}; files
@@ -380,10 +403,15 @@ internal class PropertiesAccessorsGenerator {
*/
internal val compileStubFiles get(): List<JavaFile> {
val stubFiles = mutableListOf<JavaFile>()
val nonnullFile =
TypeSpec.annotationBuilder(Nonnull::class.java.simpleName)
.addModifiers(Modifier.PUBLIC)
.build().createJavaFile(Nonnull::class.java.packageName)
val iExtensionAccessorsFile =
TypeSpec.interfaceBuilder(IExtensionAccessors::class.java.simpleName)
.addModifiers(Modifier.PUBLIC)
.build().createJavaFile(IExtensionAccessors::class.java.packageName)
stubFiles.add(nonnullFile)
stubFiles.add(iExtensionAccessorsFile)
return stubFiles
}

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -25,9 +25,10 @@ import com.highcapable.sweetproperty.SweetProperty
import com.highcapable.sweetproperty.plugin.config.proxy.ISweetPropertyConfigs
import com.highcapable.sweetproperty.plugin.generator.factory.PropertyMap
import com.highcapable.sweetproperty.plugin.generator.factory.parseTypedValue
import com.highcapable.sweetproperty.plugin.generator.factory.toOptimize
import com.highcapable.sweetproperty.plugin.generator.factory.toUnderscores
import com.highcapable.sweetproperty.utils.debug.SError
import com.highcapable.sweetproperty.utils.firstNumberToLetter
import com.highcapable.sweetproperty.utils.underscore
import com.squareup.kotlinpoet.FileSpec
import com.squareup.kotlinpoet.KModifier
import com.squareup.kotlinpoet.PropertySpec
@@ -67,13 +68,13 @@ internal class PropertiesSourcesGenerator {
""".trimIndent()
)
if (configs.isEnableRestrictedAccess) addModifiers(KModifier.INTERNAL)
keyValues.forEach { (key, value) ->
val typedValue = value.parseTypedValue(configs.isEnableTypeAutoConversion)
addProperty(PropertySpec.builder(key.firstNumberToLetter().underscore(), typedValue.first).apply {
addKdoc("Resolve the \"$key\" value ${typedValue.second}")
keyValues.toOptimize().toUnderscores().forEach { (key, value) ->
val typedValue = value.second.parseTypedValue(configs.isEnableTypeAutoConversion)
addProperty(PropertySpec.builder(key.firstNumberToLetter(), typedValue.first).apply {
addKdoc("Resolve the \"${value.first.toKotlinPoetNoEscape()}\" value ${typedValue.second.toKotlinPoetNoEscape()}")
if (configs.isEnableRestrictedAccess) addModifiers(KModifier.INTERNAL)
addModifiers(KModifier.CONST)
initializer(typedValue.second.toKotlinPoetSpace())
initializer(typedValue.second.toKotlinPoetNoEscape().toKotlinPoetSpace())
}.build())
}
}.build())
@@ -85,4 +86,10 @@ internal class PropertiesSourcesGenerator {
* @return [String]
*/
private fun String.toKotlinPoetSpace() = replace(" ", "·")
/**
* 转换到 KotlinPoet 非转义字符内容
* @return [String]
*/
private fun String.toKotlinPoetNoEscape() = replace("%", "%%")
}

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -21,14 +21,24 @@
*/
package com.highcapable.sweetproperty.plugin.generator.factory
import com.highcapable.sweetproperty.utils.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
/**
* 移除键值内容自动转换类型的引号
* @return [String]
*/
internal fun String.removeAutoConversion() = removeSurrounding("\"").removeSurrounding("'")
/**
* 解析到键值内容类型
* @param isAutoConversion 是否自动转换类型
@@ -46,16 +56,50 @@ internal fun Any.parseTypedValue(isAutoConversion: Boolean): Pair<KClass<*>, Str
it.drop(1).dropLast(1)
} else it.replace("\"", "\\\"")
}
if (isAutoConversion.not()) return Pair(String::class, "\"$valueString\"")
if (!isAutoConversion) return Pair(String::class, "\"$valueString\"")
val trimmed = valueString.trim()
val typeSpec = when {
isStringType -> String::class
valueString.trim().toIntOrNull() != null -> Int::class
valueString.trim().toLongOrNull() != null -> Long::class
valueString.trim().toDoubleOrNull() != null -> Double::class
valueString.trim().toFloatOrNull() != null -> Float::class
valueString.trim() == "true" || valueString.trim() == "false" -> Boolean::class
isStringType || trimmed.any { !it.isDigit() && it != '.' && it != '-' } -> String::class
trimmed.toIntOrNull() != null -> Int::class
trimmed.toLongOrNull() != null -> Long::class
trimmed.toDoubleOrNull() != null -> Double::class
trimmed.toFloatOrNull() != null -> Float::class
trimmed == "true" || trimmed == "false" -> Boolean::class
else -> String::class
}; return Pair(typeSpec, if (typeSpec == String::class) "\"$valueString\"" else valueString.let {
if (typeSpec == Long::class && it.endsWith("L").not()) "${it}L" else it
})
}
val finalValue = when (typeSpec) {
String::class -> "\"$valueString\""
Long::class -> if (trimmed.endsWith("L")) trimmed else "${trimmed}L"
else -> trimmed
}; return typeSpec to finalValue
}
/**
* [PropertyMap] 转换到 [PropertyOptimizeMap]
*
* 替换可能的键值名称特殊字符内容并保留原始键值名称
* @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
}
/**
* [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
}

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -35,8 +35,8 @@ import javax.xml.parsers.DocumentBuilderFactory
*/
internal object PluginUpdateHelper {
/** OSS Release URL 地址 */
private const val SONATYPE_OSS_RELEASES_URL = "https://s01.oss.sonatype.org/content/repositories/releases"
/** Maven Central Release URL 地址 */
private const val SONATYPE_OSS_RELEASES_URL = "https://repo1.maven.org/maven2"
/** 依赖配置文件名 */
private const val METADATA_FILE_NAME = "maven-metadata.xml"
@@ -73,7 +73,7 @@ internal object PluginUpdateHelper {
* @return [String]
*/
private fun String.findLatest() = runCatching {
if ((contains("<metadata ") || contains("<metadata>")).not() || endsWith("</metadata>").not()) return@runCatching ""
if (!(contains("<metadata ") || contains("<metadata>")) || !endsWith("</metadata>")) return@runCatching ""
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(InputSource(StringReader(this))).let { document ->
document.getElementsByTagName("latest")?.let { if (it.length > 0) it.item(0)?.textContent ?: "" else "" }
}

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -36,10 +36,12 @@ import com.highcapable.sweetproperty.plugin.config.type.GenerateLocationType
import com.highcapable.sweetproperty.plugin.generator.PropertiesAccessorsGenerator
import com.highcapable.sweetproperty.plugin.generator.PropertiesSourcesGenerator
import com.highcapable.sweetproperty.plugin.generator.factory.PropertyMap
import com.highcapable.sweetproperty.plugin.generator.factory.removeAutoConversion
import com.highcapable.sweetproperty.utils.camelcase
import com.highcapable.sweetproperty.utils.code.entity.MavenPomData
import com.highcapable.sweetproperty.utils.code.factory.compile
import com.highcapable.sweetproperty.utils.debug.SError
import com.highcapable.sweetproperty.utils.debug.SLog
import com.highcapable.sweetproperty.utils.flatted
import com.highcapable.sweetproperty.utils.hasInterpolation
import com.highcapable.sweetproperty.utils.isEmpty
@@ -48,7 +50,6 @@ import com.highcapable.sweetproperty.utils.noEmpty
import com.highcapable.sweetproperty.utils.replaceInterpolation
import com.highcapable.sweetproperty.utils.toStringMap
import com.highcapable.sweetproperty.utils.uppercamelcase
import org.gradle.api.DomainObjectCollection
import org.gradle.api.Project
import org.gradle.api.initialization.Settings
import java.io.File
@@ -102,7 +103,7 @@ internal object PropertiesDeployHelper {
internal fun initialize(settings: Settings, configs: ISweetPropertyConfigs) {
this.configs = configs
checkingConfigsModified(settings)
if (configs.isEnable.not()) return
if (!configs.isEnable) return
generatedAccessors(settings)
}
@@ -111,7 +112,7 @@ internal object PropertiesDeployHelper {
* @param rootProject 当前根项目
*/
internal fun resolve(rootProject: Project) {
if (configs.isEnable.not()) return
if (!configs.isEnable) return
resolveAccessors(rootProject)
}
@@ -120,7 +121,7 @@ internal object PropertiesDeployHelper {
* @param rootProject 当前根项目
*/
internal fun deploy(rootProject: Project) {
if (configs.isEnable.not()) return
if (!configs.isEnable) return
deployAccessors(rootProject)
deploySourcesCode(rootProject)
}
@@ -152,13 +153,13 @@ internal object PropertiesDeployHelper {
allConfigs.add(configs.global.buildScript)
}
configs.projects.forEach { (name, subConfigs) ->
if (subConfigs.buildScript.isEnable.not()) return@forEach
if (!subConfigs.buildScript.isEnable) return@forEach
allProperties.add(generatedProperties(subConfigs.buildScript, ProjectDescriptor.create(settings, name)))
allConfigs.add(subConfigs.buildScript)
}
if (isConfigsModified.not() &&
if (!isConfigsModified &&
allProperties == cachedSettingsProperties &&
accessorsDir.resolve(accessorsPomData.relativePomPath).isEmpty().not()
!accessorsDir.resolve(accessorsPomData.relativePomPath).isEmpty()
) return
cachedSettingsProperties = allProperties
accessorsGenerator.build(allConfigs, allProperties).compile(accessorsPomData, accessorsDir.absolutePath, accessorsGenerator.compileStubFiles)
@@ -169,7 +170,7 @@ internal object PropertiesDeployHelper {
* @param rootProject 当前根项目
*/
private fun resolveAccessors(rootProject: Project) {
if (accessorsDir.resolve(accessorsPomData.relativePomPath).isEmpty().not())
if (!accessorsDir.resolve(accessorsPomData.relativePomPath).isEmpty())
rootProject.addDependencyToBuildScript(accessorsDir.absolutePath, accessorsPomData)
}
@@ -181,7 +182,7 @@ internal object PropertiesDeployHelper {
/** 部署扩展方法 */
fun Project.deploy() {
val configs = configs.with(this).buildScript
if (configs.isEnable.not()) return
if (!configs.isEnable) return
val className = accessorsGenerator.propertiesClass(configs.name)
val accessorsClass = loadBuildScriptClass(className) ?: SError.make(
"""
@@ -205,12 +206,14 @@ internal object PropertiesDeployHelper {
fun Project.generate() {
val configs = configs.with(this).sourcesCode
val outputDir = file(configs.generateDirPath)
if (configs.isEnable.not()) return
if (!configs.isEnable) return
val properties = generatedProperties(configs, ProjectDescriptor.create(project = this))
if (isConfigsModified.not() && properties == cachedProjectProperties[fullName()] && outputDir.isEmpty().not()) {
if (!isConfigsModified && properties == cachedProjectProperties[fullName()] && !outputDir.isEmpty()) {
if (configs.isEnable) configureSourceSets(project = this)
return
}; outputDir.apply { if (exists()) deleteRecursively() }
// 每次都会重新创建目录
outputDir.mkdirs()
cachedProjectProperties[fullName()] = properties
val packageName = generatedPackageName(configs, project = this)
val className = generatedClassName(configs, project = this)
@@ -226,16 +229,26 @@ internal object PropertiesDeployHelper {
* @param project 当前项目
*/
private fun configureSourceSets(project: Project) {
fun Project.deploySourceSets(name: String) = runCatching {
val configs = configs.with(project).sourcesCode
fun Project.deploySourceSet(name: String, sourceSetName: String = configs.sourceSetName) = runCatching {
val extension = get(name)
val collection = extension.javaClass.getMethod("getSourceSets").invoke(extension) as DomainObjectCollection<*>
collection.configureEach {
val kotlin = javaClass.getMethod("getKotlin").invoke(this)
kotlin.javaClass.getMethod("srcDir", Any::class.java).invoke(kotlin, configs.with(project).sourcesCode.generateDirPath)
}
val collection = extension.javaClass.getMethod("getSourceSets").invoke(extension) as? Iterable<*>?
val mainSet = collection?.firstOrNull {
it?.javaClass?.getMethod("getName")?.invoke(it) == sourceSetName
} ?: return@runCatching SLog.warn("Could not found source set \"$sourceSetName\" for $name extension")
val kotlin = mainSet.javaClass.getMethod("getKotlin").invoke(mainSet)
val generateDir = configs.generateDirPath
val generateFile = File(generateDir)
// 确保目录存在
if (!generateFile.exists()) generateFile.mkdirs()
val srcDirs = kotlin.javaClass.getMethod("getSrcDirs").invoke(kotlin) as Set<*>
val alreadyAdded = srcDirs.any { it is File && it.canonicalPath == generateFile.canonicalPath }
if (!alreadyAdded) kotlin.javaClass.getMethod("srcDir", Any::class.java).invoke(kotlin, generateFile)
}.onFailure {
SLog.error(msg = "Failed to deploy source set \"$sourceSetName\" for $name extension\n${it.stackTraceToString()}")
}
if (project.hasExtension("kotlin")) project.deploySourceSets(name = "kotlin")
if (project.hasExtension("android")) project.deploySourceSets(name = "android")
if (project.hasExtension("kotlin")) project.deploySourceSet(name = "kotlin")
if (project.hasExtension("android")) project.deploySourceSet(name = "android")
}
/**
@@ -293,7 +306,8 @@ internal object PropertiesDeployHelper {
fun String.resolveValue(): String = replaceInterpolation { matchKey ->
if (resolveKeys.size > 5) SError.make("Key \"$key\" has been called recursively multiple times of those $resolveKeys")
resolveKeys.add(matchKey)
val resolveValue = if (configs.isEnableValueInterpolation) resolveKeyValues[matchKey] ?: "" else matchKey
var resolveValue = if (configs.isEnableValueInterpolation) resolveKeyValues[matchKey] ?: "" else matchKey
resolveValue = resolveValue.removeAutoConversion()
if (resolveValue.hasInterpolation()) resolveValue.resolveValue()
else resolveValue
}

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -52,7 +52,7 @@ internal fun String.parseUnixFileSeparator() = replace("\\", "/")
* - 如果文件不存在 - 返回 true
* @return [Boolean]
*/
internal fun File.isEmpty() = exists().not() || isDirectory.not() || listFiles().isNullOrEmpty()
internal fun File.isEmpty() = !exists() || !isDirectory || listFiles().isNullOrEmpty()
/** 删除目录下的空子目录 */
internal fun File.deleteEmptyRecursively() {

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -52,7 +52,7 @@ internal fun String.executeUrlBody(username: String = "", password: String = "",
else -> SError.make("Invalid URL: $this")
}).get().build()
).execute().let {
if (it.code == 200 || it.code == 404) it.body?.string() ?: ""
if (it.code == 200 || it.code == 404) it.body.string()
else SError.make("Request failed with code ${it.code}")
}
}.onFailure { if (isShowFailure) SLog.error("Failed to connect to $this\n$it") }.getOrNull() ?: ""

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0
@@ -59,7 +59,7 @@ internal object CodeCompiler {
if (files.isEmpty()) {
if (outputDir.exists()) outputDir.deleteRecursively()
return
} else outputDir.also { if (it.exists().not()) it.mkdirs() }
} 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() }
@@ -99,7 +99,7 @@ internal object CodeCompiler {
* @param sourcesDir 编译源码目录
*/
private fun createJarAndPom(pomData: MavenPomData, outputDir: File, buildDir: File, classesDir: File, sourcesDir: File) {
val pomDir = outputDir.resolve(pomData.relativePomPath).also { if (it.exists().not()) it.mkdirs() }
val pomDir = outputDir.resolve(pomData.relativePomPath).also { if (!it.exists()) it.mkdirs() }
packageToJar(classesDir, pomDir, pomData, isSourcesJar = false)
packageToJar(sourcesDir, pomDir, pomData, isSourcesJar = true)
writePom(pomDir, pomData)
@@ -159,7 +159,7 @@ internal object CodeCompiler {
* @throws IllegalStateException 如果编译输出目录不存在
*/
private fun packageToJar(buildDir: File, outputDir: File, pomData: MavenPomData, isSourcesJar: Boolean) {
if (buildDir.exists().not()) SError.make("Jar file output path not found: ${buildDir.absolutePath}")
if (!buildDir.exists()) SError.make("Jar file output path not found: ${buildDir.absolutePath}")
val jarFile = outputDir.resolve("${pomData.artifactId}-${pomData.version}${if (isSourcesJar) "-sources" else ""}.jar")
if (jarFile.exists()) jarFile.delete()
ZipFile(jarFile).addFolder(buildDir, ZipParameters().apply { isIncludeRootFolder = false })

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0

View File

@@ -1,6 +1,6 @@
/*
* SweetProperty - An easy get project properties anywhere Gradle plugin.
* Copyright (C) 2019-2023 HighCapable
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/SweetProperty
*
* Apache License Version 2.0