public static Copy addTaskExpandCompileDependency( Project project, File file, File destinationDir, String taskNamePrefix, RenameDependencyClosure renameDependencyClosure) { String taskName = GradleUtil.getTaskName(taskNamePrefix, file); Copy copy = GradleUtil.addTask(project, taskName, Copy.class); copy.doFirst( new Action<Task>() { @Override public void execute(Task task) { Copy copy = (Copy)task; Project project = copy.getProject(); project.delete(copy.getDestinationDir()); } }); copy.from(project.zipTree(file)); String name = renameDependencyClosure.call(file.getName()); name = name.substring(0, name.length() - 4); destinationDir = new File(destinationDir, name); copy.setDescription( "Expands " + file.getName() + " into " + project.relativePath(destinationDir) + "."); copy.setDestinationDir(destinationDir); return copy; }
private Task _addTaskBuildWSDLCompile( BuildWSDLTask buildWSDLTask, FileCollection classpath, File inputFile, File tmpDir, Task generateTask) { Project project = buildWSDLTask.getProject(); String taskName = GradleUtil.getTaskName( buildWSDLTask.getName() + "Compile", inputFile); JavaCompile javaCompile = GradleUtil.addTask( project, taskName, JavaCompile.class); javaCompile.setClasspath(classpath); File tmpBinDir = new File(tmpDir, "bin"); javaCompile.setDestinationDir(tmpBinDir); javaCompile.setSource(generateTask.getOutputs()); return javaCompile; }
private Jar _addTaskBuildWSDLJar( BuildWSDLTask buildWSDLTask, File inputFile, Task compileTask, final Task generateTask) { Project project = buildWSDLTask.getProject(); String taskName = GradleUtil.getTaskName( buildWSDLTask.getName(), inputFile); Jar jar = GradleUtil.addTask(project, taskName, Jar.class); jar.from(compileTask.getOutputs()); if (buildWSDLTask.isIncludeSource()) { jar.into( "OSGI-OPT/src", new Closure<Void>(project) { @SuppressWarnings("unused") public void doCall(CopySpec copySpec) { copySpec.from(generateTask.getOutputs()); } }); } jar.setDestinationDir(buildWSDLTask.getDestinationDir()); String wsdlName = FileUtil.stripExtension(inputFile.getName()); jar.setArchiveName(wsdlName + "-ws.jar"); return jar; }
private Task _addTaskBuildWSDLGenerate( BuildWSDLTask buildWSDLTask, FileCollection classpath, File inputFile, final File destinationDir, boolean deleteDestinationDir) { Project project = buildWSDLTask.getProject(); String taskName = GradleUtil.getTaskName( buildWSDLTask.getName() + "Generate", inputFile); JavaExec javaExec = GradleUtil.addTask( project, taskName, JavaExec.class); GenerateOptions generateOptions = buildWSDLTask.getGenerateOptions(); javaExec.args(generateOptions.getArgs()); javaExec.args("--output=" + FileUtil.getAbsolutePath(destinationDir)); javaExec.args(FileUtil.getAbsolutePath(inputFile)); if (deleteDestinationDir) { javaExec.doFirst( new Action<Task>() { @Override public void execute(Task task) { Project project = task.getProject(); project.delete(destinationDir); } }); } javaExec.setClasspath(classpath); javaExec.setMain("org.apache.axis.wsdl.WSDL2Java"); TaskInputs taskInputs = javaExec.getInputs(); taskInputs.file(inputFile); TaskOutputs taskOutputs = javaExec.getOutputs(); taskOutputs.dir(destinationDir); return javaExec; }