<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mirsaidov Nurulloh on Medium]]></title>
        <description><![CDATA[Stories by Mirsaidov Nurulloh on Medium]]></description>
        <link>https://medium.com/@mirsaidoff?source=rss-f6b7b34a0f3b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zSnFuhBRSJQCb_CcH1GZBQ.jpeg</url>
            <title>Stories by Mirsaidov Nurulloh on Medium</title>
            <link>https://medium.com/@mirsaidoff?source=rss-f6b7b34a0f3b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 23:03:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mirsaidoff/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introduction to GitLab CI/CD Basics]]></title>
            <link>https://medium.com/@mirsaidoff/introduction-to-gitlab-ci-cd-basics-f11a9ab6ca41?source=rss-f6b7b34a0f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f11a9ab6ca41</guid>
            <category><![CDATA[android-ci]]></category>
            <category><![CDATA[gitlab-ci]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Mirsaidov Nurulloh]]></dc:creator>
            <pubDate>Wed, 31 Jul 2024 07:14:40 GMT</pubDate>
            <atom:updated>2024-07-31T07:29:00.279Z</atom:updated>
            <content:encoded><![CDATA[<p>GitLab CI/CD (Continuous Integration/Continuous Deployment) is a powerful tool that automates the process of testing, building, and deploying your code. It allows you to define a series of steps (jobs) to be executed in a specific order (stages). In this guide, we’ll explore the fundamental components of a GitLab CI/CD configuration file (.gitlab-ci.yml) and their roles.</p><h3>Key Components of GitLab CI/CD Configuration</h3><h3>1. stages</h3><p><strong>Purpose</strong>: Define the sequence of execution for jobs.</p><p>The stages keyword is used to define the stages in your pipeline. Stages run sequentially, while jobs within a stage run in parallel. Common stages include build, test, and deploy.</p><pre>stages:<br>  - build<br>  - test<br>  - deploy</pre><h3>2. jobs</h3><p><strong>Purpose</strong>: Define the tasks to be executed within each stage.</p><p>A job is a unit of work that GitLab Runner executes. Each job is associated with a stage and contains a script section where you define the commands to be run.</p><pre>build_job:<br>  stage: build<br>  script:<br>    - echo &quot;Building the project&quot;<br>    - ./gradlew build</pre><h3>3. script</h3><p><strong>Purpose</strong>: Specify the tasks (commands) to be executed for a job.</p><p>The script section lists the commands to be executed by the runner. These commands, or tasks, can be anything you would run in a shell. This is where you declare the steps required to complete the job, such as building the project, running tests, or deploying the application.</p><pre>script:<br>  - echo &quot;Hello, World!&quot;<br>  - ./gradlew build<br>  - ./gradlew test</pre><h3>4. variables</h3><p><strong>Purpose</strong>: Define environment variables to be used in jobs.</p><p>The variables keyword allows you to define environment variables that can be used across jobs. These variables can help manage configurations and secrets.</p><pre>variables:<br>  GRADLE_USER_HOME: &quot;$CI_PROJECT_DIR/.gradle&quot;</pre><h3>5. before_script and after_script</h3><p><strong>Purpose</strong>: Define commands to run before and after each job.</p><p>The before_script and after_script keywords allow you to run commands before and after each job in the pipeline. This is useful for setup and cleanup tasks.</p><pre>before_script:<br>  - echo &quot;Setting up environment&quot;<br>  - chmod +x ./gradlew<br><br>after_script:<br>  - echo &quot;Cleaning up environment&quot;</pre><h3>6. artifacts</h3><p><strong>Purpose</strong>: Define files to be saved and passed between jobs.</p><p>The artifacts keyword is used to specify files and directories to be preserved after a job completes. These artifacts can be used by subsequent jobs.</p><pre>artifacts:<br>  paths:<br>    - build/libs/</pre><h3>7. dependencies</h3><p><strong>Purpose</strong>: Define job dependencies to pass artifacts between jobs.</p><p>The dependencies keyword specifies which jobs’ artifacts are required for the current job. This ensures that the necessary files are available.</p><pre>dependencies:<br>  - build_job</pre><h3>8. rules, only, and except</h3><p><strong>Purpose</strong>: Define conditions for job execution.</p><p>The rules, only, and except keywords allow you to conditionally run jobs based on branch names, tags, or other criteria.</p><pre>rules:<br>  - if: &#39;$CI_COMMIT_BRANCH == &quot;main&quot;&#39;<br><br>only:<br>  - main<br><br>except:<br>  - tags</pre><h3>9. environments</h3><p><strong>Purpose</strong>: Define environments for deployment.</p><p>The environments keyword is used to specify deployment environments, such as staging and production. This helps manage where and how your code is deployed.</p><pre>deploy_job:<br>  stage: deploy<br>  script:<br>    - echo &quot;Deploying to production&quot;<br>  environment:<br>    name: production<br>    url: &lt;https://your-app.com&gt;</pre><h3>Putting It All Together</h3><p>Here is a simple .gitlab-ci.yml file that combines these elements:</p><pre>stages:<br>  - build<br>  - test<br>  - deploy<br><br>variables:<br>  GRADLE_USER_HOME: &quot;$CI_PROJECT_DIR/.gradle&quot;<br><br>before_script:<br>  - echo &quot;Setting up environment&quot;<br>  - chmod +x ./gradlew<br><br>after_script:<br>  - echo &quot;Cleaning up environment&quot;<br><br>build_job:<br>  stage: build<br>  script:<br>    - echo &quot;Building the project&quot;<br>    - ./gradlew build<br>  artifacts:<br>    paths:<br>      - build/libs/<br><br>test_job:<br>  stage: test<br>  script:<br>    - echo &quot;Running tests&quot;<br>    - ./gradlew test<br>  dependencies:<br>    - build_job<br><br>deploy_job:<br>  stage: deploy<br>  script:<br>    - echo &quot;Deploying to production&quot;<br>  environment:<br>    name: production<br>    url: &lt;https://your-app.com&gt;<br>  rules:<br>    - if: &#39;$CI_COMMIT_BRANCH == &quot;main&quot;&#39;</pre><p>By understanding these key components of GitLab CI/CD, you can start building your own pipelines to automate the testing, building, and deployment of your projects. This guide provides a foundation for creating more complex and customized CI/CD workflows in GitLab. As you gain more experience, you can explore advanced features and configurations to further optimize your pipeline.</p><p>For more information, check out official doc - <a href="https://docs.gitlab.com/ee/ci/yaml/">https://docs.gitlab.com/ee/ci/yaml/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f11a9ab6ca41" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction of new Dependency Management (Version Control) and Kotlin DSL migration]]></title>
            <link>https://medium.com/@mirsaidoff/introduction-of-new-dependency-management-version-control-and-kotlin-dsl-migration-4a49bfa09065?source=rss-f6b7b34a0f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a49bfa09065</guid>
            <category><![CDATA[plugins]]></category>
            <category><![CDATA[gradle-kotlin-dsl]]></category>
            <category><![CDATA[gradle-version-catalog]]></category>
            <category><![CDATA[dependency-management]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Mirsaidov Nurulloh]]></dc:creator>
            <pubDate>Wed, 24 Jul 2024 06:43:45 GMT</pubDate>
            <atom:updated>2024-07-24T06:43:45.016Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>This document outlines migrating and optimizing dependency management in our Android project. It includes details on converting Gradle files from Groovy DSL to Kotlin DSL, introducing versions.libs.toml, converting dependencies, and optimizing build performance by transitioning from api() to implementation().</p><h3>Migration Steps</h3><h4>1. Converted Gradle Files from Groovy DSL to Kotlin DSL</h4><p>The first step was to convert all build.gradle files from Groovy DSL to Kotlin DSL (build.gradle.kts). This transition improves type safety, offers better IDE support, and leverages Kotlin&#39;s language features.</p><p>Example conversion:</p><p><strong>Groovy DSL (</strong>build.gradle):</p><pre>plugins {<br>    id &#39;com.android.application&#39;<br>    id &#39;kotlin-android&#39;<br>}<br><br>android {<br>    compileSdkVersion 30<br>    defaultConfig {<br>        applicationId &quot;com.example.app&quot;<br>        minSdkVersion 21<br>        targetSdkVersion 30<br>    }<br>}<br><br>dependencies {<br>    implementation &quot;org.jetbrains.kotlin:kotlin-stdlib:1.5.21&quot;<br>}</pre><p><strong>Kotlin DSL (</strong>build.gradle.kts):</p><pre>plugins {<br>    id(&quot;com.android.application&quot;)<br>    id(&quot;kotlin-android&quot;)<br>}<br><br>android {<br>    compileSdk = 30<br>    defaultConfig {<br>        applicationId = &quot;com.example.app&quot;<br>        minSdk = 21<br>        targetSdk = 30<br>    }<br>}<br><br>dependencies {<br>    implementation(&quot;org.jetbrains.kotlin:kotlin-stdlib:1.5.21&quot;)<br>}</pre><p>For more details, refer to the <a href="https://developer.android.com/studio/build/migrate-to-kotlin-dsl">official Android documentation</a>.</p><h4>2. Introduced versions.libs.toml</h4><p>To manage dependencies more efficiently, a versions.libs.toml file was introduced. This file separates versions, libraries, and plugins, making it easier to maintain and update dependencies.</p><ul><li><strong>Versions</strong>: Define version numbers for all dependencies.</li><li><strong>Libraries</strong>: List of library dependencies.</li><li><strong>Plugins</strong>: List of plugin dependencies.</li></ul><p>Example versions.libs.toml:</p><pre>[versions]<br>kotlin = &quot;1.5.21&quot;<br>coroutines = &quot;1.5.0&quot;<br><br>[libraries]<br>kotlinStdLib = { module = &quot;org.jetbrains.kotlin:kotlin-stdlib&quot;, version.ref = &quot;kotlin&quot; }<br>coroutinesCore = { module = &quot;org.jetbrains.kotlinx:kotlinx-coroutines-core&quot;, version.ref = &quot;coroutines&quot; }<br><br>[plugins]<br>androidApplication = { id = &quot;com.android.application&quot;, version = &quot;7.0.2&quot; }<br>kotlinAndroid = { id = &quot;org.jetbrains.kotlin.android&quot;, version.ref = &quot;kotlin&quot; }</pre><h4>3. Converted Dependencies</h4><p>All dependencies in the project were converted to use the versions.libs.toml file. This involved updating the build.gradle.kts files to reference the new format.</p><p>Example conversion:</p><pre>dependencies {<br>    implementation(libs.kotlinStdLib)<br>    implementation(libs.coroutinesCore)<br>}</pre><h4>4. Removed classpath() Calls</h4><p>The classpath() calls were removed and converted into plugin implementations. This simplifies the build scripts and improves clarity.</p><p>Example conversion:</p><h4>Old code :</h4><pre>dependencies {<br>        classpath &quot;com.android.tools.build:gradle:8.5.0&quot;<br>        classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21&quot;<br>}</pre><h4>New code :</h4><pre>plugins {<br>    alias(libs.plugins.androidApplication)<br>    alias(libs.plugins.kotlinAndroid)<br>}</pre><h4>5. Optimized api() to implementation()</h4><p>For better build performance, all api() calls in the shared module were converted to implementation() calls. The difference between api and implementation is crucial for build performance and encapsulation:</p><ul><li>api: Exposes the dependency to the consumers of the module.</li><li>implementation: Keeps the dependency internal to the module.</li></ul><p>For more information, refer to the official documentation: <a href="https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html#sec:java_library_separation">Difference between api and implementation</a></p><h4>6. Applying the Plugin in Specific Modules</h4><p>With apply false, the plugin is declared but not applied. You need to apply it explicitly in the modules where it&#39;s required.</p><p><strong>build.gradle.kts (app module):</strong></p><pre>plugins {<br>    alias(libs.plugins.androidApplication) apply true<br>    alias(libs.plugins.kotlinAndroid) apply true<br>}</pre><h4>Why Use apply false?</h4><ol><li><strong>Centralized Version Management</strong>: It allows for centralized management of plugin versions in the version catalog, making it easier to update versions across multiple modules.</li><li><strong>Selective Application</strong>: It enables selective application of plugins only to the necessary modules, avoiding unnecessary application of plugins to all sub-projects.</li><li><strong>Cleaner Build Scripts</strong>: By using aliases and apply false, you keep the build scripts clean and maintainable, with clear separation between declaration and application of plugins.</li></ol><p>This approach provides a clean and maintainable way to manage plugins in complex projects, ensuring that plugins are only applied where necessary while keeping version control centralized. For more details, refer to the official Gradle documentation on version catalogs.</p><h3>Adding New Plugins/Dependencies</h3><p>To add new plugins or dependencies:</p><ul><li><strong>Add Version</strong>: Define the version in versions.libs.toml.</li></ul><pre>[versions]<br>newLibrary = &quot;1.0.0&quot;</pre><ul><li><strong>Add Library</strong>: Define the library in versions.libs.toml.</li></ul><pre>[libraries]<br>newLibrary = { module = &quot;com.example:new-library&quot;, version.ref = &quot;newLibrary&quot; }</pre><ul><li><strong>Add Plugin</strong>: Define the plugin in versions.libs.toml.</li></ul><pre>[plugins]<br>newPlugin = { id = &quot;com.example.plugin&quot;, version = &quot;1.0.0&quot; }</pre><ul><li><strong>Use in Build Script</strong>: Reference the new library or plugin in the build.gradle.kts file.</li></ul><pre>dependencies {<br>    implementation(libs.newLibrary)<br>}<br><br>plugins {<br>    alias(libs.plugins.newPlugin)<br>}</pre><h3>Useful Documentation Links</h3><ul><li><a href="https://docs.gradle.org/current/userguide/kotlin_dsl.html">Gradle Kotlin DSL Primer</a></li><li><a href="https://docs.gradle.org/current/userguide/platforms.html">Gradle Version Catalogs</a></li><li><a href="https://docs.gradle.org/current/userguide/version_catalog_problems.html">Managing Dependencies with Version Catalogs</a></li><li><a href="https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html#sec:java_library_separation">Difference between api and implementation</a></li><li><a href="https://developer.android.com/studio/build/migrate-to-kotlin-dsl">Migrating to the Kotlin DSL</a></li><li><a href="https://developer.android.com/studio/build/dependencies">Dependency Management in Android Projects</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a49bfa09065" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>