|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * Copyright 2019-2020 the original author or authors.
|
|
|
+ * Copyright 2019-2022 the original author or authors.
|
|
|
*
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
* you may not use this file except in compliance with the License.
|
|
@@ -17,26 +17,48 @@ package org.springframework.gradle.github.milestones;
|
|
|
|
|
|
import org.gradle.api.Action;
|
|
|
import org.gradle.api.DefaultTask;
|
|
|
+import org.gradle.api.file.RegularFileProperty;
|
|
|
import org.gradle.api.tasks.Input;
|
|
|
+import org.gradle.api.tasks.InputFile;
|
|
|
import org.gradle.api.tasks.Optional;
|
|
|
import org.gradle.api.tasks.TaskAction;
|
|
|
+import org.yaml.snakeyaml.Yaml;
|
|
|
+import org.yaml.snakeyaml.constructor.Constructor;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
|
|
|
import org.springframework.gradle.github.RepositoryRef;
|
|
|
|
|
|
-public class GitHubMilestoneHasNoOpenIssuesTask extends DefaultTask {
|
|
|
+public abstract class GitHubMilestoneHasNoOpenIssuesTask extends DefaultTask {
|
|
|
@Input
|
|
|
private RepositoryRef repository = new RepositoryRef();
|
|
|
|
|
|
- @Input
|
|
|
+ @Input @Optional
|
|
|
private String milestoneTitle;
|
|
|
|
|
|
+ @InputFile @Optional
|
|
|
+ public abstract RegularFileProperty getNextVersionFile();
|
|
|
+
|
|
|
@Input @Optional
|
|
|
private String gitHubAccessToken;
|
|
|
|
|
|
private GitHubMilestoneApi milestones = new GitHubMilestoneApi();
|
|
|
|
|
|
@TaskAction
|
|
|
- public void checkHasNoOpenIssues() {
|
|
|
+ public void checkHasNoOpenIssues() throws FileNotFoundException {
|
|
|
+ if (this.milestoneTitle == null) {
|
|
|
+ File nextVersionFile = getNextVersionFile().getAsFile().get();
|
|
|
+ Yaml yaml = new Yaml(new Constructor(NextVersionYml.class));
|
|
|
+ NextVersionYml nextVersionYml = yaml.load(new FileInputStream(nextVersionFile));
|
|
|
+ String nextVersion = nextVersionYml.getVersion();
|
|
|
+ if (nextVersion == null) {
|
|
|
+ throw new IllegalArgumentException(
|
|
|
+ "Could not find version property in provided file " + nextVersionFile.getName());
|
|
|
+ }
|
|
|
+ this.milestoneTitle = nextVersion;
|
|
|
+ }
|
|
|
long milestoneNumber = this.milestones.findMilestoneNumberByTitle(this.repository, this.milestoneTitle);
|
|
|
boolean isOpenIssues = this.milestones.isOpenIssuesForMilestoneNumber(this.repository, milestoneNumber);
|
|
|
if (isOpenIssues) {
|