Search in sources :

Example 66 with Project

use of org.gradle.api.Project in project spring-security by spring-projects.

the class CheckAntoraVersionPluginTests method explicitProperties.

@Test
void explicitProperties() {
    Project project = ProjectBuilder.builder().build();
    project.getPluginManager().apply(CheckAntoraVersionPlugin.class);
    Task task = project.getTasks().findByName(CheckAntoraVersionPlugin.ANTORA_CHECK_VERSION_TASK_NAME);
    CheckAntoraVersionTask checkAntoraVersionTask = (CheckAntoraVersionTask) task;
    checkAntoraVersionTask.getAntoraVersion().set("1.0.0");
    checkAntoraVersionTask.getAntoraPrerelease().set("-SNAPSHOT");
    assertThat(checkAntoraVersionTask.getAntoraVersion().get()).isEqualTo("1.0.0");
    assertThat(checkAntoraVersionTask.getAntoraPrerelease().get()).isEqualTo("-SNAPSHOT");
    assertThat(checkAntoraVersionTask.getAntoraDisplayVersion().isPresent()).isFalse();
    assertThat(checkAntoraVersionTask.getAntoraYmlFile().getAsFile().get()).isEqualTo(project.file("antora.yml"));
}
Also used : Project(org.gradle.api.Project) Task(org.gradle.api.Task) Test(org.junit.jupiter.api.Test)

Example 67 with Project

use of org.gradle.api.Project in project spring-security by spring-projects.

the class CheckAntoraVersionPluginTests method versionNotDefined.

@Test
void versionNotDefined() throws Exception {
    Project project = ProjectBuilder.builder().build();
    File rootDir = project.getRootDir();
    IOUtils.write("version: '1.0.0'", new FileOutputStream(new File(rootDir, "antora.yml")), StandardCharsets.UTF_8);
    project.getPluginManager().apply(CheckAntoraVersionPlugin.class);
    Task task = project.getTasks().findByName(CheckAntoraVersionPlugin.ANTORA_CHECK_VERSION_TASK_NAME);
    assertThat(task).isInstanceOf(CheckAntoraVersionTask.class);
    CheckAntoraVersionTask checkAntoraVersionTask = (CheckAntoraVersionTask) task;
    assertThatExceptionOfType(GradleException.class).isThrownBy(() -> checkAntoraVersionTask.check());
}
Also used : Project(org.gradle.api.Project) Task(org.gradle.api.Task) FileOutputStream(java.io.FileOutputStream) GradleException(org.gradle.api.GradleException) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 68 with Project

use of org.gradle.api.Project in project spring-security by spring-projects.

the class CheckAntoraVersionPluginTests method matchesWhenMissingPropertyDefined.

@Test
void matchesWhenMissingPropertyDefined() throws Exception {
    Project project = ProjectBuilder.builder().build();
    File rootDir = project.getRootDir();
    IOUtils.write("name: 'ROOT'\nversion: '1.0.0'", new FileOutputStream(new File(rootDir, "antora.yml")), StandardCharsets.UTF_8);
    project.getPluginManager().apply(CheckAntoraVersionPlugin.class);
    Task task = project.getTasks().findByName(CheckAntoraVersionPlugin.ANTORA_CHECK_VERSION_TASK_NAME);
    assertThat(task).isInstanceOf(CheckAntoraVersionTask.class);
    CheckAntoraVersionTask checkAntoraVersionTask = (CheckAntoraVersionTask) task;
    ((CheckAntoraVersionTask) task).getAntoraVersion().set("1.0.0");
    checkAntoraVersionTask.check();
}
Also used : Project(org.gradle.api.Project) Task(org.gradle.api.Task) FileOutputStream(java.io.FileOutputStream) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 69 with Project

use of org.gradle.api.Project in project spring-security by spring-projects.

the class CheckAntoraVersionPluginTests method matchesWhenRc.

@Test
void matchesWhenRc() throws Exception {
    String expectedVersion = "1.0.0-RC1";
    Project project = ProjectBuilder.builder().build();
    File rootDir = project.getRootDir();
    IOUtils.write("version: '1.0.0-RC1'\nprerelease: 'true'\ndisplay_version: '1.0.0-RC1'", new FileOutputStream(new File(rootDir, "antora.yml")), StandardCharsets.UTF_8);
    project.setVersion(expectedVersion);
    project.getPluginManager().apply(CheckAntoraVersionPlugin.class);
    Task task = project.getTasks().findByName(CheckAntoraVersionPlugin.ANTORA_CHECK_VERSION_TASK_NAME);
    assertThat(task).isInstanceOf(CheckAntoraVersionTask.class);
    CheckAntoraVersionTask checkAntoraVersionTask = (CheckAntoraVersionTask) task;
    checkAntoraVersionTask.check();
}
Also used : Project(org.gradle.api.Project) Task(org.gradle.api.Task) FileOutputStream(java.io.FileOutputStream) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 70 with Project

use of org.gradle.api.Project in project spring-security by spring-projects.

the class CheckAntoraVersionPluginTests method matchesWhenExplicitRelease.

@Test
void matchesWhenExplicitRelease() throws Exception {
    Project project = ProjectBuilder.builder().build();
    File rootDir = project.getRootDir();
    IOUtils.write("version: '1.0.0'", new FileOutputStream(new File(rootDir, "antora.yml")), StandardCharsets.UTF_8);
    project.getPluginManager().apply(CheckAntoraVersionPlugin.class);
    Task task = project.getTasks().findByName(CheckAntoraVersionPlugin.ANTORA_CHECK_VERSION_TASK_NAME);
    assertThat(task).isInstanceOf(CheckAntoraVersionTask.class);
    CheckAntoraVersionTask checkAntoraVersionTask = (CheckAntoraVersionTask) task;
    ((CheckAntoraVersionTask) task).getAntoraVersion().set("1.0.0");
    checkAntoraVersionTask.check();
}
Also used : Project(org.gradle.api.Project) Task(org.gradle.api.Task) FileOutputStream(java.io.FileOutputStream) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

Project (org.gradle.api.Project)269 File (java.io.File)98 Task (org.gradle.api.Task)71 Plugin (org.gradle.api.Plugin)69 Configuration (org.gradle.api.artifacts.Configuration)53 List (java.util.List)40 ArrayList (java.util.ArrayList)39 SourceSet (org.gradle.api.tasks.SourceSet)38 TaskProvider (org.gradle.api.tasks.TaskProvider)38 IOException (java.io.IOException)35 Map (java.util.Map)35 Action (org.gradle.api.Action)34 Set (java.util.Set)32 JavaPlugin (org.gradle.api.plugins.JavaPlugin)31 FileCollection (org.gradle.api.file.FileCollection)30 Provider (org.gradle.api.provider.Provider)27 HashMap (java.util.HashMap)26 Collectors (java.util.stream.Collectors)26 ObjectFactory (org.gradle.api.model.ObjectFactory)25 Collections (java.util.Collections)24