Use Maven, Eclipse and Travis-ci for online build operations

Source: Internet
Author: User

Tag: lang operation TPS ROR version includes deploying an XML file server

1. Introduction to Maven:

There are three main building tools in the Java World: Ant, maven, and Gradle are now used more often than gradle,maven, and ant is virtually extinct.

Of course, there are other features that Maven does not build, such as project management, and so on.

2.Maven Dependency Management System

We write a Java project that may need to use a variety of packages, and we need them in the build process, so we have to define dependencies in Maven

In the Java world, a dependency can be uniquely identified by a coordination (coordinate) consisting of GroupID, Artifactid, and version.

Any maven-built project itself must also define these three properties, and the resulting package can be either a jar package or a war package or an ear package.

In JUnit, for example, a dependency is represented as follows:

<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version >4.12</version> <scope>test</scope></dependency>

About the package dependency writing, can be found in: http://mvnrepository.com/this site, in the top of the search field to enter the package name, you can get the writing method of the dependency relationship

3.TRAVIS-CI Introduction

Continuous integration: continuous integration, referred to as CI, means that in a project, anyone who changes the code base will trigger the CI server to automatically build the project, run tests automatically, and even automatically deploy to the test environment. This can be understood to be a persistent approach, after the code changes, the use of Travis-ci to build online, if the success of the change is not a problem, otherwise there are some errors in the modification. So why not debug on your own computer and need to use TRAVIS-CI? This is required as a validation, the program may run dependent on the local environment configuration, while the user is using your program, because his local is not configured, so the program cannot run. If the online build succeeds, the program can run without relying on the local environment.

4. Writing a. travis.yml file

Since build requires. travis.yml file, create the file under the project root and write the contents as follows, change the file name to. travis.yml

Then the document is written and completed.

language:javajdk:   -Oraclejdk8

5. Get Pom.xml File

Open Eclipse, right-click the project, select Configure, and then select Convert to Maven project.

This will automatically generate a Pom.xml file, which only needs to be added to the dependency.

To add a procedure:

Open Pom.xml, find the package you need in the previously mentioned website http://mvnrepository.com/, copy <dependency></dependencies> Go to Pom.xml and add <dependencies></dependencies> before and after it.

Examples such as the following

<dependencies>    <dependency>        <groupId>junit</groupId>        <artifactId> junit</artifactid>        <version>4.12</version>        <scope>test</scope>    </dependency>    <!--https://mvnrepository.com/artifact/org.junit.jupiter/ Junit-jupiter-api-    <dependency>        <groupId>org.junit.jupiter</groupId>        <artifactId>junit-jupiter-api</artifactId>        <version>5.1.  0</version>        <scope>test</scope>    </dependency> </dependencies>

6. Problems encountered in the middle

The following error may occur

build failure:error:unmappable character for encoding UTF-8

My solution is to change all the Chinese in the program to English (including comments)

But you can also change the character encoding to cp936, GBK and so on, you can also correct this error

In addition, because most people use JUnit as JUNIT5, search directly in Maven dependency queries will only search for JUNIT4 packages

So using JUNIT5 requires a search for Jupiter, which is related to Pom.xml

Why JUNIT4 is different from the 5 package name requires further research.

Use Maven, Eclipse and Travis-ci for online build operations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.