mirror of
https://github.com/HighCapable/Gropify.git
synced 2025-12-11 15:53:54 +08:00
12 lines
8.0 KiB
JavaScript
12 lines
8.0 KiB
JavaScript
import{_ as n,r,o as i,c as l,a as e,b as s,d as a,e as p}from"./app-aH6YcK-Q.js";const t={},c=e("h1",{id:"introduction",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#introduction","aria-hidden":"true"},"#"),s(" Introduction")],-1),d=e("blockquote",null,[e("p",null,[e("code",null,"Gropify"),s(" is a type-safe and modern properties plugin for Gradle.")])],-1),u=e("h2",{id:"background",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#background","aria-hidden":"true"},"#"),s(" Background")],-1),y=e("p",null,[s("This plugin is designed for Gradle build scripts. It aims to bring properties similar to those in the "),e("code",null,"gradle.properties"),s(" file into build scripts in a type-safe way, avoiding problems that hard-coded strings might cause.")],-1),h={href:"https://github.com/Lagrio",target:"_blank",rel:"noopener noreferrer"},m=e("strong",null,"G",-1),g=e("strong",null,"ropify",-1),b={href:"https://github.com/HighCapable/SweetProperty",target:"_blank",rel:"noopener noreferrer"},f=p(`<p>The configuration plan format of <code>Gropify</code> is similar to <code>SweetProperty</code>. If you are using <code>SweetProperty</code>, you can consider migrating to <code>Gropify</code>.</p><h2 id="usage" tabindex="-1"><a class="header-anchor" href="#usage" aria-hidden="true">#</a> Usage</h2><p><code>Gropify</code> is mainly designed for Kotlin DSL build scripts. Groovy can directly use properties from the <code>gradle.properties</code> file as variables, but you can still use <code>Gropify</code> to achieve type-safe property access.</p><p><code>Gropify</code> also supports generating properties (similar to those defined in a <code>gradle.properties</code> 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 <code>BuildConfig</code>'s <code>buildConfigField</code> feature.</p><p>Suppose we have the following <code>gradle.properties</code> file.</p><blockquote><p>The following example</p></blockquote><div class="language-properties line-numbers-mode" data-ext="properties"><pre class="shiki github-dark-dimmed" style="background-color:#22272e;" tabindex="0"><code><span class="line"><span style="color:#F47067;">project.app.name</span><span style="color:#ADBAC7;">=Gropify-Demo</span></span>
|
|
<span class="line"><span style="color:#F47067;">project.app.version</span><span style="color:#ADBAC7;">=1.0.0</span></span>
|
|
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>Here is an example of calling the code automatically generated by <code>Gropify</code>.</p><blockquote><p>Build Script (Kotlin DSL, Groovy DSL)</p></blockquote><div class="language-kotlin line-numbers-mode" data-ext="kt"><pre class="shiki github-dark-dimmed" style="background-color:#22272e;" tabindex="0"><code><span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> appName </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> gropify.project.app.name</span></span>
|
|
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> appVersion </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> gropify.project.app.version</span></span>
|
|
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><div class="language-groovy line-numbers-mode" data-ext="groovy"><pre class="shiki github-dark-dimmed" style="background-color:#22272e;" tabindex="0"><code><span class="line"><span style="color:#F47067;">def</span><span style="color:#F69D50;"> appName </span><span style="color:#F47067;">=</span><span style="color:#F69D50;"> gropify</span><span style="color:#F47067;">.</span><span style="color:#F69D50;">project</span><span style="color:#F47067;">.</span><span style="color:#F69D50;">app</span><span style="color:#F47067;">.</span><span style="color:#F69D50;">name</span></span>
|
|
<span class="line"><span style="color:#F47067;">def</span><span style="color:#F69D50;"> appVersion </span><span style="color:#F47067;">=</span><span style="color:#F69D50;"> gropify</span><span style="color:#F47067;">.</span><span style="color:#F69D50;">project</span><span style="color:#F47067;">.</span><span style="color:#F69D50;">app</span><span style="color:#F47067;">.</span><span style="color:#F69D50;">version</span></span>
|
|
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>Source Code (Kotlin, Java)</p></blockquote><div class="language-kotlin line-numbers-mode" data-ext="kt"><pre class="shiki github-dark-dimmed" style="background-color:#22272e;" tabindex="0"><code><span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> appName </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> MyAppProperties.PROJECT_APP_NAME</span></span>
|
|
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> appVersion </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> MyAppProperties.PROJECT_APP_VERSION</span></span>
|
|
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><div class="language-java line-numbers-mode" data-ext="java"><pre class="shiki github-dark-dimmed" style="background-color:#22272e;" tabindex="0"><code><span class="line"><span style="color:#F47067;">var</span><span style="color:#F69D50;"> </span><span style="color:#ADBAC7;">appName</span><span style="color:#F69D50;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> MyAppProperties.PROJECT_APP_NAME;</span></span>
|
|
<span class="line"><span style="color:#F47067;">var</span><span style="color:#F69D50;"> </span><span style="color:#ADBAC7;">appVersion</span><span style="color:#F69D50;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> MyAppProperties.PROJECT_APP_VERSION;</span></span>
|
|
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p><code>Gropify</code> also supports Kotlin Multiplatform projects, and you can use the generated property classes in the <code>commonMain</code> source set.</p><h2 id="language-requirement" tabindex="-1"><a class="header-anchor" href="#language-requirement" aria-hidden="true">#</a> Language Requirement</h2><p>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.</p><p>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.</p><h2 id="contribution" tabindex="-1"><a class="header-anchor" href="#contribution" aria-hidden="true">#</a> Contribution</h2><p>The maintenance of this project is inseparable from the support and contributions of all developers.</p><p>This project is currently in its early stages, and there may still be some problems or lack of functions you need.</p>`,21),v={href:"https://github.com/HighCapable/Gropify/issues",target:"_blank",rel:"noopener noreferrer"};function _(k,A){const o=r("ExternalLinkIcon");return i(),l("div",null,[c,d,u,y,e("p",null,[s("The project icon was designed by "),e("a",h,[s("MaiTungTM"),a(o)]),s(". The name comes from "),m,s("radleP"),g,s(", meaning a plugin for Gradle properties.")]),e("p",null,[s("It is a brand-new project rebuilt from "),e("a",b,[s("SweetProperty"),a(o)]),s(", borrowing previous design ideas and making it more polished and easier to use.")]),f,e("p",null,[s("If possible, feel free to submit a PR to contribute features you think are needed to this project or go to "),e("a",v,[s("GitHub Issues"),a(o)]),s(" to make suggestions to us.")])])}const D=n(t,[["render",_],["__file","home.html.vue"]]);export{D as default};
|