Search in sources :

Example 1 with ModelRegistry

use of org.gradle.model.internal.registry.ModelRegistry in project gradle by gradle.

the class RuleBasedPluginApplicator method applyRules.

public void applyRules(@Nullable String pluginId, Class<?> clazz) {
    ModelRegistry modelRegistry = target.getModelRegistry();
    Iterable<Class<? extends RuleSource>> declaredSources = ruleDetector.getDeclaredSources(clazz);
    for (Class<? extends RuleSource> ruleSource : declaredSources) {
        ExtractedRuleSource<?> rules = ruleInspector.extract(ruleSource);
        for (Class<?> dependency : rules.getRequiredPlugins()) {
            target.getPluginManager().apply(dependency);
        }
        modelRegistry.getRoot().applyToSelf(rules);
    }
}
Also used : RuleSource(org.gradle.model.RuleSource) ExtractedRuleSource(org.gradle.model.internal.inspect.ExtractedRuleSource) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry)

Example 2 with ModelRegistry

use of org.gradle.model.internal.registry.ModelRegistry in project gradle by gradle.

the class XCTestConventionPlugin method configureTestSuiteBuildingTasks.

private void configureTestSuiteBuildingTasks(ProjectInternal project, final DefaultSwiftXCTestBinary binary) {
    if (binary instanceof SwiftXCTestBundle) {
        TaskContainer tasks = project.getTasks();
        final Names names = binary.getNames();
        SwiftCompile compile = binary.getCompileTask().get();
        // TODO - creating a bundle should be done by some general purpose plugin
        // TODO - make this lazy
        DefaultNativePlatform currentPlatform = new DefaultNativePlatform("current");
        final ModelRegistry modelRegistry = project.getModelRegistry();
        NativeToolChain toolChain = modelRegistry.realize("toolChains", NativeToolChainRegistryInternal.class).getForPlatform(currentPlatform);
        // Platform specific arguments
        compile.getCompilerArgs().addAll(project.provider(new Callable<List<String>>() {

            @Override
            public List<String> call() {
                File frameworkDir = new File(sdkPlatformPathLocator.find(), "Developer/Library/Frameworks");
                return Arrays.asList("-parse-as-library", "-F" + frameworkDir.getAbsolutePath());
            }
        }));
        // Add a link task
        final LinkMachOBundle link = tasks.create(names.getTaskName("link"), LinkMachOBundle.class);
        link.getLinkerArgs().set(project.provider(new Callable<List<String>>() {

            @Override
            public List<String> call() {
                File frameworkDir = new File(sdkPlatformPathLocator.find(), "Developer/Library/Frameworks");
                return Lists.newArrayList("-F" + frameworkDir.getAbsolutePath(), "-framework", "XCTest", "-Xlinker", "-rpath", "-Xlinker", "@executable_path/../Frameworks", "-Xlinker", "-rpath", "-Xlinker", "@loader_path/../Frameworks");
            }
        }));
        InstallXCTestBundle install = tasks.create(names.getTaskName("install"), InstallXCTestBundle.class);
        install.getBundleBinaryFile().set(link.getLinkedFile());
        install.getInstallDirectory().set(project.getLayout().getBuildDirectory().dir("install/" + names.getDirName()));
        binary.getInstallDirectory().set(install.getInstallDirectory());
        link.source(binary.getObjects());
        link.lib(binary.getLinkLibraries());
        final PlatformToolProvider toolProvider = ((NativeToolChainInternal) toolChain).select(currentPlatform);
        Provider<RegularFile> exeLocation = project.getLayout().getBuildDirectory().file(project.getProviders().provider(new Callable<String>() {

            @Override
            public String call() {
                return toolProvider.getExecutableName("exe/" + names.getDirName() + binary.getBaseName().get());
            }
        }));
        link.getLinkedFile().set(exeLocation);
        link.getTargetPlatform().set(currentPlatform);
        link.getToolChain().set(toolChain);
        link.getDebuggable().set(binary.isDebuggable());
        binary.getExecutableFile().set(link.getLinkedFile());
        DefaultSwiftXCTestBundle bundle = (DefaultSwiftXCTestBundle) binary;
        bundle.getLinkTask().set(link);
        bundle.getRunScriptFile().set(install.getRunScriptFile());
    } else {
        DefaultSwiftXCTestExecutable executable = (DefaultSwiftXCTestExecutable) binary;
        executable.getRunScriptFile().set(executable.getInstallTask().get().getRunScriptFile());
    }
}
Also used : DefaultSwiftXCTestExecutable(org.gradle.nativeplatform.test.xctest.internal.DefaultSwiftXCTestExecutable) RegularFile(org.gradle.api.file.RegularFile) NativeToolChain(org.gradle.nativeplatform.toolchain.NativeToolChain) SwiftXCTestBundle(org.gradle.nativeplatform.test.xctest.SwiftXCTestBundle) DefaultSwiftXCTestBundle(org.gradle.nativeplatform.test.xctest.internal.DefaultSwiftXCTestBundle) Callable(java.util.concurrent.Callable) Names(org.gradle.language.nativeplatform.internal.Names) InstallXCTestBundle(org.gradle.nativeplatform.test.xctest.tasks.InstallXCTestBundle) NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) TaskContainer(org.gradle.api.tasks.TaskContainer) SwiftCompile(org.gradle.language.swift.tasks.SwiftCompile) NativeToolChainRegistryInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainRegistryInternal) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) DefaultNativePlatform(org.gradle.nativeplatform.platform.internal.DefaultNativePlatform) LinkMachOBundle(org.gradle.nativeplatform.tasks.LinkMachOBundle) DefaultSwiftXCTestBundle(org.gradle.nativeplatform.test.xctest.internal.DefaultSwiftXCTestBundle) File(java.io.File) RegularFile(org.gradle.api.file.RegularFile)

Example 3 with ModelRegistry

use of org.gradle.model.internal.registry.ModelRegistry in project gradle by gradle.

the class DefaultProject method model.

// Not part of the public API
public void model(Closure<?> modelRules) {
    prepareForRuleBasedPlugins();
    ModelRegistry modelRegistry = getModelRegistry();
    if (TransformedModelDslBacking.isTransformedBlock(modelRules)) {
        ClosureBackedAction.execute(new TransformedModelDslBacking(modelRegistry, this.getRootProject().getFileResolver()), modelRules);
    } else {
        new NonTransformedModelDslBacking(modelRegistry).configure(modelRules);
    }
}
Also used : ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) NonTransformedModelDslBacking(org.gradle.model.dsl.internal.NonTransformedModelDslBacking) TransformedModelDslBacking(org.gradle.model.dsl.internal.TransformedModelDslBacking) NonTransformedModelDslBacking(org.gradle.model.dsl.internal.NonTransformedModelDslBacking)

Example 4 with ModelRegistry

use of org.gradle.model.internal.registry.ModelRegistry in project gradle by gradle.

the class ProjectLibraryBinaryLocator method getBinaries.

// Converts the binaries of a project library into regular binary instances
@Nullable
@Override
public DomainObjectSet<NativeLibraryBinary> getBinaries(LibraryIdentifier libraryIdentifier) {
    ModelRegistry projectModel = projectModelResolver.resolveProjectModel(libraryIdentifier.getProjectPath());
    ComponentSpecContainer components = projectModel.find("components", ComponentSpecContainer.class);
    if (components == null) {
        return null;
    }
    String libraryName = libraryIdentifier.getLibraryName();
    NativeLibrarySpec library = components.withType(NativeLibrarySpec.class).get(libraryName);
    if (library == null) {
        return null;
    }
    ModelMap<NativeBinarySpec> projectBinaries = library.getBinaries().withType(NativeBinarySpec.class);
    DomainObjectSet<NativeLibraryBinary> binaries = domainObjectCollectionFactory.newDomainObjectSet(NativeLibraryBinary.class);
    for (NativeBinarySpec nativeBinarySpec : projectBinaries.values()) {
        binaries.add((NativeLibraryBinary) nativeBinarySpec);
    }
    return binaries;
}
Also used : NativeLibraryBinary(org.gradle.nativeplatform.NativeLibraryBinary) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) NativeBinarySpec(org.gradle.nativeplatform.NativeBinarySpec) ComponentSpecContainer(org.gradle.platform.base.ComponentSpecContainer) NativeLibrarySpec(org.gradle.nativeplatform.NativeLibrarySpec) Nullable(javax.annotation.Nullable)

Example 5 with ModelRegistry

use of org.gradle.model.internal.registry.ModelRegistry in project gradle by gradle.

the class PrebuiltLibraryBinaryLocator method getBinaries.

@Nullable
@Override
public DomainObjectSet<NativeLibraryBinary> getBinaries(LibraryIdentifier library) {
    ModelRegistry projectModel = projectModelResolver.resolveProjectModel(library.getProjectPath());
    Repositories repositories = projectModel.find("repositories", Repositories.class);
    if (repositories == null) {
        return null;
    }
    PrebuiltLibrary prebuiltLibrary = getPrebuiltLibrary(repositories.withType(PrebuiltLibraries.class), library.getLibraryName());
    return prebuiltLibrary != null ? prebuiltLibrary.getBinaries() : null;
}
Also used : Repositories(org.gradle.nativeplatform.Repositories) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) PrebuiltLibrary(org.gradle.nativeplatform.PrebuiltLibrary) PrebuiltLibraries(org.gradle.nativeplatform.PrebuiltLibraries) Nullable(javax.annotation.Nullable)

Aggregations

ModelRegistry (org.gradle.model.internal.registry.ModelRegistry)13 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)3 File (java.io.File)2 Nullable (javax.annotation.Nullable)2 RegularFile (org.gradle.api.file.RegularFile)2 TaskAction (org.gradle.api.tasks.TaskAction)2 TaskContainer (org.gradle.api.tasks.TaskContainer)2 ProjectDetails (org.gradle.api.tasks.diagnostics.internal.ProjectDetails)2 StyledTextOutput (org.gradle.internal.logging.text.StyledTextOutput)2 Names (org.gradle.language.nativeplatform.internal.Names)2 SwiftCompile (org.gradle.language.swift.tasks.SwiftCompile)2 DefaultNativePlatform (org.gradle.nativeplatform.platform.internal.DefaultNativePlatform)2 LinkMachOBundle (org.gradle.nativeplatform.tasks.LinkMachOBundle)2 SwiftXCTestBundle (org.gradle.nativeplatform.test.xctest.SwiftXCTestBundle)2 DefaultSwiftXCTestBundle (org.gradle.nativeplatform.test.xctest.internal.DefaultSwiftXCTestBundle)2 DefaultSwiftXCTestExecutable (org.gradle.nativeplatform.test.xctest.internal.DefaultSwiftXCTestExecutable)2 InstallXCTestBundle (org.gradle.nativeplatform.test.xctest.tasks.InstallXCTestBundle)2 NativeToolChain (org.gradle.nativeplatform.toolchain.NativeToolChain)2 NativeToolChainInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal)2 NativeToolChainRegistryInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainRegistryInternal)2