org.gradle.internal.Cast Java Examples
The following examples show how to use
org.gradle.internal.Cast.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WrapperPlugin.java From native-samples with Apache License 2.0 | 6 votes |
public void apply(Project project) { project.getTasks().register("nightlyWrapper", Wrapper.class, task -> { task.getLogger().lifecycle("Locating nightly version ..."); try { Map<String, String> result = Cast.uncheckedCast(new JsonSlurper().parseText(IOUtils.toString(new URL("https://services.gradle.org/versions/nightly"), Charset.defaultCharset()))); if (result.isEmpty()) { throw new GradleException("Cannot update wrapper to 'nightly' version as there is currently no version of that label"); } String version = result.get("version"); String url = result.get("downloadUrl"); task.doFirst(t -> { task.getLogger().lifecycle("Updating wrapper to nightly version: " + version + " (downloadUrl: " + url + ")"); }); task.setDistributionUrl(url); task.setGroup("wrapper"); task.setDescription("Updates the samples to use the most recent nightly"); } catch (IOException e) { throw new UncheckedIOException(e); } }); }
Example #2
Source File: PublishToIvyRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void doPublish(final IvyPublicationInternal publication, final IvyArtifactRepository repository) { new PublishOperation(publication, repository) { @Override protected void publish() throws Exception { IvyNormalizedPublication normalizedPublication = publication.asNormalisedPublication(); IvyPublisher publisher = getIvyPublisher(); publisher.publish(normalizedPublication, Cast.cast(PublicationAwareRepository.class, repository)); } }.run(); }
Example #3
Source File: PublishToIvyRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void doPublish(final IvyPublicationInternal publication, final IvyArtifactRepository repository) { new PublishOperation(publication, repository) { @Override protected void publish() throws Exception { IvyNormalizedPublication normalizedPublication = publication.asNormalisedPublication(); IvyPublisher publisher = new DependencyResolverIvyPublisher(); publisher = new ValidatingIvyPublisher(publisher); publisher = new ContextualizingIvyPublisher(publisher, getServices().get(IvyContextManager.class)); publisher.publish(normalizedPublication, Cast.cast(PublicationAwareRepository.class, repository)); } }.run(); }
Example #4
Source File: RoutesCompilerAdapterV24X.java From playframework with Apache License 2.0 | 5 votes |
private RoutesCompilationErrorAdapter(Class<?> routesCompilationError, Class<?> option) { this.sourceMethod = Cast.uncheckedCast(JavaReflectionUtil.method(routesCompilationError, File.class, "source")); this.messageMethod = Cast.uncheckedCast(JavaReflectionUtil.method(routesCompilationError, String.class, "message")); this.lineMethod = Cast.uncheckedCast(JavaReflectionUtil.method(routesCompilationError, Object.class, "line")); this.columnMethod = Cast.uncheckedCast(JavaReflectionUtil.method(routesCompilationError, Object.class, "column")); this.getMethod = Cast.uncheckedCast(JavaReflectionUtil.method(option, Object.class, "get")); }
Example #5
Source File: RoutesCompilerAdapterV24X.java From playframework with Apache License 2.0 | 5 votes |
Integer toInt(Object optionInt) { try { return Cast.uncheckedCast(getMethod.invoke(optionInt)); } catch (Exception e) { return 0; } }
Example #6
Source File: ScalaOptionInvocationWrapper.java From playframework with Apache License 2.0 | 5 votes |
public T get() { try { return Cast.uncheckedCast(obj.getClass().getMethod("get").invoke(obj)); } catch (Exception e) { throw new RuntimeException(e); } }
Example #7
Source File: SourceCopyTask.java From native-samples with Apache License 2.0 | 5 votes |
private <T extends TemplateTarget> T add(T target) { if (projects.containsKey(target.getKey())) { return Cast.uncheckedCast(projects.get(target.getKey())); } projects.put(target.getKey(), target); return target; }
Example #8
Source File: PublishToIvyRepository.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void doPublish(final IvyPublicationInternal publication, final IvyArtifactRepository repository) { new PublishOperation(publication, repository) { @Override protected void publish() throws Exception { IvyNormalizedPublication normalizedPublication = publication.asNormalisedPublication(); IvyPublisher publisher = getIvyPublisher(); publisher.publish(normalizedPublication, Cast.cast(PublicationAwareRepository.class, repository)); } }.run(); }
Example #9
Source File: PublishToIvyRepository.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void doPublish(final IvyPublicationInternal publication, final IvyArtifactRepository repository) { new PublishOperation(publication, repository) { @Override protected void publish() throws Exception { IvyNormalizedPublication normalizedPublication = publication.asNormalisedPublication(); IvyPublisher publisher = new DependencyResolverIvyPublisher(); publisher = new ValidatingIvyPublisher(publisher); publisher = new ContextualizingIvyPublisher(publisher, getServices().get(IvyContextManager.class)); publisher.publish(normalizedPublication, Cast.cast(PublicationAwareRepository.class, repository)); } }.run(); }
Example #10
Source File: DefaultVersionedPlayRunAdapter.java From playframework with Apache License 2.0 | 4 votes |
@Override public Object getBuildLink(final ClassLoader classLoader, final Reloader reloader, final File projectPath, final File applicationJar, final Iterable<File> changingClasspath, final File assetsJar, final Iterable<File> assetsDirs) throws ClassNotFoundException { final ClassLoader assetsClassLoader = createAssetsClassLoader(assetsJar, assetsDirs, classLoader); final Class<? extends Throwable> playExceptionClass = Cast.uncheckedCast(classLoader.loadClass(PLAY_EXCEPTION_CLASSNAME)); return Proxy.newProxyInstance(classLoader, new Class<?>[]{getBuildLinkClass(classLoader)}, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals("projectPath")) { return projectPath; } else if (method.getName().equals("reload")) { Reloader.Result result = reloader.requireUpToDate(); // We can't close replaced loaders immediately, because their classes may be used during shutdown, // after the return of the reload() call that caused the loader to be swapped out. // We have no way of knowing when the loader is actually done with, so we use the request after the request // that triggered the reload as the trigger point to close the replaced loader. closeOldLoaders(); if (result.changed) { ClassPath classpath = DefaultClassPath.of(applicationJar).plus(DefaultClassPath.of(changingClasspath)); URLClassLoader currentClassLoader = new URLClassLoader(classpath.getAsURLArray(), assetsClassLoader); storeClassLoader(currentClassLoader); return currentClassLoader; } else { Throwable failure = result.failure; if (failure == null) { return null; } else { try { return DirectInstantiator.instantiate(playExceptionClass, "Gradle Build Failure", failure.getMessage(), failure); } catch (Exception e) { LOGGER.warn("Could not translate " + failure + " to " + PLAY_EXCEPTION_CLASSNAME, e); return failure; } } } } else if (method.getName().equals("settings")) { return new HashMap<String, String>(); } //TODO: all methods return null; } }); }
Example #11
Source File: DefaultVersionedPlayRunAdapter.java From playframework with Apache License 2.0 | 4 votes |
private void storeClassLoader(ClassLoader classLoader) { final ClassLoader previous = currentClassloader.getAndSet(classLoader); if (previous != null && previous instanceof Closeable) { loadersToClose.add(new SoftReference<Closeable>(Cast.cast(Closeable.class, previous))); } }