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

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

Introduction

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

Prototype

public Boolean getSnapshotEnabled() 

Source Link

Usage

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

private void addReposIfNeeded(Document pom, List<Repo> repos) {
    //Example://w  ww.  j  a va2s  . com
    //   <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);
            }
        }
    }
}