Skip to content
Closed
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
Expand Up @@ -6,7 +6,7 @@ repositories {

compileGroovy {
if (JavaVersion.current().isJava9()) {
options.compilerArgs += ['--add-modules', 'javafx.graphics']
options.compilerArgs.addAll(['--add-modules', 'javafx.graphics'])
groovyOptions.forkOptions.jvmArgs += ['--add-modules', 'javafx.graphics']
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package org.gradle.api.tasks.compile;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.gradle.api.Incubating;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.FileCollection;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.model.ReplacedBy;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.Classpath;
Expand Down Expand Up @@ -77,9 +77,6 @@ public abstract class CompileOptions extends AbstractOptions {

private String extensionDirs;

private List<String> compilerArgs = Lists.newArrayList();
private final List<CommandLineArgumentProvider> compilerArgumentProviders = Lists.newArrayList();

private boolean incremental = true;

private FileCollection sourcepath;
Expand Down Expand Up @@ -318,9 +315,7 @@ public void setExtensionDirs(@Nullable String extensionDirs) {
* are ignored.
*/
@Input
public List<String> getCompilerArgs() {
return compilerArgs;
}
public abstract ListProperty<String> getCompilerArgs();

/**
* Returns all compiler arguments, added to the {@link #getCompilerArgs()} or the {@link #getCompilerArgumentProviders()} property.
Expand All @@ -330,8 +325,8 @@ public List<String> getCompilerArgs() {
@Internal
public List<String> getAllCompilerArgs() {
ImmutableList.Builder<String> builder = ImmutableList.builder();
builder.addAll(CollectionUtils.stringize(getCompilerArgs()));
for (CommandLineArgumentProvider compilerArgumentProvider : getCompilerArgumentProviders()) {
builder.addAll(CollectionUtils.stringize(getCompilerArgs().get()));
for (CommandLineArgumentProvider compilerArgumentProvider : getCompilerArgumentProviders().get()) {
builder.addAll(compilerArgumentProvider.asArguments());
}
return builder.build();
Expand All @@ -343,17 +338,7 @@ public List<String> getAllCompilerArgs() {
* @since 4.5
*/
@Nested
public List<CommandLineArgumentProvider> getCompilerArgumentProviders() {
return compilerArgumentProviders;
}

/**
* Sets any additional arguments to be passed to the compiler.
* Defaults to the empty list.
*/
public void setCompilerArgs(List<String> compilerArgs) {
this.compilerArgs = compilerArgs;
}
public abstract ListProperty<CommandLineArgumentProvider> getCompilerArgumentProviders();

/**
* Convenience method to set {@link ForkOptions} with named parameter syntax.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CompileOptionsTest extends Specification {
!compileOptions.verbose
!compileOptions.fork

compileOptions.compilerArgs.empty
compileOptions.compilerArgs.get().empty
compileOptions.encoding == null
compileOptions.bootstrapClasspath == null
compileOptions.extensionDirs == null
Expand Down Expand Up @@ -90,7 +90,7 @@ class CompileOptionsTest extends Specification {

def "converts GStrings to Strings when getting all compiler arguments"() {
given:
compileOptions.compilerArgs << "Foo${23}"
compileOptions.compilerArgs.add("Foo${23}")

expect:
compileOptions.allCompilerArgs.contains('Foo23')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
{
"acceptedApiChanges": []
"acceptedApiChanges": [
{
"type": "org.gradle.api.tasks.compile.CompileOptions",
"member": "Method org.gradle.api.tasks.compile.CompileOptions.getCompilerArgs()",
"acceptation": "Upgraded property",
"changes": [
"Method return type has changed",
"Method is now abstract"
]
},
{
"type": "org.gradle.api.tasks.compile.CompileOptions",
"member": "Method org.gradle.api.tasks.compile.CompileOptions.getCompilerArgumentProviders()",
"acceptation": "Upgraded property",
"changes": [
"Method return type has changed",
"Method is now abstract"
]
},
{
"type": "org.gradle.api.tasks.compile.CompileOptions",
"member": "Method org.gradle.api.tasks.compile.CompileOptions.setCompilerArgs(java.util.List)",
"acceptation": "Upgraded property",
"changes": [
"Method has been removed"
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ Method <org.gradle.api.tasks.compile.BaseForkOptions.getMemoryInitialSize()> doe
Method <org.gradle.api.tasks.compile.BaseForkOptions.getMemoryMaximumSize()> does not have raw return type assignable to org.gradle.api.provider.Property in (BaseForkOptions.java:0)
Method <org.gradle.api.tasks.compile.CompileOptions.getAllCompilerArgs()> does not have raw return type assignable to org.gradle.api.provider.Provider in (CompileOptions.java:0)
Method <org.gradle.api.tasks.compile.CompileOptions.getAnnotationProcessorGeneratedSourcesDirectory()> does not have raw return type assignable to org.gradle.api.provider.Property in (CompileOptions.java:0)
Method <org.gradle.api.tasks.compile.CompileOptions.getCompilerArgs()> does not have raw return type assignable to org.gradle.api.provider.Property in (CompileOptions.java:0)
Method <org.gradle.api.tasks.compile.CompileOptions.getCompilerArgumentProviders()> does not have raw return type assignable to org.gradle.api.provider.Provider in (CompileOptions.java:0)
Method <org.gradle.api.tasks.compile.CompileOptions.getDebugOptions()> does not have raw return type assignable to org.gradle.api.provider.Property in (CompileOptions.java:0)
Method <org.gradle.api.tasks.compile.CompileOptions.getEncoding()> does not have raw return type assignable to org.gradle.api.provider.Property in (CompileOptions.java:0)
Method <org.gradle.api.tasks.compile.CompileOptions.getExtensionDirs()> does not have raw return type assignable to org.gradle.api.provider.Property in (CompileOptions.java:0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private static <COMPILE extends AbstractCompile & HasCompileOptions> int getDefa
return compileTask.getOptions().getRelease().get();
}

List<String> compilerArgs = compileTask.getOptions().getCompilerArgs();
List<String> compilerArgs = compileTask.getOptions().getCompilerArgs().get();
int flagIndex = compilerArgs.indexOf("--release");

if (flagIndex != -1 && flagIndex + 1 < compilerArgs.size()) {
Expand Down