Search in sources :

Example 6 with CommandLineArgumentProvider

use of org.gradle.process.CommandLineArgumentProvider in project MyLuaApp-Build-Core by dingyi222666.

the class DefaultJavaForkOptions method copyTo.

@Override
public JavaForkOptions copyTo(JavaForkOptions target) {
    super.copyTo(target);
    options.copyTo(target);
    if (jvmArgumentProviders != null) {
        for (CommandLineArgumentProvider jvmArgumentProvider : jvmArgumentProviders) {
            target.jvmArgs(jvmArgumentProvider.asArguments());
        }
    }
    return this;
}
Also used : CommandLineArgumentProvider(org.gradle.process.CommandLineArgumentProvider)

Example 7 with CommandLineArgumentProvider

use of org.gradle.process.CommandLineArgumentProvider in project gradle-baseline by palantir.

the class BaselineEnablePreviewFlag method apply.

@Override
public void apply(Project project) {
    // The idea behind registering a single 'extra property' is that other plugins (like
    // sls-packaging) can easily detect this and also also add the --enable-preview jvm arg
    Provider<Boolean> enablePreview = project.provider(() -> {
        JavaVersion jvmExecutingGradle = JavaVersion.current();
        JavaPluginConvention javaConvention = project.getConvention().findPlugin(JavaPluginConvention.class);
        if (javaConvention == null) {
            return false;
        }
        return javaConvention.getSourceCompatibility() == jvmExecutingGradle;
    });
    project.getExtensions().getExtraProperties().set("enablePreview", enablePreview);
    project.getPlugins().withId("java", _unused -> {
        project.getTasks().withType(JavaCompile.class).configureEach(t -> {
            List<CommandLineArgumentProvider> args = t.getOptions().getCompilerArgumentProviders();
            // mutation is gross, but it's the gradle convention
            args.add(new MaybeEnablePreview(enablePreview));
        });
        project.getTasks().withType(Test.class).configureEach(t -> {
            t.getJvmArgumentProviders().add(new MaybeEnablePreview(enablePreview));
        });
        project.getTasks().withType(JavaExec.class).configureEach(t -> {
            t.getJvmArgumentProviders().add(new MaybeEnablePreview(enablePreview));
        });
        // sadly we have to use afterEvaluate because the Javadoc task doesn't support passing in providers
        project.afterEvaluate(_unused2 -> {
            if (enablePreview.get()) {
                JavaVersion sourceCompat = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceCompatibility();
                project.getTasks().withType(Javadoc.class).configureEach(t -> {
                    CoreJavadocOptions options = (CoreJavadocOptions) t.getOptions();
                    // Yes truly javadoc wants a single leading dash, other javac wants a double leading dash.
                    // We also have to use these manual string options because they don't have first-class methods
                    // yet (e.g. https://github.com/gradle/gradle/issues/12898)
                    options.addBooleanOption("-enable-preview", true);
                    options.addStringOption("source", sourceCompat.getMajorVersion());
                });
            }
        });
    });
}
Also used : CoreJavadocOptions(org.gradle.external.javadoc.CoreJavadocOptions) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) CommandLineArgumentProvider(org.gradle.process.CommandLineArgumentProvider) JavaExec(org.gradle.api.tasks.JavaExec) Test(org.gradle.api.tasks.testing.Test) Javadoc(org.gradle.api.tasks.javadoc.Javadoc) JavaVersion(org.gradle.api.JavaVersion) JavaCompile(org.gradle.api.tasks.compile.JavaCompile)

Example 8 with CommandLineArgumentProvider

use of org.gradle.process.CommandLineArgumentProvider in project MyLuaApp-Build-Core by dingyi222666.

the class ProcessArgumentsSpec method getAllArguments.

public List<String> getAllArguments() {
    List<String> allArgs;
    List<String> args = getArgs();
    if (args == null) {
        allArgs = new ArrayList<>();
    } else {
        allArgs = new ArrayList<>(args);
    }
    for (CommandLineArgumentProvider argumentProvider : argumentProviders) {
        Iterables.addAll(allArgs, argumentProvider.asArguments());
    }
    return allArgs;
}
Also used : CommandLineArgumentProvider(org.gradle.process.CommandLineArgumentProvider)

Example 9 with CommandLineArgumentProvider

use of org.gradle.process.CommandLineArgumentProvider in project MyLuaApp-Build-Core by dingyi222666.

the class ProviderAwareCompilerDaemonForkOptions method getAllJvmArgs.

/**
 * Returns the full set of arguments to use to launch the JVM for the compiler process. This includes arguments to define
 * system properties, the minimum/maximum heap size, and the bootstrap classpath.
 *
 * @return The arguments. Returns an empty list if there are no arguments.
 */
@Internal
public List<String> getAllJvmArgs() {
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    builder.addAll(CollectionUtils.stringize(getJvmArgs()));
    for (CommandLineArgumentProvider argumentProvider : getJvmArgumentProviders()) {
        builder.addAll(argumentProvider.asArguments());
    }
    return builder.build();
}
Also used : CommandLineArgumentProvider(org.gradle.process.CommandLineArgumentProvider) ImmutableList(com.google.common.collect.ImmutableList) Internal(org.gradle.api.tasks.Internal)

Example 10 with CommandLineArgumentProvider

use of org.gradle.process.CommandLineArgumentProvider in project gradle by gradle.

the class ProcessArgumentsSpec method getAllArguments.

public List<String> getAllArguments() {
    List<String> allArgs;
    List<String> args = getArgs();
    if (args == null) {
        allArgs = new ArrayList<>();
    } else {
        allArgs = new ArrayList<>(args);
    }
    for (CommandLineArgumentProvider argumentProvider : argumentProviders) {
        Iterables.addAll(allArgs, argumentProvider.asArguments());
    }
    return allArgs;
}
Also used : CommandLineArgumentProvider(org.gradle.process.CommandLineArgumentProvider)

Aggregations

CommandLineArgumentProvider (org.gradle.process.CommandLineArgumentProvider)14 ImmutableList (com.google.common.collect.ImmutableList)6 Test (org.gradle.api.tasks.testing.Test)4 Internal (org.gradle.api.tasks.Internal)3 File (java.io.File)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 BaselineModuleJvmArgsExtension (com.palantir.baseline.extensions.BaselineModuleJvmArgsExtension)1 CLanguagePlugin (dev.nokee.language.c.internal.plugins.CLanguagePlugin)1 CppLanguagePlugin (dev.nokee.language.cpp.internal.plugins.CppLanguagePlugin)1 ToolChainSelectorInternal (dev.nokee.language.nativebase.internal.ToolChainSelectorInternal)1 NokeeStandardToolChainsPlugin (dev.nokee.language.nativebase.internal.toolchains.NokeeStandardToolChainsPlugin)1 ObjectiveCLanguagePlugin (dev.nokee.language.objectivec.internal.plugins.ObjectiveCLanguagePlugin)1 ObjectiveCppLanguagePlugin (dev.nokee.language.objectivecpp.internal.plugins.ObjectiveCppLanguagePlugin)1 ProjectIdentifier (dev.nokee.model.internal.ProjectIdentifier)1 ModelNodes (dev.nokee.model.internal.core.ModelNodes)1 ModelProperties (dev.nokee.model.internal.core.ModelProperties)1 ModelRegistry (dev.nokee.model.internal.registry.ModelRegistry)1 VariantView (dev.nokee.platform.base.VariantView)1 BaseVariant (dev.nokee.platform.base.internal.BaseVariant)1 ComponentIdentifier (dev.nokee.platform.base.internal.ComponentIdentifier)1