Java Code Examples for org.gradle.api.plugins.ExtensionContainer

The following examples show how to use org.gradle.api.plugins.ExtensionContainer. These examples are extracted from open source projects. 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 Project: gradle-modules-plugin   Source File: ModuleSystemPlugin.java    License: MIT License 6 votes vote down vote up
private void configureModularity(Project project, String moduleName) {
    ExtensionContainer extensions = project.getExtensions();
    extensions.add("moduleName", moduleName);
    extensions.create("patchModules", PatchModuleExtension.class);
    extensions.create(ModularityExtension.class, "modularity", DefaultModularityExtension.class, project);

    new CompileTask(project).configureCompileJava();
    new CompileModuleInfoTask(project).configureCompileModuleInfoJava();
    new MergeClassesTask(project).configureMergeClasses();
    new CompileTestTask(project).configureCompileTestJava();
    new TestTask(project).configureTestJava();
    new RunTask(project).configureRun();
    new JavadocTask(project).configureJavaDoc();
    ModularJavaExec.configure(project);
    ModularCreateStartScripts.configure(project);
    PatchModuleContainer.configure(project);
}
 
Example 2
@Override
public void apply(Project project) {
    final ConfigurationContainer configurations = project.getConfigurations();
    configurations.maybeCreate("test");
    configurations.maybeCreate("build");
    configurations.maybeCreate("tool");

    final ExtensionContainer extensions = project.getExtensions();
    final ExtensionAware golang = (ExtensionAware) extensions.create("golang", GolangSettings.class, true, project);
    golang.getExtensions().create("build", BuildSettings.class, true, project);
    golang.getExtensions().create("toolchain", ToolchainSettings.class, true, project);
    golang.getExtensions().create("dependencies", DependenciesSettings.class, true, project);
    golang.getExtensions().create("testing", TestingSettings.class, true, project);

    extensions.create(INSTANCE_PROPERTY_NAME, Reference.class, this);

    final TaskContainer tasks = project.getTasks();
    addTasks(tasks);
}
 
Example 3
protected RegisterTypeRule(ModelType<? extends T> type, ModelType<? extends U> implementation, ModelRuleDescriptor descriptor, Action<? super RegistrationContext<T, U>> registerAction) {
    this.type = type;
    this.implementation = implementation;
    this.descriptor = descriptor;
    this.registerAction = registerAction;

    subject = ModelReference.of("extensions", ExtensionContainer.class);
    inputs = ImmutableList.<ModelReference<?>>of(ModelReference.of(ProjectIdentifier.class));
}
 
Example 4
public final void mutate(final ExtensionContainer extensionContainer, final Inputs inputs) {
    RuleContext.inContext(getDescriptor(), new Runnable() {
        public void run() {
            RegistrationContext<T, U> context = new RegistrationContext<T, U>(type, implementation, extensionContainer, inputs.get(0, ModelType.of(ProjectIdentifier.class)).getInstance());
            registerAction.execute(context);
        }
    });
}
 
Example 5
Source Project: jig   Source File: JigGradlePlugin.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    ExtensionContainer extensions = project.getExtensions();
    extensions.create("jig", JigConfig.class);
    TaskContainer tasks = project.getTasks();

    JigReportsTask jigReports = tasks.create("jigReports", JigReportsTask.class);
    jigReports.setGroup("JIG");
    jigReports.setDescription("Generates JIG documentation for the main source code.");

    VerifyJigEnvironmentTask verifyTask = tasks.create("verifyJigEnvironment", VerifyJigEnvironmentTask.class);
    verifyTask.setGroup("JIG");
    verifyTask.setDescription("Verify JIG environment.");
}
 
Example 6
/**
 * Assemble the gradle project with appropriate task.
 */
private Project mockProject() {
  Project project = mock(Project.class);

  ExtensionContainer extension = mock(ExtensionContainer.class);
  when(project.getExtensions()).thenReturn(extension);
  when(project.getDisplayName()).thenReturn("Mock Mock");

  Task audit = mock(Task.class);
  when(audit.getProject()).thenReturn(project);
  when(project.task("audit")).thenReturn(audit);

  return project;
}
 
Example 7
/**
 * Assemble the gradle project with appropriate task.
 */
private Project mockProject() {
  Project project = mock(Project.class);

  ExtensionContainer extension = mock(ExtensionContainer.class);
  when(project.getExtensions()).thenReturn(extension);
  when(project.getDisplayName()).thenReturn("Mock Mock");

  Task audit = mock(Task.class);
  when(audit.getProject()).thenReturn(project);
  when(project.task("audit")).thenReturn(audit);

  return project;
}
 
Example 8
Source Project: gradle-golang-plugin   Source File: Settings.java    License: Mozilla Public License 2.0 5 votes vote down vote up
public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container) {
    _project = project;
    _golang = container.getByType(GolangSettings.class);
    if (!(_golang instanceof ExtensionAware)) {
        throw new IllegalStateException("golang instance (" + _golang + ") of provided extension container (" + container + ") is not an instance of " + ExtensionAware.class.getName() + ".");
    }
    final ExtensionContainer globalExtensions = ((ExtensionAware) _golang).getExtensions();
    _build = globalExtensions.getByType(BuildSettings.class);
    _toolchain = globalExtensions.getByType(ToolchainSettings.class);
    _dependencies = globalExtensions.getByType(DependenciesSettings.class);
    _testing = globalExtensions.getByType(TestingSettings.class);
}
 
Example 9
Source Project: gradle-golang-plugin   Source File: Settings.java    License: Mozilla Public License 2.0 5 votes vote down vote up
public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container, boolean init) {
    _project = project;
    _golang = container.create("golang", GolangSettings.class, init, project);
    final ExtensionContainer taskExtensions = ((ExtensionAware) _golang).getExtensions();
    _build = taskExtensions.create("build", BuildSettings.class, init, project);
    _toolchain = taskExtensions.create("toolchain", ToolchainSettings.class, init, project);
    _dependencies = taskExtensions.create("dependencies", DependenciesSettings.class, init, project);
    _testing = taskExtensions.create("testing", TestingSettings.class, init, project);
}
 
Example 10
Source Project: pygradle   Source File: ExtensionUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static <T> T maybeCreate(PythonExtension extension, String name, Class<T> type, Object... args) {
    ExtensionContainer extensionContainer = ((ExtensionAware) extension).getExtensions();
    T maybeExtension = extensionContainer.findByType(type);
    if (maybeExtension == null) {
        maybeExtension = extensionContainer.create(name, type, args);
    }
    return maybeExtension;
}
 
Example 11
@Before
public void setUp() {
    this.project = mock(Project.class);
    ExtensionContainer extensionContainer = mock(ExtensionContainer.class);
    this.pluginExtension = sampleExtension(this.project);
    when(extensionContainer.findByType(CfPluginExtension.class)).thenReturn(this.pluginExtension);
    when(this.project.getExtensions()).thenReturn(extensionContainer);
    this.cfPropertiesMapper = new CfPropertiesMapper(this.project);
}
 
Example 12
@Before
public void setUp() {
    this.project = mock(Project.class);
    ExtensionContainer extensionContainer = mock(ExtensionContainer.class);
    this.pluginExtension = sampleExtension(this.project);
    when(extensionContainer.findByType(CfPluginExtension.class)).thenReturn(this.pluginExtension);
    when(this.project.getExtensions()).thenReturn(extensionContainer);
}
 
Example 13
protected RegisterTypeRule(ModelType<? extends T> type, ModelType<? extends U> implementation, ModelRuleDescriptor descriptor, Action<? super RegistrationContext<T, U>> registerAction) {
    this.type = type;
    this.implementation = implementation;
    this.descriptor = descriptor;
    this.registerAction = registerAction;

    subject = ModelReference.of("extensions", ExtensionContainer.class);
    inputs = ImmutableList.<ModelReference<?>>of(ModelReference.of(ProjectIdentifier.class));
}
 
Example 14
public final void mutate(final ExtensionContainer extensionContainer, final Inputs inputs) {
    RuleContext.inContext(getDescriptor(), new Runnable() {
        public void run() {
            RegistrationContext<T, U> context = new RegistrationContext<T, U>(type, implementation, extensionContainer, inputs.get(0, ModelType.of(ProjectIdentifier.class)).getInstance());
            registerAction.execute(context);
        }
    });
}
 
Example 15
public RegistrationContext(ModelType<? extends T> type, ModelType<? extends U> implementation, ExtensionContainer extensions, ProjectIdentifier projectIdentifier) {
    this.type = type;
    this.implementation = implementation;
    this.extensions = extensions;
    this.projectIdentifier = projectIdentifier;
}
 
Example 16
public ExtensionContainer getExtensions() {
    return extensions;
}
 
Example 17
public ModelReference<ExtensionContainer> getSubject() {
    return subject;
}
 
Example 18
public void execute(final RegistrationContext<ComponentSpec, BaseComponentSpec> context) {
    ExtensionContainer extensions = context.getExtensions();
    ProjectSourceSet projectSourceSet = extensions.getByType(ProjectSourceSet.class);
    ComponentSpecContainer componentSpecs = extensions.getByType(ComponentSpecContainer.class);
    doRegister(context.getType(), context.getImplementation(), projectSourceSet, componentSpecs, context.getProjectIdentifier());
}
 
Example 19
@Model
LanguageRegistry languages(ExtensionContainer extensions) {
    return extensions.getByType(LanguageRegistry.class);
}
 
Example 20
@Mutate
void registerPlatformExtension(ExtensionContainer extensions, PlatformContainer platforms) {
    extensions.add("platforms", platforms);
}
 
Example 21
@Model
ProjectSourceSet sources(ExtensionContainer extensions) {
    return extensions.getByType(ProjectSourceSet.class);
}
 
Example 22
@Model
PublishingExtension publishing(ExtensionContainer extensions) {
    return extensions.getByType(PublishingExtension.class);
}
 
Example 23
@Mutate
public void registerExtensions(ExtensionContainer extensions, BuildTypeContainer buildTypes, FlavorContainer flavors) {
    extensions.add("buildTypes", buildTypes);
    extensions.add("flavors", flavors);
}
 
Example 24
public ExtensionContainer getExtensions() {
    return convention;
}
 
Example 25
public ExtensionContainer getExtensions() {
    return getConvention();
}
 
Example 26
Source Project: pushfish-android   Source File: DslObject.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ExtensionContainer getExtensions() {
    if (extensionContainer == null) {
        this.extensionContainer = toType(object, ExtensionAware.class).getExtensions();
    }
    return extensionContainer;
}
 
Example 27
public ExtensionContainer getExtensions() {
    return convention;
}
 
Example 28
public ExtensionContainer getExtensions() {
    return getConvention();
}
 
Example 29
Source Project: pushfish-android   Source File: DslObject.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ExtensionContainer getExtensions() {
    if (extensionContainer == null) {
        this.extensionContainer = toType(object, ExtensionAware.class).getExtensions();
    }
    return extensionContainer;
}
 
Example 30
Source Project: pygradle   Source File: ExtensionUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static <T> T getPythonComponentExtension(PythonExtension extension, Class<T> type) {
    ExtensionContainer extensionContainer = ((ExtensionAware) extension).getExtensions();
    return extensionContainer.getByType(type);
}