use of org.apache.tools.ant.taskdefs.condition.Os in project curiostack by curioswitch.
the class CuriostackPlugin method apply.
@Override
public void apply(Project rootProject) {
PluginContainer plugins = rootProject.getPlugins();
// Provides useful tasks like 'clean', 'assemble' to the root project.
plugins.apply(BasePlugin.class);
plugins.apply(BaselineIdea.class);
plugins.apply(CurioGenericCiPlugin.class);
plugins.apply(GcloudPlugin.class);
plugins.apply(NodePlugin.class);
plugins.apply(PythonEnvsPlugin.class);
setupPyenvs(rootProject);
YarnInstallTask yarnTask = rootProject.getTasks().withType(YarnInstallTask.class).getByName("yarn");
yarnTask.setArgs(ImmutableList.of("--frozen-lockfile"));
YarnInstallTask yarnUpdateTask = rootProject.getTasks().create("yarnUpdate", YarnInstallTask.class);
Task yarnWarning = rootProject.getTasks().create("yarnWarning", task -> {
task.onlyIf(unused -> yarnTask.getState().getFailure() != null);
task.doFirst(unused -> rootProject.getLogger().warn("yarn task failed. If you have updated a dependency and the " + "error says 'Your lockfile needs to be updated.', run \n\n" + "./gradlew " + yarnUpdateTask.getPath()));
});
yarnTask.finalizedBy(yarnWarning);
rootProject.getTasks().create("setupGitHooks", SetupGitHooks.class);
CreateShellConfigTask rehash = rootProject.getTasks().create("rehash", CreateShellConfigTask.class, t -> t.path(CommandUtil.getPythonBinDir(rootProject, "dev")).path(CommandUtil.getGcloudSdkBinDir(rootProject)));
setupNode(rootProject, rehash);
rootProject.getTasks().create("setup", t -> {
t.dependsOn("gcloudSetup");
t.dependsOn("pythonSetup");
t.dependsOn("nodeSetup");
t.dependsOn("yarnSetup");
t.dependsOn("rehash");
});
String baselineFiles;
try {
baselineFiles = Resources.toString(Resources.getResource("META-INF/org.curioswitch.curiostack.baseline_manifest.txt"), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
Task baselineUpdateConfig = rootProject.getTasks().create("baselineUpdateConfig").doLast(task -> {
File baselineDir = rootProject.file(".baseline");
baselineDir.mkdirs();
for (String filePath : NEW_LINE_SPLITTER.split(baselineFiles)) {
Path path = Paths.get(filePath);
Path outputDirectory = Paths.get(baselineDir.getAbsolutePath()).resolve(path.getParent());
rootProject.file(outputDirectory.toAbsolutePath()).mkdirs();
try (FileOutputStream os = new FileOutputStream(outputDirectory.resolve(path.getFileName()).toFile());
InputStream is = Resources.getResource(filePath).openStream()) {
ByteStreams.copy(is, os);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
});
if (!rootProject.file(".baseline").exists()) {
rootProject.getTasks().getByName("ideaProject").dependsOn(baselineUpdateConfig);
}
rootProject.afterEvaluate((p) -> rootProject.getPlugins().withType(IdeaPlugin.class, plugin -> {
plugin.getModel().getProject().getIpr().withXml(provider -> setupProjectXml(rootProject, provider));
plugin.getModel().getWorkspace().getIws().withXml(provider -> setupWorkspaceXml(rootProject, provider));
}));
rootProject.allprojects(project -> {
setupRepositories(project);
project.getPlugins().apply(ResolutionRulesPlugin.class);
project.getPlugins().withType(JavaPlugin.class, plugin -> setupJavaProject(project));
project.getPlugins().withType(LicensePlugin.class, unused -> {
LicenseExtension license = project.getExtensions().getByType(LicenseExtension.class);
license.exclude("**/*.json");
license.setHeader(rootProject.file("LICENSE"));
license.mapping(ImmutableMap.of("conf", "DOUBLESLASH_STYLE", "java", "SLASHSTAR_STYLE", "proto", "SLASHSTAR_STYLE", "yml", "SCRIPT_STYLE"));
});
});
setupDataSources(rootProject);
}
Aggregations