Search in sources :

Example 1 with LibraryVersion

use of org.springframework.boot.build.bom.Library.LibraryVersion in project spring-boot by spring-projects.

the class UpgradeApplicatorTests method whenUpgradeIsAppliedToLibraryWithVersionPropertyThenGradlePropertiesIsUpdated.

@Test
void whenUpgradeIsAppliedToLibraryWithVersionPropertyThenGradlePropertiesIsUpdated() throws IOException {
    File bom = new File(this.temp, "bom.gradle");
    FileCopyUtils.copy(new File("src/test/resources/bom.gradle"), bom);
    File gradleProperties = new File(this.temp, "gradle.properties");
    FileCopyUtils.copy(new File("src/test/resources/gradle.properties"), gradleProperties);
    new UpgradeApplicator(bom.toPath(), gradleProperties.toPath()).apply(new Upgrade(new Library("Kotlin", new LibraryVersion(DependencyVersion.parse("1.3.70"), null), null, null, null), DependencyVersion.parse("1.4")));
    Properties properties = new Properties();
    try (InputStream in = new FileInputStream(gradleProperties)) {
        properties.load(in);
    }
    assertThat(properties).containsOnly(entry("a", "alpha"), entry("b", "bravo"), entry("kotlinVersion", "1.4"), entry("t", "tango"));
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) LibraryVersion(org.springframework.boot.build.bom.Library.LibraryVersion) Library(org.springframework.boot.build.bom.Library) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.jupiter.api.Test)

Example 2 with LibraryVersion

use of org.springframework.boot.build.bom.Library.LibraryVersion in project spring-boot by spring-projects.

the class BomExtension method library.

public void library(String name, String version, Action<LibraryHandler> action) {
    ObjectFactory objects = this.project.getObjects();
    LibraryHandler libraryHandler = objects.newInstance(LibraryHandler.class, (version != null) ? version : "", objects);
    action.execute(libraryHandler);
    LibraryVersion libraryVersion = new LibraryVersion(DependencyVersion.parse(libraryHandler.version), libraryHandler.versionAlignment);
    addLibrary(new Library(name, libraryVersion, libraryHandler.groups, libraryHandler.prohibitedVersions, libraryHandler.dependencyVersions));
}
Also used : ObjectFactory(org.gradle.api.model.ObjectFactory) LibraryVersion(org.springframework.boot.build.bom.Library.LibraryVersion)

Example 3 with LibraryVersion

use of org.springframework.boot.build.bom.Library.LibraryVersion in project spring-boot by spring-projects.

the class UpgradeApplicatorTests method whenUpgradeIsAppliedToLibraryWithVersionThenBomIsUpdated.

@Test
void whenUpgradeIsAppliedToLibraryWithVersionThenBomIsUpdated() throws IOException {
    File bom = new File(this.temp, "bom.gradle");
    FileCopyUtils.copy(new File("src/test/resources/bom.gradle"), bom);
    String originalContents = new String(Files.readAllBytes(bom.toPath()), StandardCharsets.UTF_8);
    File gradleProperties = new File(this.temp, "gradle.properties");
    FileCopyUtils.copy(new File("src/test/resources/gradle.properties"), gradleProperties);
    new UpgradeApplicator(bom.toPath(), gradleProperties.toPath()).apply(new Upgrade(new Library("ActiveMQ", new LibraryVersion(DependencyVersion.parse("5.15.11"), null), null, null, null), DependencyVersion.parse("5.16")));
    String bomContents = new String(Files.readAllBytes(bom.toPath()), StandardCharsets.UTF_8);
    assertThat(bomContents.length()).isEqualTo(originalContents.length() - 3);
}
Also used : LibraryVersion(org.springframework.boot.build.bom.Library.LibraryVersion) Library(org.springframework.boot.build.bom.Library) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 4 with LibraryVersion

use of org.springframework.boot.build.bom.Library.LibraryVersion in project spring-boot by spring-projects.

the class UpgradeApplicatorTests method whenUpgradeIsAppliedToLibraryWithAlignedVersionThenBomIsUpdated.

@Test
void whenUpgradeIsAppliedToLibraryWithAlignedVersionThenBomIsUpdated() throws IOException {
    File bom = new File(this.temp, "bom.gradle");
    FileCopyUtils.copy(new File("src/test/resources/bom.gradle"), bom);
    String originalContents = new String(Files.readAllBytes(bom.toPath()), StandardCharsets.UTF_8);
    File gradleProperties = new File(this.temp, "gradle.properties");
    FileCopyUtils.copy(new File("src/test/resources/gradle.properties"), gradleProperties);
    new UpgradeApplicator(bom.toPath(), gradleProperties.toPath()).apply(new Upgrade(new Library("OAuth2 OIDC SDK", new LibraryVersion(DependencyVersion.parse("8.36.1"), null), null, null, null), DependencyVersion.parse("8.36.2")));
    String bomContents = new String(Files.readAllBytes(bom.toPath()), StandardCharsets.UTF_8);
    assertThat(bomContents.length()).isEqualTo(originalContents.length());
    assertThat(bomContents).contains("version(\"8.36.2\")");
}
Also used : LibraryVersion(org.springframework.boot.build.bom.Library.LibraryVersion) Library(org.springframework.boot.build.bom.Library) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

LibraryVersion (org.springframework.boot.build.bom.Library.LibraryVersion)4 File (java.io.File)3 Test (org.junit.jupiter.api.Test)3 Library (org.springframework.boot.build.bom.Library)3 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 ObjectFactory (org.gradle.api.model.ObjectFactory)1