Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from gradle:master #12

Merged
merged 12 commits into from
Jan 5, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import org.gradle.internal.declarativedsl.analysis.dataOfTypeOrNull
import org.gradle.internal.declarativedsl.evaluator.schema.DeclarativeScriptContext
import org.gradle.internal.declarativedsl.evaluator.schema.InterpretationSchemaBuilder
import org.gradle.internal.declarativedsl.evaluator.schema.InterpretationSchemaBuildingResult
import org.gradle.internal.service.scopes.Scope
import org.gradle.internal.service.scopes.ServiceScope
import org.gradle.kotlin.dsl.accessors.ContainerElementFactoryEntry
import org.gradle.kotlin.dsl.accessors.SoftwareTypeEntry
import org.gradle.kotlin.dsl.support.serviceOf
Expand Down Expand Up @@ -72,6 +74,7 @@ internal fun KotlinDslDclSchemaCollector.collectDclSchemaForKotlinDslTarget(targ
}


@ServiceScope(Scope.UserHome::class)
internal interface KotlinDslDclSchemaCollector {
fun collectContainerFactories(interpretationSequence: InterpretationSequence, classLoaderScope: ClassLoaderScope): List<ContainerElementFactoryEntry<TypeOf<*>>>
fun collectSoftwareTypes(softwareTypeRegistry: SoftwareTypeRegistry): List<SoftwareTypeEntry<TypeOf<*>>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import org.gradle.internal.service.Provides
import org.gradle.internal.service.ServiceRegistration
import org.gradle.internal.service.ServiceRegistrationProvider
import org.gradle.internal.service.scopes.AbstractGradleModuleServices
import org.gradle.kotlin.dsl.accessors.ProjectSchemaProvider
import org.gradle.kotlin.dsl.provider.KotlinScriptBasePluginsApplicator
import org.gradle.kotlin.dsl.provider.PrecompiledScriptPluginsSupport
import org.gradle.kotlin.dsl.provider.plugins.precompiled.DefaultPrecompiledScriptPluginsSupport


Expand All @@ -37,15 +40,15 @@ internal
object GradleUserHomeServices : ServiceRegistrationProvider {

@Provides
fun createProjectSchemaProvider(kotlinDslDclSchemaCollector: KotlinDslDclSchemaCollector) =
fun createProjectSchemaProvider(kotlinDslDclSchemaCollector: KotlinDslDclSchemaCollector): ProjectSchemaProvider =
DefaultProjectSchemaProvider(kotlinDslDclSchemaCollector)

@Provides
fun createKotlinScriptBasePluginsApplicator() =
fun createKotlinScriptBasePluginsApplicator(): KotlinScriptBasePluginsApplicator =
DefaultKotlinScriptBasePluginsApplicator()

@Provides
fun createPrecompiledScriptPluginsSupport() =
fun createPrecompiledScriptPluginsSupport(): PrecompiledScriptPluginsSupport =
DefaultPrecompiledScriptPluginsSupport()

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ import org.gradle.cache.scopes.GlobalScopedCacheBuilderFactory
import org.gradle.internal.execution.workspace.ImmutableWorkspaceProvider
import org.gradle.internal.execution.workspace.impl.CacheBasedImmutableWorkspaceProvider
import org.gradle.internal.file.FileAccessTimeJournal
import org.gradle.internal.service.scopes.Scope
import org.gradle.internal.service.scopes.ServiceScope
import java.io.Closeable


@ServiceScope(Scope.UserHome::class)
internal
class KotlinDslWorkspaceProvider(
cacheBuilderFactory: GlobalScopedCacheBuilderFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
package org.gradle.kotlin.dsl.provider

import org.gradle.api.internal.project.ProjectInternal
import org.gradle.internal.service.scopes.Scope
import org.gradle.internal.service.scopes.ServiceScope


@ServiceScope(Scope.UserHome::class)
interface KotlinScriptBasePluginsApplicator {

fun apply(project: ProjectInternal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ package org.gradle.kotlin.dsl.provider

import org.gradle.cache.internal.CrossBuildInMemoryCache
import org.gradle.cache.internal.CrossBuildInMemoryCacheFactory
import org.gradle.internal.service.scopes.Scope
import org.gradle.internal.service.scopes.ServiceScope
import org.gradle.kotlin.dsl.execution.CompiledScript

import org.gradle.kotlin.dsl.execution.ProgramId

import javax.inject.Inject


@ServiceScope(Scope.UserHome::class)
internal
class KotlinScriptClassloadingCache @Inject constructor(
cacheFactory: CrossBuildInMemoryCacheFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.file.SourceDirectorySet
import org.gradle.api.provider.Provider
import org.gradle.internal.service.scopes.Scope
import org.gradle.internal.service.scopes.ServiceScope

import java.io.File

Expand All @@ -32,6 +34,7 @@ import java.io.File
*
* This needs to be cross-version compatible.
*/
@ServiceScope(Scope.UserHome::class)
interface PrecompiledScriptPluginsSupport {

fun enableOn(target: Target): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
package org.gradle.kotlin.dsl.support

import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.internal.service.scopes.Scope
import org.gradle.internal.service.scopes.ServiceScope

import org.gradle.kotlin.dsl.embeddedKotlinVersion

import java.util.Properties


@ServiceScope(Scope.UserHome::class)
class EmbeddedKotlinProvider internal constructor() {

fun addDependenciesTo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
package org.gradle.internal.execution;

import org.gradle.api.file.FileCollection;
import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;
import org.gradle.internal.snapshot.FileSystemSnapshot;

/**
* Service for snapshotting {@link FileCollection}s.
*/
@ServiceScope({Scope.UserHome.class, Scope.BuildSession.class})
public interface FileCollectionSnapshotter {
interface Result {
FileSystemSnapshot getSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
import org.gradle.api.Describable;
import org.gradle.internal.concurrent.Stoppable;
import org.gradle.internal.operations.BuildOperationRef;
import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;

import javax.annotation.Nullable;
import java.time.Duration;

/**
* Manages timeouts for threads, interrupting them if the timeout is exceeded.
*/
@ServiceScope(Scope.UserHome.class)
public interface TimeoutHandler extends Stoppable {
/**
* Starts a timeout for the given thread. The thread is interrupted if the given timeout is exceeded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@

package org.gradle.internal.watch.vfs;

import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;

import java.io.File;
import java.util.stream.Stream;

@ServiceScope(Scope.UserHome.class)
public interface WatchableFileSystemDetector {
/**
* Returns the mount points of all file systems for which file system watching is not supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.gradle.internal.watch.vfs.impl;

import org.gradle.internal.file.FileHierarchySet;
import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;
import org.gradle.internal.vfs.FileSystemAccess;

import java.util.concurrent.atomic.AtomicReference;
Expand All @@ -31,6 +33,7 @@
* captured after the changes; to avoid this, after a known modification we assume no further modifications will
* happen to the same location, and all file events belong the know modifications instead.
*/
@ServiceScope(Scope.UserHome.class)
public class FileWatchingFilter implements FileSystemAccess.WriteListener {
private final FileHierarchySet immutableLocations;
private final AtomicReference<FileHierarchySet> locationsWrittenByCurrentBuild = new AtomicReference<>(FileHierarchySet.empty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
*/
package org.gradle.internal.hash;

import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;

import java.io.File;

@ServiceScope({Scope.UserHome.class, Scope.BuildSession.class})
public interface FileHasher {
/**
* Returns the hash of the current content of the given file. The provided file must exist and be a file (rather than, say, a directory).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* The global cache is managed by Gradle, so we Gradle needs to take care
* of informing all the infrastructure about changes to it.
*/
@ServiceScope(Scope.Global.class)
@ServiceScope({Scope.Global.class, Scope.UserHome.class})
public interface GlobalCache {
/**
* Returns the root directories of the global cache.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
package org.gradle.cache.internal;

import org.gradle.internal.serialize.Serializer;
import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;

import java.io.File;

/**
* A factory for caches that contain some calculated value for a particular file. Maintains a cross-build in-memory and persistent cache of computed values. The value for a given file is updated when the content of the file changes.
*/
@ServiceScope({Scope.UserHome.class, Scope.Gradle.class})
public interface FileContentCacheFactory {
/**
* Creates or locates a cache. The contents of the cache are reused across builds, where possible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

package org.gradle.workers.internal;

import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;
import org.gradle.workers.WorkAction;
import org.gradle.workers.WorkParameters;

@ServiceScope(Scope.UserHome.class)
public interface ActionExecutionSpecFactory {
<T extends WorkParameters> TransportableActionExecutionSpec newTransportableSpec(IsolatedParametersActionExecutionSpec<T> spec);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.gradle.internal.classloader.FilteringClassLoader;
import org.gradle.internal.classloader.VisitableURLClassLoader;
import org.gradle.internal.classpath.DefaultClassPath;
import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;

import java.io.File;
import java.net.URL;
Expand All @@ -30,6 +32,7 @@
import java.util.LinkedHashSet;
import java.util.Set;

@ServiceScope(Scope.UserHome.class)
public class ClassLoaderStructureProvider {
private final ClassLoaderRegistry classLoaderRegistry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.gradle.internal.serialize.DefaultSerializerRegistry;
import org.gradle.internal.serialize.Encoder;
import org.gradle.internal.serialize.Serializer;
import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;
import org.gradle.internal.snapshot.impl.AbstractIsolatedMap;
import org.gradle.internal.snapshot.impl.ArrayOfPrimitiveValueSnapshot;
import org.gradle.internal.snapshot.impl.AttributeDefinitionSnapshot;
Expand Down Expand Up @@ -59,6 +61,7 @@

import static org.gradle.internal.classloader.ClassLoaderUtils.classFromContextLoader;

@ServiceScope(Scope.UserHome.class)
public class IsolatableSerializerRegistry extends DefaultSerializerRegistry {
private static final byte STRING_VALUE = (byte) 0;
private static final byte BOOLEAN_VALUE = (byte) 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.gradle.internal.logging.events.OutputEvent;
import org.gradle.internal.logging.events.OutputEventListener;
import org.gradle.internal.os.OperatingSystem;
import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;
import org.gradle.internal.session.BuildSessionLifecycleListener;
import org.gradle.process.internal.health.memory.MemoryManager;
import org.gradle.process.internal.health.memory.OsMemoryInfo;
Expand All @@ -40,6 +42,7 @@

import static java.util.Comparator.comparingInt;

@ServiceScope(Scope.UserHome.class)
public class WorkerDaemonClientsManager implements Stoppable {

private static final Logger LOGGER = Logging.getLogger(WorkerDaemonClientsManager.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@

package org.gradle.initialization;

import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;

import java.io.File;

@ServiceScope(Scope.UserHome.class)
public interface GradleUserHomeDirProvider {
/**
* Returns the user home directory for the current build.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

import org.gradle.internal.classpath.ClassPath;
import org.gradle.internal.hash.HashCode;
import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;

@ServiceScope(Scope.UserHome.class)
public interface ClasspathHasher {
/**
* Returns a strong hash for a given classpath.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@

import org.gradle.internal.classpath.ClassPath;
import org.gradle.internal.hash.HashCode;
import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;

import javax.annotation.Nullable;

/**
* A {@link ClassLoaderFactory} that also stores the hash of each created classloader which is later retrievable via {@link #getClassLoaderClasspathHash(ClassLoader)}.
*/
@ServiceScope(Scope.UserHome.class)
public interface HashingClassLoaderFactory extends ClassLoaderFactory {
/**
* Creates a {@link ClassLoader} with the given parent and classpath. Use the given hash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.gradle.api.internal.file.temp.TemporaryFileProvider;
import org.gradle.cache.FileLockManager;
import org.gradle.cache.GlobalCache;
import org.gradle.cache.UnscopedCacheBuilderFactory;
import org.gradle.cache.internal.CacheFactory;
import org.gradle.cache.internal.DefaultCacheFactory;
Expand Down Expand Up @@ -89,7 +90,7 @@ UnscopedCacheBuilderFactory createCacheRepository(CacheFactory cacheFactory) {
return new DefaultUnscopedCacheBuilderFactory(cacheFactory);
}

@Provides
@Provides({GlobalScopedCacheBuilderFactory.class, GlobalCache.class})
DefaultGlobalScopedCacheBuilderFactory createGlobalScopedCache(GlobalCacheDir globalCacheDir, UnscopedCacheBuilderFactory unscopedCacheBuilderFactory) {
return new DefaultGlobalScopedCacheBuilderFactory(globalCacheDir.getDir(), unscopedCacheBuilderFactory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.gradle.tooling.internal.provider.serialization;

import org.gradle.internal.classloader.ClassLoaderSpec;
import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;

import java.util.List;

Expand All @@ -25,6 +27,7 @@
*
* <p>Implementations are not required to be thread-safe.</p>
*/
@ServiceScope(Scope.UserHome.class)
public interface PayloadClassLoaderFactory {
ClassLoader getClassLoaderFor(ClassLoaderSpec spec, List<? extends ClassLoader> parents);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.gradle.internal.IoActions;
import org.gradle.internal.UncheckedException;
import org.gradle.internal.io.StreamByteBuffer;
import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;

import javax.annotation.Nullable;
import java.io.IOException;
Expand All @@ -32,6 +34,7 @@
import java.util.Map;

@ThreadSafe
@ServiceScope(Scope.UserHome.class)
public class PayloadSerializer {
private final PayloadClassLoaderRegistry classLoaderRegistry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@

package org.gradle.internal.file;

import org.gradle.internal.service.scopes.Scope;
import org.gradle.internal.service.scopes.ServiceScope;

import java.io.File;

@ServiceScope(Scope.UserHome.class)
public interface FileAccessTimeJournal {

long getLastAccessTime(File file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* Checks that services are being declared in the correct scope.
* <p>
* Only services that are annotated with {@link ServiceScope} are validated.
* In {@link #strict}-mode all services must be annotated.
*/
class ServiceScopeValidator implements AnnotatedServiceLifecycleHandler {

Expand Down
Loading
Loading