]> www.git.dmfe.net Git - dmfe-website/commitdiff
Add Gradle Build File Basics page.
authorDmitry Fedotov <dm.fe@yandex.ru>
Sun, 14 Apr 2024 11:13:46 +0000 (14:13 +0300)
committerDmitry Fedotov <dm.fe@yandex.ru>
Sun, 14 Apr 2024 11:13:46 +0000 (14:13 +0300)
docs/gradle/core-concepts/build_file_basics.md [new file with mode: 0644]
docs/gradle/core-concepts/settings-file-basics.md [deleted file]
docs/gradle/core-concepts/settings_file_basics.md [new file with mode: 0644]

diff --git a/docs/gradle/core-concepts/build_file_basics.md b/docs/gradle/core-concepts/build_file_basics.md
new file mode 100644 (file)
index 0000000..5accb75
--- /dev/null
@@ -0,0 +1,79 @@
+---
+sidebar_position: 5
+tags:
+    - gradle
+    - build tool
+    - build file
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+# Build File Basics
+
+A build script details build configuration, tasks, and plugins.
+Every Gradle build comprises at least one build script.
+In the build file, two types of dependencies can be added:
+1. The libraries and/or plugins on which Gradle and the build script depend.
+2. The libraries on which the project sources depend.
+
+## Build script
+
+The build script is either a `build.gradle` file written in Groovy or a
+`build.gradle.kts` file in Kotlin.
+Example of the build script:
+<Tabs>
+  <TabItem value="kotlin" label="Kotlin" default>
+        ```kotlin title="󱈙 settings.gradle.kts"
+        plugins {
+            id("application")               (1)
+        }
+
+        application {
+            mainClass = "com.example.Main"  (2)
+        }
+        ```
+  </TabItem>
+  <TabItem value="groovy" label="Groovy">
+        ```groovy title=" settings.gradle"
+        plugins {
+            id 'application'                (1)
+        }
+
+        application {
+            mainClass = 'com.example.Main'  (2)
+        }
+        ```
+  </TabItem>
+</Tabs>
+
+(1) Add plugins.  
+(2) Use convention properties.
+
+### 1. Add plugins
+
+Plugins extend Gradle's functionality and can add more tasks to a project.
+Adding a plugin to a build is called _applying_ a plugin:
+```kotlin
+plugins {
+  id("application")
+}
+```
+The application plugin facilitates creating an executable JVM application.
+Applying the [Application plugin](https://docs.gradle.org/current/userguide/application_plugin.html#application_plugin)
+also implicitly applies the [Java plugin](https://docs.gradle.org/current/userguide/java_plugin.html#java_plugin).
+The `java` plugin adds Java compilation along with testing and bundling capabilities to a project.
+
+### 2. Use convention properties
+
+A plugin adds tasks to a project. It also adds properties and methods to a project.
+The `application` plugin defines tasks that package and distribute an application,
+such as the `run` task.
+The Application plugin provides a way to declare the main class of a Java application,
+which is required to execute the code.
+```kotlin
+application {
+    mainClass = "com.example.Main"
+}
+```
+
diff --git a/docs/gradle/core-concepts/settings-file-basics.md b/docs/gradle/core-concepts/settings-file-basics.md
deleted file mode 100644 (file)
index 7dec86c..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
----
-sidebar_position: 4
-tags:
-    - gradle
-    - build tool
-    - settings
----
-
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
-
-# Settings File Basics
-
-Settings file is the **entry point** of every Gradle project.
-The primary purpose of the _settings file_ is to add subprojects to your build.
-Gradle supports single and multi-project builds.
-- Settings file is optional for single-project builds.
-- Settings file is mandatory and declares all subprojects for multi-project builds.
-
-## Settings script
-
-The settings file is a script. It is either a `settings.gradle` file written in Groovy
-or a `settings.gradle.kts` file in Kotlin.
-The _Groovy DSL_ and _Kotlin DSL_ are the only accepted languages for Gradle scripts.
-The settings file is typically found in the root directory of the project:
-<Tabs>
-  <TabItem value="kotlin" label="Kotlin" default>
-        ```kotlin title="󱈙 settings.gradle.kts"
-        rootProject.name = "root-project"   (1)
-
-        include("sub-project-a")            (2) 
-        include("sub-project-b")
-        include("sub-project-c")
-        ```
-  </TabItem>
-  <TabItem value="groovy" label="Groovy">
-        ```groovy title=" settings.gradle"
-        rootProject.name = 'root-project'   (1)
-
-        include('sub-project-a')            (2)
-        include('sub-project-b')
-        include('sub-project-c')
-        ```
-  </TabItem>
-</Tabs>
-
-(1) Define the project name.  
-(2) Add subprojects.
-
diff --git a/docs/gradle/core-concepts/settings_file_basics.md b/docs/gradle/core-concepts/settings_file_basics.md
new file mode 100644 (file)
index 0000000..7dec86c
--- /dev/null
@@ -0,0 +1,49 @@
+---
+sidebar_position: 4
+tags:
+    - gradle
+    - build tool
+    - settings
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+# Settings File Basics
+
+Settings file is the **entry point** of every Gradle project.
+The primary purpose of the _settings file_ is to add subprojects to your build.
+Gradle supports single and multi-project builds.
+- Settings file is optional for single-project builds.
+- Settings file is mandatory and declares all subprojects for multi-project builds.
+
+## Settings script
+
+The settings file is a script. It is either a `settings.gradle` file written in Groovy
+or a `settings.gradle.kts` file in Kotlin.
+The _Groovy DSL_ and _Kotlin DSL_ are the only accepted languages for Gradle scripts.
+The settings file is typically found in the root directory of the project:
+<Tabs>
+  <TabItem value="kotlin" label="Kotlin" default>
+        ```kotlin title="󱈙 settings.gradle.kts"
+        rootProject.name = "root-project"   (1)
+
+        include("sub-project-a")            (2) 
+        include("sub-project-b")
+        include("sub-project-c")
+        ```
+  </TabItem>
+  <TabItem value="groovy" label="Groovy">
+        ```groovy title=" settings.gradle"
+        rootProject.name = 'root-project'   (1)
+
+        include('sub-project-a')            (2)
+        include('sub-project-b')
+        include('sub-project-c')
+        ```
+  </TabItem>
+</Tabs>
+
+(1) Define the project name.  
+(2) Add subprojects.
+