org.gradle.api.plugins.ExtensionContainer Java Examples

The following examples show how to use org.gradle.api.plugins.ExtensionContainer. 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 File: ModuleSystemPlugin.java    From gradle-modules-plugin with 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
Source File: GolangPluginSupport.java    From gradle-golang-plugin with Mozilla Public License 2.0 6 votes vote down vote up
@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
Source File: CfPropertiesEnvOverrideTest.java    From ya-cf-app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@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 #4
Source File: CfPropertiesMapperTest.java    From ya-cf-app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@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 #5
Source File: ExtensionUtils.java    From pygradle with 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 #6
Source File: Settings.java    From gradle-golang-plugin with 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 #7
Source File: Settings.java    From gradle-golang-plugin with 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 #8
Source File: ProxyUnitTest.java    From ossindex-gradle-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 #9
Source File: ProxyTests.java    From ossindex-gradle-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 #10
Source File: JigGradlePlugin.java    From jig with 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 #11
Source File: ComponentModelRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #12
Source File: ComponentModelRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #13
Source File: ComponentModelRuleDefinitionHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: ComponentModelRuleDefinitionHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: AbstractTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ExtensionContainer getExtensions() {
    return getConvention();
}
 
Example #16
Source File: DslObject.java    From Pushjet-Android with 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 #17
Source File: AbstractTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ExtensionContainer getExtensions() {
    return getConvention();
}
 
Example #18
Source File: ComponentModelRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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 #19
Source File: ComponentModelRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ExtensionContainer getExtensions() {
    return extensions;
}
 
Example #20
Source File: DefaultNamedDomainObjectCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ExtensionContainer getExtensions() {
    return convention;
}
 
Example #21
Source File: DslObject.java    From Pushjet-Android with 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 #22
Source File: ComponentModelBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Mutate
void registerPlatformExtension(ExtensionContainer extensions, PlatformContainer platforms) {
    extensions.add("platforms", platforms);
}
 
Example #23
Source File: DefaultNamedDomainObjectCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ExtensionContainer getExtensions() {
    return convention;
}
 
Example #24
Source File: NativeComponentModelPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Mutate
public void registerExtensions(ExtensionContainer extensions, BuildTypeContainer buildTypes, FlavorContainer flavors) {
    extensions.add("buildTypes", buildTypes);
    extensions.add("flavors", flavors);
}
 
Example #25
Source File: PublishingPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
PublishingExtension publishing(ExtensionContainer extensions) {
    return extensions.getByType(PublishingExtension.class);
}
 
Example #26
Source File: ComponentModelRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ModelReference<ExtensionContainer> getSubject() {
    return subject;
}
 
Example #27
Source File: LanguageBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
ProjectSourceSet sources(ExtensionContainer extensions) {
    return extensions.getByType(ProjectSourceSet.class);
}
 
Example #28
Source File: ComponentTypeRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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 #29
Source File: ComponentModelBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
LanguageRegistry languages(ExtensionContainer extensions) {
    return extensions.getByType(LanguageRegistry.class);
}
 
Example #30
Source File: NativeComponentModelPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Mutate
public void registerExtensions(ExtensionContainer extensions, BuildTypeContainer buildTypes, FlavorContainer flavors) {
    extensions.add("buildTypes", buildTypes);
    extensions.add("flavors", flavors);
}