use of org.gradle.internal.classpath.DefaultClassPath in project gradle by gradle.
the class PluginResolutionServiceResolver method resolvePluginDependencies.
private ClassPath resolvePluginDependencies(final PluginUseMetaData metadata) {
DependencyResolutionServices resolution = dependencyResolutionServicesFactory.create();
RepositoryHandler repositories = resolution.getResolveRepositoryHandler();
final String repoUrl = metadata.implementation.get("repo");
repositories.maven(new Action<MavenArtifactRepository>() {
public void execute(MavenArtifactRepository mavenArtifactRepository) {
mavenArtifactRepository.setUrl(repoUrl);
}
});
Dependency dependency = resolution.getDependencyHandler().create(metadata.implementation.get("gav"));
ConfigurationContainerInternal configurations = (ConfigurationContainerInternal) resolution.getConfigurationContainer();
ConfigurationInternal configuration = configurations.detachedConfiguration(dependency);
try {
Set<File> files = configuration.getResolvedConfiguration().getFiles(Specs.satisfyAll());
return new DefaultClassPath(files);
} catch (ResolveException e) {
throw new DependencyResolutionException("Failed to resolve all plugin dependencies from " + repoUrl, e.getCause());
}
}
use of org.gradle.internal.classpath.DefaultClassPath in project gradle by gradle.
the class DefaultVersionedPlayRunAdapter method getBuildLink.
@Override
public Object getBuildLink(final ClassLoader classLoader, 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));
reload();
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")) {
// 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 (reload.getAndSet(false)) {
ClassPath classpath = new DefaultClassPath(applicationJar).plus(new DefaultClassPath(changingClasspath));
URLClassLoader currentClassLoader = new URLClassLoader(classpath.getAsURLArray(), assetsClassLoader);
storeClassLoader(currentClassLoader);
return currentClassLoader;
} else {
Throwable failure = buildFailure;
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;
}
});
}
use of org.gradle.internal.classpath.DefaultClassPath in project gradle by gradle.
the class WorkerProcessClassPathProvider method findClassPath.
public ClassPath findClassPath(String name) {
if (name.equals("WORKER_MAIN")) {
synchronized (lock) {
if (workerClassPath == null) {
workerClassPathCache = cacheRepository.cache("workerMain").withInitializer(new CacheInitializer()).open();
workerClassPath = new DefaultClassPath(jarFile(workerClassPathCache));
}
LOGGER.debug("Using worker process classpath: {}", workerClassPath);
return workerClassPath;
}
}
return null;
}
use of org.gradle.internal.classpath.DefaultClassPath in project gradle by gradle.
the class ForegroundDaemonAction method run.
public void run() {
LoggingManagerInternal loggingManager = loggingRegistry.newInstance(LoggingManagerInternal.class);
loggingManager.start();
DaemonServices daemonServices = new DaemonServices(configuration, loggingRegistry, loggingManager, new DefaultClassPath());
Daemon daemon = daemonServices.get(Daemon.class);
DaemonRegistry daemonRegistry = daemonServices.get(DaemonRegistry.class);
DaemonExpirationStrategy expirationStrategy = daemonServices.get(MasterExpirationStrategy.class);
daemon.start();
try {
daemonRegistry.markState(daemon.getAddress(), Idle);
daemon.stopOnExpiration(expirationStrategy, configuration.getPeriodicCheckIntervalMs());
} finally {
daemon.stop();
}
}
use of org.gradle.internal.classpath.DefaultClassPath in project gradle by gradle.
the class DaemonMain method doAction.
@Override
protected void doAction(String[] args, ExecutionListener listener) {
//The first argument is not really used but it is very useful in diagnosing, i.e. running 'jps -m'
if (args.length != 1) {
invalidArgs("Following arguments are required: <gradle-version>");
}
// Read configuration from stdin
List<String> startupOpts;
File gradleHomeDir;
File daemonBaseDir;
int idleTimeoutMs;
int periodicCheckIntervalMs;
String daemonUid;
List<File> additionalClassPath;
KryoBackedDecoder decoder = new KryoBackedDecoder(new EncodedStream.EncodedInput(System.in));
try {
gradleHomeDir = new File(decoder.readString());
daemonBaseDir = new File(decoder.readString());
idleTimeoutMs = decoder.readSmallInt();
periodicCheckIntervalMs = decoder.readSmallInt();
daemonUid = decoder.readString();
int argCount = decoder.readSmallInt();
startupOpts = new ArrayList<String>(argCount);
for (int i = 0; i < argCount; i++) {
startupOpts.add(decoder.readString());
}
int additionalClassPathLength = decoder.readSmallInt();
additionalClassPath = new ArrayList<File>(additionalClassPathLength);
for (int i = 0; i < additionalClassPathLength; i++) {
additionalClassPath.add(new File(decoder.readString()));
}
} catch (EOFException e) {
throw new UncheckedIOException(e);
}
NativeServices.initialize(gradleHomeDir);
DaemonServerConfiguration parameters = new DefaultDaemonServerConfiguration(daemonUid, daemonBaseDir, idleTimeoutMs, periodicCheckIntervalMs, startupOpts);
LoggingServiceRegistry loggingRegistry = LoggingServiceRegistry.newCommandLineProcessLogging();
LoggingManagerInternal loggingManager = loggingRegistry.newInstance(LoggingManagerInternal.class);
DaemonServices daemonServices = new DaemonServices(parameters, loggingRegistry, loggingManager, new DefaultClassPath(additionalClassPath));
File daemonLog = daemonServices.getDaemonLogFile();
// Any logging prior to this point will not end up in the daemon log file.
initialiseLogging(loggingManager, daemonLog);
// Detach the process from the parent terminal/console
ProcessEnvironment processEnvironment = daemonServices.get(ProcessEnvironment.class);
processEnvironment.maybeDetachProcess();
LOGGER.debug("Assuming the daemon was started with following jvm opts: {}", startupOpts);
Daemon daemon = daemonServices.get(Daemon.class);
daemon.start();
try {
DaemonContext daemonContext = daemonServices.get(DaemonContext.class);
Long pid = daemonContext.getPid();
daemonStarted(pid, daemon.getUid(), daemon.getAddress(), daemonLog);
DaemonExpirationStrategy expirationStrategy = daemonServices.get(MasterExpirationStrategy.class);
daemon.stopOnExpiration(expirationStrategy, parameters.getPeriodicCheckIntervalMs());
} finally {
daemon.stop();
}
}
Aggregations