use of org.gradle.tooling.BuildLauncher in project meghanada-server by mopemope.
the class AndroidSupport method prepareCompileAndroidTestJavaV2.
private void prepareCompileAndroidTestJavaV2() {
ProjectConnection connection = this.project.getProjectConnection();
try {
BuildLauncher buildLauncher = connection.newBuild();
String genTestTask = this.project.getName() + genUnitTestTaskName;
String genAndroidTestTask = this.project.getName() + genAndroidTestTaskName;
buildLauncher.forTasks(genTestTask, genAndroidTestTask).run();
int size = this.project.getDependencies().size();
String aar = Joiner.on(File.separator).join(this.project.getProjectRoot(), BUILD_DIR, INTERMEDIATE_DIR, EXPLODED_DIR);
List<File> jars = FileUtils.collectFiles(new File(aar), EXT_JAR);
for (File jar : jars) {
addAAR(jar);
}
int after = this.project.getDependencies().size();
if (size != after) {
CachedASMReflector.getInstance().createClassIndexes(jars);
this.project.resetCachedClasspath();
}
} finally {
connection.close();
}
}
use of org.gradle.tooling.BuildLauncher in project meghanada-server by mopemope.
the class GradleProject method runPrepareCompileTask.
private void runPrepareCompileTask() throws IOException {
if (!this.prepareCompileTask.isEmpty()) {
final ProjectConnection connection = this.getProjectConnection();
try {
final String[] tasks = prepareCompileTask.toArray(new String[prepareCompileTask.size()]);
final BuildLauncher buildLauncher = connection.newBuild();
log.info("project {} run tasks:{}", this.name, (Object) tasks);
this.setBuildJVMArgs(buildLauncher);
buildLauncher.forTasks(tasks).run();
} finally {
connection.close();
}
}
}
use of org.gradle.tooling.BuildLauncher in project meghanada-server by mopemope.
the class GradleProject method runPrepareTestCompileTask.
private void runPrepareTestCompileTask() throws IOException {
if (!this.prepareTestCompileTask.isEmpty()) {
final ProjectConnection connection = this.getProjectConnection();
try {
final String[] tasks = prepareTestCompileTask.toArray(new String[prepareTestCompileTask.size()]);
final BuildLauncher buildLauncher = connection.newBuild();
log.info("project {} run tasks:{}", this.name, (Object) tasks);
this.setBuildJVMArgs(buildLauncher);
buildLauncher.forTasks(tasks).run();
} finally {
connection.close();
}
}
}
use of org.gradle.tooling.BuildLauncher in project meghanada-server by mopemope.
the class GradleProject method runTask.
@Override
public InputStream runTask(final List<String> args) throws IOException {
try {
final List<String> tasks = new ArrayList<>(4);
final List<String> taskArgs = new ArrayList<>(4);
for (final String temp : args) {
for (final String arg : Splitter.on(" ").split(temp)) {
if (arg.startsWith("-")) {
taskArgs.add(arg.trim());
} else {
tasks.add(arg.trim());
}
}
}
log.debug("task:{}:{} args:{}:{}", tasks, tasks.size(), taskArgs, taskArgs.size());
final ProjectConnection projectConnection = getProjectConnection();
final BuildLauncher build = projectConnection.newBuild();
this.setBuildJVMArgs(build);
build.forTasks(tasks.toArray(new String[tasks.size()]));
if (taskArgs.size() > 0) {
build.withArguments(taskArgs.toArray(new String[taskArgs.size()]));
}
final PipedOutputStream outputStream = new PipedOutputStream();
PipedInputStream inputStream = new PipedInputStream(outputStream);
build.setStandardError(outputStream);
build.setStandardOutput(outputStream);
final VoidResultHandler handler = new VoidResultHandler(outputStream, inputStream, projectConnection);
build.run(handler);
return inputStream;
} finally {
Config.setProjectRoot(this.projectRoot.getCanonicalPath());
}
}
use of org.gradle.tooling.BuildLauncher in project liferay-ide by liferay.
the class LiferayGradleProject method getOutputBundle.
@Override
public IPath getOutputBundle(boolean cleanBuild, IProgressMonitor monitor) throws CoreException {
ProjectConnection connection = null;
try {
IPath projectLocation = getProject().getLocation();
File projectFile = projectLocation.toFile();
GradleConnector connector = GradleConnector.newConnector().forProjectDirectory(projectFile);
connection = connector.connect();
BuildLauncher launcher = connection.newBuild();
BlockingResultHandler<Object> handler = new BlockingResultHandler<>(Object.class);
if (cleanBuild) {
launcher.forTasks("clean", "assemble").run(handler);
} else {
launcher.forTasks("assemble").run(handler);
}
handler.getResult();
} catch (Exception e) {
GradleCore.logError("Project " + getProject().getName() + " build output error", e);
return null;
} finally {
if (connection != null) {
connection.close();
}
}
IPath outputBundlePath = getOutputBundlePath();
if (FileUtil.exists(outputBundlePath)) {
return outputBundlePath;
}
return null;
}
Aggregations