use of org.gradle.api.GradleException in project gradle by gradle.
the class OsgiHelper method getVersion.
public String getVersion(String version) {
/* if it's already OSGi compliant don't touch it */
final Matcher m = OSGI_VERSION_PATTERN.matcher(version);
if (m.matches()) {
return version;
}
int group = 0;
boolean groupToken = true;
String[] groups = new String[4];
groups[0] = "0";
groups[1] = "0";
groups[2] = "0";
groups[3] = "";
StringTokenizer st = new StringTokenizer(version, ",./;'?:\\|=+-_*&^%$#@!~", true);
while (st.hasMoreTokens()) {
String token = st.nextToken();
if (groupToken) {
if (group < 3) {
if (ONLY_NUMBERS.matcher(token).matches()) {
groups[group++] = token;
groupToken = false;
} else {
// if not a number, i.e. 2.ABD
groups[3] = token + fillQualifier(st);
}
} else {
// Last group; what ever is left take that replace all characters that are not alphanum or '_' or '-'
groups[3] = token + fillQualifier(st);
}
} else {
// If a delimiter; if dot, swap to groupToken, otherwise the rest belongs in qualifier.
if (".".equals(token)) {
groupToken = true;
} else {
groups[3] = fillQualifier(st);
}
}
}
String ver = groups[0] + "." + groups[1] + "." + groups[2];
String result;
if (groups[3].length() > 0) {
result = ver + "." + groups[3];
} else {
result = ver;
}
if (!OSGI_VERSION_PATTERN.matcher(result).matches()) {
throw new GradleException("OSGi plugin unable to convert version to a compliant version");
}
return result;
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class AbstractJettyRunTask method startJettyInternal.
public void startJettyInternal() {
ProgressLoggerFactory progressLoggerFactory = getServices().get(ProgressLoggerFactory.class);
ProgressLogger progressLogger = progressLoggerFactory.newOperation(AbstractJettyRunTask.class).start("Start Jetty server", "Starting Jetty");
try {
setServer(createServer());
applyJettyXml();
JettyPluginServer plugin = getServer();
Object[] configuredConnectors = getConnectors();
plugin.setConnectors(configuredConnectors);
Object[] connectors = plugin.getConnectors();
if (connectors == null || connectors.length == 0) {
configuredConnectors = new Object[] { plugin.createDefaultConnector(getHttpPort()) };
plugin.setConnectors(configuredConnectors);
}
//set up a RequestLog if one is provided
if (getRequestLog() != null) {
getServer().setRequestLog(getRequestLog());
}
//set up the webapp and any context provided
getServer().configureHandlers();
configureWebApplication();
getServer().addWebApplication(webAppConfig);
// set up security realms
Object[] configuredRealms = getUserRealms();
for (int i = 0; (configuredRealms != null) && i < configuredRealms.length; i++) {
LOGGER.debug(configuredRealms[i].getClass().getName() + ": " + configuredRealms[i].toString());
}
plugin.setUserRealms(configuredRealms);
//do any other configuration required by the
//particular Jetty version
finishConfigurationBeforeStart();
// start Jetty
server.start();
if (getStopPort() != null && getStopPort() > 0 && getStopKey() != null) {
Monitor monitor = new Monitor(getStopPort(), getStopKey(), (Server) server.getProxiedObject());
monitor.start();
}
if (daemon) {
return;
}
// start the scanner thread (if necessary) on the main webapp
configureScanner();
startScanner();
// start the new line scanner thread if necessary
startConsoleScanner();
} catch (Exception e) {
throw new GradleException("Could not start the Jetty server.", e);
} finally {
progressLogger.completed();
}
progressLogger = progressLoggerFactory.newOperation(AbstractJettyRunTask.class).start("Run Jetty at http://localhost:" + getHttpPort() + "/" + getContextPath(), "Running at http://localhost:" + getHttpPort() + "/" + getContextPath());
try {
// keep the thread going if not in daemon mode
server.join();
} catch (Exception e) {
throw new GradleException("Failed to wait for the Jetty server to stop.", e);
} finally {
progressLogger.completed();
}
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class JacocoCoverageVerification method check.
@TaskAction
public void check() {
final Spec<File> fileExistsSpec = new Spec<File>() {
@Override
public boolean isSatisfiedBy(File file) {
return file.exists();
}
};
JacocoCheckResult checkResult = new AntJacocoCheck(getAntBuilder()).execute(getJacocoClasspath(), getProject().getName(), getAllClassDirs().filter(fileExistsSpec), getAllSourceDirs().filter(fileExistsSpec), getExecutionData(), getViolationRules());
if (!checkResult.isSuccess()) {
throw new GradleException(checkResult.getFailureMessage());
}
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class UnavailablePlatformToolProvider method failure.
private RuntimeException failure() {
TreeFormatter formatter = new TreeFormatter();
this.explain(formatter);
return new GradleException(formatter.toString());
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class ApiGroovyCompiler method applyConfigurationScript.
private void applyConfigurationScript(File configScript, CompilerConfiguration configuration) {
VersionNumber version = parseGroovyVersion();
if (version.compareTo(VersionNumber.parse("2.1")) < 0) {
throw new GradleException("Using a Groovy compiler configuration script requires Groovy 2.1+ but found Groovy " + version + "");
}
Binding binding = new Binding();
binding.setVariable("configuration", configuration);
CompilerConfiguration configuratorConfig = new CompilerConfiguration();
ImportCustomizer customizer = new ImportCustomizer();
customizer.addStaticStars("org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder");
configuratorConfig.addCompilationCustomizers(customizer);
GroovyShell shell = new GroovyShell(binding, configuratorConfig);
try {
shell.evaluate(configScript);
} catch (Exception e) {
throw new GradleException("Could not execute Groovy compiler configuration script: " + configScript.getAbsolutePath(), e);
}
}
Aggregations