private void createBinaryLifecycleTask(SourceSet sourceSet, Project target) { Task binaryLifecycleTask = target.task(sourceSet.getClassesTaskName()); binaryLifecycleTask.setGroup(LifecycleBasePlugin.BUILD_GROUP); binaryLifecycleTask.setDescription(String.format("Assembles %s.", sourceSet)); binaryLifecycleTask.dependsOn(sourceSet.getOutput().getDirs()); binaryLifecycleTask.dependsOn(sourceSet.getCompileJavaTaskName()); binaryLifecycleTask.dependsOn(sourceSet.getProcessResourcesTaskName()); }
private Task _addTaskBuild(Project project, UpdatePropertiesTask updatePropertiesTask) { Task task = project.task(LifecycleBasePlugin.BUILD_TASK_NAME); task.dependsOn(updatePropertiesTask, WarPlugin.WAR_TASK_NAME); task.setDescription("Alias for 'ant war'."); return task; }
protected Task addTaskCreateLiferayThemeJson( Project project, final WorkspaceExtension workspaceExtension) { Task task = project.task(CREATE_LIFERAY_THEME_JSON_TASK_NAME); final File liferayThemeJsonFile = project.file("liferay-theme.json"); task.doLast( new Action<Task>() { @Override public void execute(Task task) { Project project = task.getProject(); Map<String, Object> map = new HashMap<>(); File appServerDir = new File(workspaceExtension.getHomeDir(), "tomcat-7.0.62"); map.put("appServerPath", appServerDir.getAbsolutePath()); File appServerThemeDir = new File(appServerDir, "webapps/" + project.getName()); map.put("appServerPathTheme", appServerThemeDir.getAbsolutePath()); map.put("deployed", false); File deployDir = new File(workspaceExtension.getHomeDir(), "deploy"); map.put("deployPath", deployDir.getAbsolutePath()); map.put("themeName", project.getName()); String json = JsonOutput.toJson(Collections.singletonMap("LiferayTheme", map)); try { Files.write(liferayThemeJsonFile.toPath(), json.getBytes(StandardCharsets.UTF_8)); } catch (IOException ioe) { throw new GradleException(ioe.getMessage(), ioe); } } }); task.onlyIf( new Spec<Task>() { @Override public boolean isSatisfiedBy(Task task) { if (liferayThemeJsonFile.exists()) { return true; } return false; } }); return task; }
protected void configurePluginsSDK( Project project, final WorkspaceExtension workspaceExtension, Copy initBundleTask, AbstractArchiveTask[] distBundleTasks) { final Project pluginsSDKProject = GradleUtil.getProject(project, workspaceExtension.getPluginsSDKDir()); if (pluginsSDKProject == null) { return; } AntBuilder antBuilder = pluginsSDKProject.getAnt(); antBuilder.importBuild("build.xml"); final Task warTask = GradleUtil.getTask(pluginsSDKProject, WarPlugin.WAR_TASK_NAME); File homeDir = workspaceExtension.getHomeDir(); if (!homeDir.exists()) { warTask.dependsOn(initBundleTask); } Task updateSDKPropertiesTask = addTaskUpdateSDKProperties(pluginsSDKProject, workspaceExtension); Task buildTask = pluginsSDKProject.task(LifecycleBasePlugin.BUILD_TASK_NAME); buildTask.dependsOn(updateSDKPropertiesTask, warTask); for (AbstractArchiveTask abstractArchiveTask : distBundleTasks) { abstractArchiveTask.into( "deploy", new Closure<Void>(null) { @SuppressWarnings("unused") public void doCall(CopySpec copySpec) { ConfigurableFileTree configurableFileTree = pluginsSDKProject.fileTree("dist"); configurableFileTree.builtBy(warTask); configurableFileTree.include("*.war"); copySpec.from(configurableFileTree); } }); } }
@Override public void apply(Project project) { project.getExtensions().create(BugVMPluginExtension.NAME, BugVMPluginExtension.class, project); project.task( Collections.singletonMap("type", IPhoneSimulatorTask.class), "launchIPhoneSimulator"); project.task(Collections.singletonMap("type", IPadSimulatorTask.class), "launchIPadSimulator"); project.task(Collections.singletonMap("type", IOSDeviceTask.class), "launchIOSDevice"); project.task(Collections.singletonMap("type", ConsoleTask.class), "launchConsole"); project.task(Collections.singletonMap("type", ArchiveTask.class), "createIPA"); project.task(Collections.singletonMap("type", ArchiveTask.class), "bugvmArchive"); project.task(Collections.singletonMap("type", InstallTask.class), "bugvmInstall"); }
protected Task addTaskUnzipJar(final Project project) { Task task = project.task(UNZIP_JAR_TASK_NAME); final Jar jar = (Jar) GradleUtil.getTask(project, JavaPlugin.JAR_TASK_NAME); task.dependsOn(jar); task.doLast( new Action<Task>() { @Override public void execute(Task task) { Project project = task.getProject(); FileUtil.unzip(project, jar.getArchivePath(), getUnzippedJarDir(project)); } }); return task; }
@Override public void apply(Project target) { target.getExtensions().create("generator", GeneratorPluginExtension.class); target.task("javaTask"); }
public <T extends SourceTask> T task(String name, Class<T> type, Closure closure) { T task = (T) project.task(Collections.singletonMap("type", type), name, closure); add(task); return task; }