当前位置: 首页>>代码示例>>Java>>正文


Java UncheckedException类代码示例

本文整理汇总了Java中org.gradle.internal.UncheckedException的典型用法代码示例。如果您正苦于以下问题:Java UncheckedException类的具体用法?Java UncheckedException怎么用?Java UncheckedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UncheckedException类属于org.gradle.internal包,在下文中一共展示了UncheckedException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getClasspathForClass

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public static File getClasspathForClass(Class<?> targetClass) {
    URI location;
    try {
        CodeSource codeSource = targetClass.getProtectionDomain().getCodeSource();
        if (codeSource != null && codeSource.getLocation() != null) {
            location = codeSource.getLocation().toURI();
            if (location.getScheme().equals("file")) {
                return new File(location);
            }
        }
        if (targetClass.getClassLoader() != null) {
            String resourceName = targetClass.getName().replace('.', '/') + ".class";
            URL resource = targetClass.getClassLoader().getResource(resourceName);
            if (resource != null) {
                return getClasspathForResource(resource, resourceName);
            }
        }
        throw new GradleException(String.format("Cannot determine classpath for class %s.", targetClass.getName()));
    } catch (URISyntaxException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:ClasspathUtil.java

示例2: send

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
@Override
public void send(String title, String message) {
    String isRunning = "\ntell application \"System Events\"\n"
        + "set isRunning to count of (every process whose bundle identifier is \"com.Growl.GrowlHelperApp\") > 0\n"
        + "end tell\n" + "return isRunning\n";
    try {
        Object value = engine.eval(isRunning);
        if (value.equals(0)) {
            throw new AnnouncerUnavailableException("Growl is not running.");
        }
        final File icon = iconProvider.getIcon(48, 48);
        String iconDef = icon != null ? "image from location ((POSIX file \"" + icon.getAbsolutePath() + "\") as string) as alias" : "";
        String script = "\ntell application id \"com.Growl.GrowlHelperApp\"\n"
            + "register as application \"Gradle\" all notifications {\"Build Notification\"} default notifications {\"Build Notification\"}\n"
            + "notify with name \"Build Notification\" title \"" + escape(title) + "\" description \"" + escape(message)
            + "\" application name \"Gradle\"" + iconDef
            + "\nend tell\n";
        engine.eval(script);
    } catch (ScriptException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:AppleScriptBackedGrowlAnnouncer.java

示例3: execute

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
@Override
public void execute(final WorkerProcessContext workerProcessContext) {
    LOGGER.info("{} started executing tests.", workerProcessContext.getDisplayName());

    completed = new CountDownLatch(1);

    System.setProperty(WORKER_ID_SYS_PROPERTY, workerProcessContext.getWorkerId().toString());

    DefaultServiceRegistry testServices = new TestFrameworkServiceRegistry(workerProcessContext);
    startReceivingTests(workerProcessContext, testServices);

    try {
        try {
            completed.await();
        } catch (InterruptedException e) {
            throw new UncheckedException(e);
        }
    } finally {
        LOGGER.info("{} finished executing tests.", workerProcessContext.getDisplayName());
        // Clean out any security manager the tests might have installed
        System.setSecurityManager(null);
        testServices.close();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:25,代码来源:TestWorker.java

示例4: toStoppable

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
private static Stoppable toStoppable(final Object object) {
    if (object instanceof Stoppable) {
        return (Stoppable) object;
    }
    if (object instanceof Closeable) {
        final Closeable closeable = (Closeable) object;
        return new Stoppable() {
            @Override
            public String toString() {
                return closeable.toString();
            }

            public void stop() {
                try {
                    closeable.close();
                } catch (IOException e) {
                    throw UncheckedException.throwAsUncheckedException(e);
                }
            }
        };
    }
    return NO_OP_STOPPABLE;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:24,代码来源:CompositeStoppable.java

示例5: stop

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public void stop() {
    Throwable failure = null;
    try {
        for (Stoppable element : elements) {
            try {
                element.stop();
            } catch (Throwable throwable) {
                if (failure == null) {
                    failure = throwable;
                } else {
                    LOGGER.error(String.format("Could not stop %s.", element), throwable);
                }
            }
        }
    } finally {
        elements.clear();
    }

    if (failure != null) {
        throw UncheckedException.throwAsUncheckedException(failure);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:CompositeStoppable.java

示例6: getClasspath

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public static ClassPath getClasspath(ClassLoader classLoader) {
    final List<File> implementationClassPath = new ArrayList<File>();
    new ClassLoaderVisitor() {
        @Override
        public void visitClassPath(URL[] classPath) {
            for (URL url : classPath) {
                try {
                    implementationClassPath.add(new File(url.toURI()));
                } catch (URISyntaxException e) {
                    throw new UncheckedException(e);
                }
            }
        }
    }.visit(classLoader);
    return DefaultClassPath.of(implementationClassPath);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:ClasspathUtil.java

示例7: connectToCanceledDaemon

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
private DaemonClientConnection connectToCanceledDaemon(Collection<DaemonInfo> busyDaemons, ExplainingSpec<DaemonContext> constraint) {
    DaemonClientConnection connection = null;
    final Pair<Collection<DaemonInfo>, Collection<DaemonInfo>> canceledBusy = partitionByState(busyDaemons, Canceled);
    final Collection<DaemonInfo> compatibleCanceledDaemons = getCompatibleDaemons(canceledBusy.getLeft(), constraint);
    if (!compatibleCanceledDaemons.isEmpty()) {
        LOGGER.info(DaemonMessages.WAITING_ON_CANCELED);
        CountdownTimer timer = Timers.startTimer(CANCELED_WAIT_TIMEOUT);
        while (connection == null && !timer.hasExpired()) {
            try {
                sleep(200);
                connection = connectToIdleDaemon(daemonRegistry.getIdle(), constraint);
            } catch (InterruptedException e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    }
    return connection;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:DefaultDaemonConnector.java

示例8: stop

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public void stop() {
    lifecycleLock.lock();
    try {
        if (!stopped) {
            try {
                disconnectableInput.close();
            } catch (IOException e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }

            forwardingExecuter.stop();
            stopped = true;
        }
    } finally {
        lifecycleLock.unlock();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:InputForwarder.java

示例9: getEffectiveManifest

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
@Override
public DefaultManifest getEffectiveManifest() {
    ContainedVersionAnalyzer analyzer = analyzerFactory.create();
    DefaultManifest effectiveManifest = new DefaultManifest(null);
    try {
        setAnalyzerProperties(analyzer);
        Manifest osgiManifest = analyzer.calcManifest();
        java.util.jar.Attributes attributes = osgiManifest.getMainAttributes();
        for (Map.Entry<Object, Object> entry : attributes.entrySet()) {
            effectiveManifest.attributes(WrapUtil.toMap(entry.getKey().toString(), (String) entry.getValue()));
        }
        effectiveManifest.attributes(this.getAttributes());
        for (Map.Entry<String, Attributes> ent : getSections().entrySet()) {
            effectiveManifest.attributes(ent.getValue(), ent.getKey());
        }
        if (classesDir != null) {
            long mod = classesDir.lastModified();
            if (mod > 0) {
                effectiveManifest.getAttributes().put(Analyzer.BND_LASTMODIFIED, mod);
            }
        }
    } catch (Exception e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
    return getEffectiveManifestInternal(effectiveManifest);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:27,代码来源:DefaultOsgiManifest.java

示例10: openJarOutputStream

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
private ZipOutputStream openJarOutputStream(File outputJar) {
    try {
        ZipOutputStream outputStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(outputJar), BUFFER_SIZE));
        outputStream.setLevel(0);
        return outputStream;
    } catch (IOException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:RuntimeShadedJarCreator.java

示例11: run

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
private void run() {
    ClassLoaderUtils.disableUrlConnectionCaching();
    final Thread thread = Thread.currentThread();
    final ClassLoader previousContextClassLoader = thread.getContextClassLoader();
    final ClassLoader classLoader = new URLClassLoader(new DefaultClassPath(runSpec.getClasspath()).getAsURLArray(), null);
    thread.setContextClassLoader(classLoader);
    try {
        Object buildDocHandler = runAdapter.getBuildDocHandler(classLoader, runSpec.getClasspath());
        Object buildLink = runAdapter.getBuildLink(classLoader, runSpec.getProjectPath(), runSpec.getApplicationJar(), runSpec.getChangingClasspath(), runSpec.getAssetsJar(), runSpec.getAssetsDirs());
        runAdapter.runDevHttpServer(classLoader, classLoader, buildLink, buildDocHandler, runSpec.getHttpPort());
    } catch (Exception e) {
        throw UncheckedException.throwAsUncheckedException(e);
    } finally {
        thread.setContextClassLoader(previousContextClassLoader);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:PlayWorkerServer.java

示例12: readConfigMappings

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
private static Map<String, List<String>> readConfigMappings(DependencyDescriptor dependencyDescriptor) {
    if (dependencyDescriptor instanceof DefaultDependencyDescriptor) {
        try {
            return (Map<String, List<String>>) DEPENDENCY_CONFIG_FIELD.get(dependencyDescriptor);
        } catch (IllegalAccessException e) {
            throw UncheckedException.throwAsUncheckedException(e);
        }
    }

    String[] modConfs = dependencyDescriptor.getModuleConfigurations();
    Map<String, List<String>> results = Maps.newLinkedHashMap();
    for (String modConf : modConfs) {
        results.put(modConf, Arrays.asList(dependencyDescriptor.getDependencyConfigurations(modConfs)));
    }
    return results;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:IvyModuleDescriptorConverter.java

示例13: putModuleDescriptor

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public LocallyAvailableResource putModuleDescriptor(ModuleComponentAtRepositoryKey component, final ModuleComponentResolveMetadata metadata) {
    String filePath = getFilePath(component);
    return metaDataStore.add(filePath, new Action<File>() {
        public void execute(File moduleDescriptorFile) {
            try {
                KryoBackedEncoder encoder = new KryoBackedEncoder(new FileOutputStream(moduleDescriptorFile));
                try {
                    moduleMetadataSerializer.write(encoder, metadata);
                } finally {
                    encoder.close();
                }
            } catch (Exception e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:ModuleMetadataStore.java

示例14: stop

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public void stop() {
    lock.lock();
    try {
        stopped = true;
        while (!executing.isEmpty()) {
            try {
                condition.await();
            } catch (InterruptedException e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
        this.connection = null;
    } finally {
        lock.unlock();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:LazyConsumerActionExecutor.java

示例15: getBuildDocHandler

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
@Override
public Object getBuildDocHandler(ClassLoader docsClassLoader, Iterable<File> classpath) throws NoSuchMethodException, ClassNotFoundException, IOException, IllegalAccessException {
    Class<?> docHandlerFactoryClass = getDocHandlerFactoryClass(docsClassLoader);
    Method docHandlerFactoryMethod = docHandlerFactoryClass.getMethod("fromJar", JarFile.class, String.class);
    JarFile documentationJar = findDocumentationJar(classpath);
    try {
        return docHandlerFactoryMethod.invoke(null, documentationJar, "play/docs/content");
    } catch (InvocationTargetException e) {
        throw UncheckedException.unwrapAndRethrow(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:12,代码来源:DefaultVersionedPlayRunAdapter.java


注:本文中的org.gradle.internal.UncheckedException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。