Travis

Use Java with Travis CI

The following is a guide to getting started with Travis CI using Java.

Prerequisite #

Before getting started, create a .travis.yml file and add it to the root directory of your Java project. This file defines how Travis CI builds and tests your project.

Specify the Language and JDK Version #

Add the following code to let Travis CI know you are working with Java:

language: java

You can test your project across multiple Java versions. The following example uses OpenJDK 11 and OpenJDK 17.

jdk:
  - openjdk11
  - openjdk17

Install Build Dependencies #

Travis CI automatically installs project dependencies based on your build tool (like Maven or Gradle). For Maven projects, use the following command:

install:
  - mvn install -DskipTests=true -B -V

The command above installs all necessary dependencies without running any tests during the installation.

Define the Test Command #

Use the script key to specify the command you want Travis CI to run your unit tests. For a Maven project, use the following code:

script:
  - mvn test

The code above runs unit tests with the default Maven settings.

Commit and Push #

Once the file is created, commit it to your repository. Travis CI detects the file and automatically starts building and testing your project each time you push a new change. The following is the complete code:

language: java
jdk:
  - openjdk11
  - openjdk17
install:
  - mvn install -DskipTests=true -B -V
script:
  - mvn test

Further Reading #

For more information on Java projects, see:

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy