mirror of
https://github.com/google/nomulus.git
synced 2025-08-15 05:54:06 +02:00
Set up the plugin build environment
The goal of this CL is to set up the build environment to allow plugins to work. We have a trivial plugin that doesn't do anything (yet) - it just sets itself as the finalizer of all Reporting tasks. Eventually, this plugin will upload all reports to GCS, and even create a "cover page" linking to each one of them. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=233617499
This commit is contained in:
parent
75c80b5e24
commit
e6c46cab58
4 changed files with 126 additions and 0 deletions
|
@ -37,6 +37,12 @@ plugins {
|
||||||
id "com.moowork.node" version "1.2.0"
|
id "com.moowork.node" version "1.2.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply plugin: google.registry.gradle.plugin.GcsReportUploaderPlugin
|
||||||
|
|
||||||
|
gcsReportUploader {
|
||||||
|
bucket = 'my-bucket'
|
||||||
|
}
|
||||||
|
|
||||||
apply from: 'dependencies.gradle'
|
apply from: 'dependencies.gradle'
|
||||||
|
|
||||||
// Provide defaults for all of the project properties.
|
// Provide defaults for all of the project properties.
|
||||||
|
|
21
gradle/buildSrc/build.gradle
Normal file
21
gradle/buildSrc/build.gradle
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
if (project.ext.properties.repositoryUrl == null) {
|
||||||
|
println "Plugins: Using Maven central..."
|
||||||
|
mavenCentral()
|
||||||
|
} else {
|
||||||
|
maven {
|
||||||
|
println "Plugins: Using repo ${repositoryUrl}..."
|
||||||
|
url repositoryUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: '../dependencies.gradle'
|
||||||
|
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
def deps = dependencyMap
|
||||||
|
compile deps['com.google.guava:guava']
|
||||||
|
testCompile deps['com.google.truth:truth']
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
// Copyright 2019 The Nomulus Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package google.registry.gradle.plugin;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import org.gradle.api.DefaultTask;
|
||||||
|
import org.gradle.api.Task;
|
||||||
|
import org.gradle.api.reporting.Report;
|
||||||
|
import org.gradle.api.reporting.ReportContainer;
|
||||||
|
import org.gradle.api.reporting.Reporting;
|
||||||
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A task that uploads the Reports generated by other tasks to GCS.
|
||||||
|
*
|
||||||
|
* <p>TODO:implement it.
|
||||||
|
*/
|
||||||
|
public class GcsReportUploader extends DefaultTask {
|
||||||
|
|
||||||
|
private final ArrayList<Task> reportingTasks = new ArrayList<>();
|
||||||
|
|
||||||
|
private String bucket = null;
|
||||||
|
|
||||||
|
public void setBucket(String bucket) {
|
||||||
|
this.bucket = bucket;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
void uploadResults() {
|
||||||
|
System.out.format("GcsReportUploader uploading to %s: Unimplemented\n", bucket);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Reporting<? extends ReportContainer<? extends Report>> asReporting(Task task) {
|
||||||
|
return (Reporting) task;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addTask(Task task) {
|
||||||
|
if (!(task instanceof Reporting)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
reportingTasks.add(task);
|
||||||
|
task.finalizedBy(this);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
// Copyright 2019 The Nomulus Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package google.registry.gradle.plugin;
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin;
|
||||||
|
import org.gradle.api.Project;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin setting up the GcsReportUploader task.
|
||||||
|
*
|
||||||
|
* <p>It goes over all the tasks in a project and pass them on to the GcsReportUploader task for set
|
||||||
|
* up.
|
||||||
|
*
|
||||||
|
* <p>Note that since we're passing in all the projects' tasks - this includes the GcsReportUploader
|
||||||
|
* itself! It's up to the GcsReportuploader to take care of not having "infinite loops" caused by
|
||||||
|
* waiting for itself to end before finishing.
|
||||||
|
*/
|
||||||
|
public class GcsReportUploaderPlugin implements Plugin<Project> {
|
||||||
|
|
||||||
|
public void apply(Project project) {
|
||||||
|
GcsReportUploader reportUploader =
|
||||||
|
project.getTasks().create("gcsReportUploader", GcsReportUploader.class, task -> {
|
||||||
|
task.setDescription("Uploads the reports to GCS bucket");
|
||||||
|
task.setGroup("uploads");
|
||||||
|
});
|
||||||
|
|
||||||
|
for (Project subProject : project.getAllprojects()) {
|
||||||
|
subProject.getTasks().all(reportUploader::addTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue