Example usage for org.springframework.ide.eclipse.boot.core Repo getName

List of usage examples for org.springframework.ide.eclipse.boot.core Repo getName

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.core Repo getName.

Prototype

public String getName() 

Source Link

Usage

From source file:org.springframework.ide.eclipse.boot.core.internal.MavenSpringBootProject.java

private void addReposIfNeeded(Document pom, List<Repo> repos) {
    //Example:/*from   ww w  .ja  v a 2s.co  m*/
    //   <repositories>
    //      <repository>
    //         <id>spring-snapshots</id>
    //         <name>Spring Snapshots</name>
    //         <url>https://repo.spring.io/snapshot</url>
    //         <snapshots>
    //            <enabled>true</enabled>
    //         </snapshots>
    //      </repository>
    //      <repository>
    //         <id>spring-milestones</id>
    //         <name>Spring Milestones</name>
    //         <url>https://repo.spring.io/milestone</url>
    //         <snapshots>
    //            <enabled>false</enabled>
    //         </snapshots>
    //      </repository>
    //   </repositories>

    if (repos != null && !repos.isEmpty()) {
        Element doc = pom.getDocumentElement();
        Element repoList = findChild(doc, REPOSITORIES);
        if (repoList == null) {
            repoList = createElement(doc, REPOSITORIES);
            format(repoList);
        }
        for (Repo repo : repos) {
            String id = repo.getId();
            Element repoEl = findChild(repoList, REPOSITORY, childEquals(ID, id));
            if (repoEl == null) {
                repoEl = createElement(repoList, REPOSITORY);
                createElementWithTextMaybe(repoEl, ID, id);
                createElementWithTextMaybe(repoEl, NAME, repo.getName());
                createElementWithTextMaybe(repoEl, URL, repo.getUrl());
                Boolean isSnapshot = repo.getSnapshotEnabled();
                if (isSnapshot != null) {
                    Element snapshot = createElement(repoEl, SNAPSHOTS);
                    createElementWithText(snapshot, ENABLED, isSnapshot.toString());
                }
                format(repoEl);
            }
        }
    }
}