use of org.gradle.api.GradleException in project gradle by gradle.
the class DistributionPlugin method configureArchiveTask.
private <T extends AbstractArchiveTask> Task configureArchiveTask(Project project, String taskName, final Distribution distribution, Class<T> type) {
final T archiveTask = project.getTasks().create(taskName, type);
archiveTask.setDescription("Bundles the project as a distribution.");
archiveTask.setGroup(DISTRIBUTION_GROUP);
archiveTask.getConventionMapping().map("baseName", new Callable<Object>() {
@Override
public Object call() throws Exception {
if (distribution.getBaseName() == null || distribution.getBaseName().equals("")) {
throw new GradleException("Distribution baseName must not be null or empty! Check your configuration of the distribution plugin.");
}
return distribution.getBaseName();
}
});
Callable<String> baseDir = new Callable<String>() {
@Override
public String call() throws Exception {
return TextUtil.minus(archiveTask.getArchiveName(), "." + archiveTask.getExtension());
}
};
CopySpec childSpec = project.copySpec();
childSpec.into(baseDir);
childSpec.with(distribution.getContents());
archiveTask.with(childSpec);
ArchivePublishArtifact archiveArtifact = new ArchivePublishArtifact(archiveTask);
project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(archiveArtifact);
return archiveTask;
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class ApplicationPlugin method configureInstallTask.
private void configureInstallTask(Task installTask) {
installTask.doFirst(new Action<Task>() {
@Override
public void execute(Task task) {
Sync sync = (Sync) task;
if (sync.getDestinationDir().isDirectory()) {
if (!new File(sync.getDestinationDir(), "lib").isDirectory() || !new File(sync.getDestinationDir(), "bin").isDirectory()) {
throw new GradleException("The specified installation directory \'" + sync.getDestinationDir() + "\' is neither empty nor does it contain an installation for \'" + pluginConvention.getApplicationName() + "\'.\n" + "If you really want to install to this directory, delete it and run the install task again.\n" + "Alternatively, choose a different installation directory.");
}
}
}
});
installTask.doLast(new Action<Task>() {
@Override
public void execute(Task task) {
Sync sync = (Sync) task;
HashMap<String, Object> args = new HashMap<String, Object>();
args.put("file", "" + sync.getDestinationDir().getAbsolutePath() + "/bin/" + pluginConvention.getApplicationName());
args.put("perm", "ugo+x");
project.getAnt().invokeMethod("chmod", args);
}
});
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class PlayApplicationRunner method start.
public PlayApplicationRunnerToken start(PlayRunSpec spec) {
WorkerProcess process = createWorkerProcess(spec.getProjectPath(), workerFactory, spec, adapter);
process.start();
PlayWorkerClient clientCallBack = new PlayWorkerClient();
process.getConnection().addIncoming(PlayRunWorkerClientProtocol.class, clientCallBack);
PlayRunWorkerServerProtocol workerServer = process.getConnection().addOutgoing(PlayRunWorkerServerProtocol.class);
process.getConnection().connect();
PlayAppLifecycleUpdate result = clientCallBack.waitForRunning();
if (result.isRunning()) {
return new PlayApplicationRunnerToken(workerServer, clientCallBack, process);
} else {
throw new GradleException("Unable to start Play application.", result.getException());
}
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class PropertiesToDaemonParametersConverter method convert.
public void convert(Map<String, String> properties, DaemonParameters target) {
String prop = properties.get(IDLE_TIMEOUT_PROPERTY);
if (prop != null) {
try {
target.setIdleTimeout(new Integer(prop));
} catch (NumberFormatException e) {
throw new GradleException(String.format("Unable to parse %s property. The value should be an int but is: %s", IDLE_TIMEOUT_PROPERTY, prop));
}
}
prop = properties.get(HEALTH_CHECK_INTERVAL_PROPERTY);
if (prop != null) {
try {
target.setPeriodicCheckInterval(new Integer(prop));
} catch (NumberFormatException e) {
throw new GradleException(String.format("Unable to parse %s property. Expected an int but got: %s", HEALTH_CHECK_INTERVAL_PROPERTY, prop), e);
}
}
prop = properties.get(JVM_ARGS_PROPERTY);
if (prop != null) {
target.setJvmArgs(JvmOptions.fromString(prop));
}
prop = properties.get(JAVA_HOME_PROPERTY);
if (prop != null) {
File javaHome = new File(prop);
if (!javaHome.isDirectory()) {
throw new GradleException(String.format("Java home supplied via '%s' is invalid. Invalid directory: %s", JAVA_HOME_PROPERTY, prop));
}
JavaInfo jvm;
try {
jvm = Jvm.forHome(javaHome);
} catch (JavaHomeException e) {
throw new GradleException(String.format("Java home supplied via '%s' seems to be invalid: %s", JAVA_HOME_PROPERTY, prop));
}
target.setJvm(jvm);
}
prop = properties.get(DAEMON_BASE_DIR_PROPERTY);
if (prop != null) {
target.setBaseDir(new File(prop));
}
String daemonEnabledPropertyValue = properties.get(DAEMON_ENABLED_PROPERTY);
if (daemonEnabledPropertyValue != null) {
target.setEnabled(isTrue(daemonEnabledPropertyValue));
}
final String debugEnabledPropertyValue = properties.get(DEBUG_MODE_PROPERTY);
if (debugEnabledPropertyValue != null) {
target.setDebug(isTrue(debugEnabledPropertyValue));
}
}
use of org.gradle.api.GradleException in project hibernate-orm by hibernate.
the class HibernatePlugin method writeOutEnhancedClass.
private void writeOutEnhancedClass(byte[] enhancedBytecode, File file) {
try {
if (file.delete()) {
if (!file.createNewFile()) {
logger.error("Unable to recreate class file [" + file.getName() + "]");
}
} else {
logger.error("Unable to delete class file [" + file.getName() + "]");
}
} catch (IOException e) {
logger.warn("Problem preparing class file for writing out enhancements [" + file.getName() + "]");
}
try {
FileOutputStream outputStream = new FileOutputStream(file, false);
try {
outputStream.write(enhancedBytecode);
outputStream.flush();
} catch (IOException e) {
throw new GradleException("Error writing to enhanced class [" + file.getName() + "] to file [" + file.getAbsolutePath() + "]", e);
} finally {
try {
outputStream.close();
} catch (IOException ignore) {
}
}
} catch (FileNotFoundException e) {
throw new GradleException("Error opening class file for writing : " + file.getAbsolutePath(), e);
}
}
Aggregations