Gradle Project

Gradle Project

Create a “starting” Gradle/Kotlin project and save it in Git.

⚠️
Make sure you review the project guidelines before proceeding.

Steps

Step 1. Getting working copy

First, you need to git clone your GitLab repository to your local machine so that you have a working copy.

Open the web page for your GitLab project. Click on the Code button, and copy the URL from Clone with HTTPS.

GitLab

In a terminal, on your computer, cd to the location where you want to keep your source code. git clone the URL.

$ git clone https://git.uwaterloo.ca/cs346/public/mm.git

In this example, we would have a folder named mm that contains the contents of the Git repository.

Step 2. Create empty project

You will want to create a project directly in your Git working copy.

IntelliJ IDEA and Android Studio both fully support Gradle, and we can create a new project directly in the IDE.

Option A. Standalone Desktop

This project-type is suitable for a standalone desktop/JVM application. If you wish to build for multiple targets, see the KMP project below.

From the Splash screen in IntelliJ IDEA, select New Project.

New Project Wizard

Choose Kotlin from the list of project types, and provide the following:

  • Name is the name of the folder that will contain your source code. e.g., “DesktopApp”.
  • Location is the location of your working copy (from Step 1 above).
  • JDK should point to your JDK installation.
ℹ️
You will need a JDK installed to proceed. We recommend JDK 21, which is the latest long-term release that is fully supported. You may need to click on the JDK dropdown and choose a compatible JDK 21 installation - IntelliJ will download and install it for you. It doesn’t matter which vendor you choose, as long as you install JDK 21.

Click Create to proceed. If successful, IntelliJ IDEA will open into the main window to an empty project.

Empty Project Window

You should be able to click the Run button in the toolbar to execute it.

Option B. Android

This project-type is suitable for a single-target application built for Android.

From the Splash screen in Android Studio, select New Project.

New Project Wizard 1

Select Empty Activity and Next. A second screen will prompt you for project parameters.

New Project Wizard 2
  • Name: Your application name
  • Package name: A unique package name.
  • Save location: Your working copy location.
  • Minimum SDK: API 26 or later.
  • Build configuration language: Kotlin DSL.

Click Finish and your project should be created.

You will need to add an Android Virtual Device for testing:

  • Tools > Device Manager
  • +, Create Virtual Deviceand walk through the wizard to add an emulated device for testing.

Option C. KMP

This project-type is suitable for targetting two or more targets with your application e.g., Desktop/JVM + Android.

From the Splash screen in IntelliJ IDEA, select New Project. Choose Kotlin Multiplatform from the list of project types.

New Project Wizard

Provide the following:

  • Name is the name of the folder that will contain your source code. e.g., “DesktopApp”.
  • Location is the location of your working copy (from Step 1 above).
  • Group is a reverse-DNS name, used for the top-level package name.
  • Artifact is the single-word name of the project.
  • JDK should point to your JDK installation (see toolchain).
ℹ️
You will need a JDK installed to proceed. We recommend JDK 21, which is the latest long-term release that is fully supported. You may need to click on the JDK dropdown and choose a compatible JDK 21 installation - IntelliJ will download and install it for you. It doesn’t matter which vendor you choose, as long as you install JDK 21.

Select the platforms that you wish to target, and make suer Share UI is enabled (which will default to using Compose for all platforms). Click Create to proceed. If successful, IntelliJ IDEA will open into the main window to an empty project.

Empty Project Window

You should be able to expand the folders to an individual target under the composeApp folder, and click the Run button in the toolbar to execute it.

Step 3. Update .gitignore

Check that you have a .gitignore file in your source tree. It should include at a minimum .idea and build/ folders.

Step 4. Push changes

Once you have confirmed that your project is working, you can commit and push the changes.

$ git add *
$ git commit -m "Initial commit"
$ git push

Step 5. Share with everyone

Your teammates should now be able to git clone the project URL to get a copy of this repository.

Final Word

Git
https://xkcd.com/1597