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

Ungradlefy the Groovy DSL mixin of public types #153

Merged
merged 1 commit into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package dev.nokee.platform.base;

import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.api.artifacts.ExternalModuleDependency;
import org.gradle.api.artifacts.ModuleDependency;
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.util.ConfigureUtil;

/**
* The dependency buckets for an application component.
Expand All @@ -28,6 +31,17 @@ public interface ApplicationComponentDependencies extends ComponentDependencies
*/
void implementation(Object notation, Action<? super ModuleDependency> action);

/**
* Adds an implementation dependency to this component.
* An implementation dependency is not visible to consumers that are compiled against this component.
*
* @param notation The dependency notation, as per {@link org.gradle.api.artifacts.dsl.DependencyHandler#create(Object)}.
* @param closure The closure to run to configure the dependency (project dependencies are {@link ProjectDependency} and external dependencies are {@link ExternalModuleDependency}).
*/
default void implementation(Object notation, @DelegatesTo(value = ModuleDependency.class, strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
implementation(notation, ConfigureUtil.configureUsing(closure));
}

/**
* Returns the implementation bucket of dependencies for this component.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package dev.nokee.platform.base;

import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.util.ConfigureUtil;

/**
* A component with dependency buckets.
Expand All @@ -24,5 +27,14 @@ public interface DependencyAwareComponent<T extends ComponentDependencies> {
default void dependencies(Action<? super T> action) {
action.execute(getDependencies());
}

/**
* Configure the dependencies of this component.
*
* @param closure configuration closure for {@link ComponentDependencies}.
*/
default void dependencies(@DelegatesTo(type = "T", strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
dependencies(ConfigureUtil.configureUsing(closure));
}
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package dev.nokee.platform.base;

import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.api.artifacts.ExternalModuleDependency;
import org.gradle.api.artifacts.ModuleDependency;
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.util.ConfigureUtil;

/**
* The dependency buckets for a library component.
Expand All @@ -26,6 +29,16 @@ public interface LibraryComponentDependencies extends ComponentDependencies {
*/
void api(Object notation, Action<? super ModuleDependency> action);

/**
* Adds an API dependency to this library. An API dependency is made visible to consumers that are compiled against this component.
*
* @param notation The dependency notation, as per {@link org.gradle.api.artifacts.dsl.DependencyHandler#create(Object)}.
* @param closure The closure to run to configure the dependency (project dependencies are {@link ProjectDependency} and external dependencies are {@link ExternalModuleDependency}).
*/
default void api(Object notation, @DelegatesTo(value = ModuleDependency.class, strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
api(notation, ConfigureUtil.configureUsing(closure));
}

/**
* Adds an implementation dependency to this component.
* An implementation dependency is not visible to consumers that are compiled against this component.
Expand All @@ -43,6 +56,17 @@ public interface LibraryComponentDependencies extends ComponentDependencies {
*/
void implementation(Object notation, Action<? super ModuleDependency> action);

/**
* Adds an implementation dependency to this component.
* An implementation dependency is not visible to consumers that are compiled against this component.
*
* @param notation The dependency notation, as per {@link org.gradle.api.artifacts.dsl.DependencyHandler#create(Object)}.
* @param closure The closure to run to configure the dependency (project dependencies are {@link ProjectDependency} and external dependencies are {@link ExternalModuleDependency}).
*/
default void implementation(Object notation, @DelegatesTo(value = ModuleDependency.class, strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
implementation(notation, ConfigureUtil.configureUsing(closure));
}

/**
* Returns the implementation bucket of dependencies for this component.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package dev.nokee.platform.base;

import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.api.Transformer;
import org.gradle.api.provider.Provider;
import org.gradle.api.specs.Spec;
import org.gradle.util.ConfigureUtil;

import java.util.List;
import java.util.Set;
Expand All @@ -24,6 +27,17 @@ public interface View<T> {
*/
void configureEach(Action<? super T> action);

/**
* Registers a closure to execute to configure each element in the view.
* The action is only executed for those elements that are required.
* Fails if any element has already been finalized.
*
* @param closure The closure to execute on each element for configuration.
*/
default void configureEach(@DelegatesTo(type = "T", strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
configureEach(ConfigureUtil.configureUsing(closure));
}

/**
* Registers an action to execute to configure each element in the view.
* The action is only executed for those elements that are required.
Expand All @@ -37,6 +51,21 @@ public interface View<T> {
*/
<S extends T> void configureEach(Class<S> type, Action<? super S> action);

/**
* Registers a closure to execute to configure each element in the view.
* The action is only executed for those elements that are required.
* Fails if any matching element has already been finalized.
*
* This method is equivalent to <code>view.withType(Foo).configureEach { ... }</code>.
*
* @param type the type of binary to select.
* @param <S> the base type of the element to configure.
* @param closure the closure to execute on each element for configuration.
*/
default <S extends T> void configureEach(Class<S> type, @DelegatesTo(type = "S", strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
configureEach(type, ConfigureUtil.configureUsing(closure));
}

/**
* Registers an action to execute to configure each element in the view matching the given specification.
* The action is only executed for those elements that are required.
Expand All @@ -48,6 +77,19 @@ public interface View<T> {
*/
void configureEach(Spec<? super T> spec, Action<? super T> action);

/**
* Registers a closure to execute to configure each element in the view matching the given specification.
* The action is only executed for those elements that are required.
* Fails if any element has already been finalized.
*
* @param spec a specification to satisfy. The spec is applied to each binary prior to configuration.
* @param closure the closure to execute on each element for configuration.
* @since 0.4
*/
default void configureEach(Spec<? super T> spec, @DelegatesTo(type = "S", strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
configureEach(spec, ConfigureUtil.configureUsing(closure));
}

/**
* Returns a view containing the objects in this view of the given type.
* The returned view is live, so that when matching objects are later added to this view, they are also visible in the filtered view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import dev.nokee.platform.base.ComponentDependencies;
import dev.nokee.platform.base.DependencyBucket;
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.api.artifacts.ExternalModuleDependency;
import org.gradle.api.artifacts.ModuleDependency;
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.util.ConfigureUtil;

/**
* Allows the API, JVM implementation and native implementation dependencies of a Java Native Interface (JNI) library to be specified.
Expand All @@ -29,6 +32,16 @@ public interface JavaNativeInterfaceLibraryComponentDependencies extends JavaNat
*/
void api(Object notation, Action<? super ModuleDependency> action);

/**
* Adds an JVM API dependency to this library. An API dependency is made visible to consumers that are compiled against this component.
*
* @param notation The dependency notation, as per {@link org.gradle.api.artifacts.dsl.DependencyHandler#create(Object)}.
* @param closure The closure to run to configure the dependency (project dependencies are {@link ProjectDependency} and external dependencies are {@link ExternalModuleDependency}).
*/
default void api(Object notation, @DelegatesTo(value = ModuleDependency.class, strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
api(notation, ConfigureUtil.configureUsing(closure));
}

/**
* Adds an JVM implementation dependency to this library. An implementation dependency is not visible to consumers that are compiled against this component.
*
Expand All @@ -45,6 +58,17 @@ public interface JavaNativeInterfaceLibraryComponentDependencies extends JavaNat
*/
void jvmImplementation(Object notation, Action<? super ModuleDependency> action);

/**
* Adds an JVM implementation dependency to this library.
* An implementation dependency is not visible to consumers that are compiled against this component.
*
* @param notation The dependency notation, as per {@link org.gradle.api.artifacts.dsl.DependencyHandler#create(Object)}.
* @param closure The closure to run to configure the dependency (project dependencies are {@link ProjectDependency} and external dependencies are {@link ExternalModuleDependency}).
*/
default void jvmImplementation(Object notation, @DelegatesTo(value = ModuleDependency.class, strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
jvmImplementation(notation, ConfigureUtil.configureUsing(closure));
}

/**
* Adds an JVM runtime only dependency to this library.
* An implementation dependency is only visible to consumers that are running against this component.
Expand All @@ -62,6 +86,17 @@ public interface JavaNativeInterfaceLibraryComponentDependencies extends JavaNat
*/
void jvmRuntimeOnly(Object notation, Action<? super ModuleDependency> action);

/**
* Adds an JVM runtime only dependency to this library.
* An implementation dependency is only visible to consumers that are running against this component.
*
* @param notation The dependency notation, as per {@link org.gradle.api.artifacts.dsl.DependencyHandler#create(Object)}.
* @param closure The closure to run to configure the dependency (project dependencies are {@link ProjectDependency} and external dependencies are {@link ExternalModuleDependency}).
*/
default void jvmRuntimeOnly(Object notation, @DelegatesTo(value = ModuleDependency.class, strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
jvmRuntimeOnly(notation, ConfigureUtil.configureUsing(closure));
}

/**
* Returns the JVM runtime only bucket of dependencies for this component.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import dev.nokee.platform.base.ComponentDependencies;
import dev.nokee.platform.base.DependencyBucket;
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.api.artifacts.ExternalModuleDependency;
import org.gradle.api.artifacts.ModuleDependency;
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.util.ConfigureUtil;

/**
* Allows the native implementation dependencies of a Java Native Interface (JNI) library to be specified.
Expand All @@ -31,6 +34,17 @@ public interface JavaNativeInterfaceNativeComponentDependencies extends Componen
*/
void nativeImplementation(Object notation, Action<? super ModuleDependency> action);

/**
* Adds an native implementation dependency to this component.
* An implementation dependency is not visible to consumers that are compiled or linked against this component.
*
* @param notation The dependency notation, as per {@link org.gradle.api.artifacts.dsl.DependencyHandler#create(Object)}.
* @param closure The closure to run to configure the dependency (project dependencies are {@link ProjectDependency} and external dependencies are {@link ExternalModuleDependency}).
*/
default void nativeImplementation(Object notation, @DelegatesTo(value = ModuleDependency.class, strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
nativeImplementation(notation, ConfigureUtil.configureUsing(closure));
}

/**
* Adds an native link only dependency to this component.
* An link only dependency is not visible to consumers that are compiled or linked against this component.
Expand All @@ -49,6 +63,18 @@ public interface JavaNativeInterfaceNativeComponentDependencies extends Componen
*/
void nativeLinkOnly(Object notation, Action<? super ModuleDependency> action);

/**
* Adds an native link only dependency to this component.
* An link only dependency is not visible to consumers that are compiled or linked against this component.
*
* @param notation The dependency notation, as per {@link org.gradle.api.artifacts.dsl.DependencyHandler#create(Object)}.
* @param closure The closure to run to configure the dependency (project dependencies are {@link ProjectDependency} and external dependencies are {@link ExternalModuleDependency}).
* @since 0.4
*/
default void nativeLinkOnly(Object notation, @DelegatesTo(value = ModuleDependency.class, strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
nativeLinkOnly(notation, ConfigureUtil.configureUsing(closure));
}

/**
* Adds an native runtime only dependency to this component.
* An runtime only dependency is not visible to consumers that are running against this component.
Expand All @@ -66,6 +92,17 @@ public interface JavaNativeInterfaceNativeComponentDependencies extends Componen
*/
void nativeRuntimeOnly(Object notation, Action<? super ModuleDependency> action);

/**
* Adds an native runtime only dependency to this component.
* An runtime only dependency is visible only to consumers that are running against this component.
*
* @param notation The dependency notation, as per {@link org.gradle.api.artifacts.dsl.DependencyHandler#create(Object)}.
* @param closure The closure to run to configure the dependency (project dependencies are {@link ProjectDependency} and external dependencies are {@link ExternalModuleDependency}).
*/
default void nativeRuntimeOnly(Object notation, @DelegatesTo(value = ModuleDependency.class, strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
nativeRuntimeOnly(notation, ConfigureUtil.configureUsing(closure));
}

/**
* Returns the native implementation bucket of dependencies for this component.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
import dev.nokee.platform.base.Variant;
import dev.nokee.platform.nativebase.SharedLibraryBinary;
import dev.nokee.runtime.nativebase.TargetMachine;
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.provider.Property;
import org.gradle.util.ConfigureUtil;

/**
* Configuration for a specific Java Native Interface (JNI) library variant, defining the dependencies that make up the library plus other settings.
Expand Down Expand Up @@ -45,6 +48,16 @@ public interface JniLibrary extends Variant, DependencyAwareComponent<JavaNative
*/
void sharedLibrary(Action<? super SharedLibraryBinary> action);

/**
* Configure the shared library binary for this variant.
*
* @param closure configuration closure for {@link SharedLibraryBinary}.
* @since 0.3
*/
default void sharedLibrary(@DelegatesTo(value = SharedLibraryBinary.class, strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
sharedLibrary(ConfigureUtil.configureUsing(closure));
}

/**
* Configure the native runtime files to include inside the JNI JAR at the resource path location.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import dev.nokee.platform.nativebase.TargetMachineAwareComponent;
import dev.nokee.platform.nativebase.TargetMachineFactory;
import dev.nokee.runtime.nativebase.TargetMachine;
import org.gradle.api.Action;
import org.gradle.api.provider.SetProperty;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@

import dev.nokee.platform.base.ApplicationComponentDependencies;
import dev.nokee.platform.base.ComponentDependencies;
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.artifacts.ModuleDependency;
import org.gradle.util.ConfigureUtil;

/**
* Allows the implementation dependencies of a native application to be specified.
*
* @since 0.5
*/
public interface NativeApplicationComponentDependencies extends ApplicationComponentDependencies, NativeComponentDependencies, ComponentDependencies {
/**
* {@inheritDoc}
*/
@Override
default void implementation(Object notation, @DelegatesTo(value = ModuleDependency.class, strategy = Closure.DELEGATE_FIRST) Closure<Void> closure) {
implementation(notation, ConfigureUtil.configureUsing(closure));
}
}
Loading