Reputation: 11
I was tried to update the gradle version of custom plugin of my projects. Gradle version was updated 5.4.1 to 7.4.2. But I am getting below error while running the previous code.
C:\DevTools\devtools\mxdocker\src\main\java\com\mxi\gradle\plugins\docker\DockerExecCommand.java:8: error: cannot find symbol
import org.gradle.api.internal.provider.DefaultPropertyState;
^
symbol: class DefaultPropertyState
location: package org.gradle.api.internal.provider
C:\DevTools\devtools\mxdocker\src\main\java\com\mxi\gradle\plugins\docker\DockerExecCommand.java:16: error: cannot find symbol
private final Property<String> command = new DefaultPropertyState<String>( String.class );
^
symbol: class DefaultPropertyState
location: class com.mxi.gradle.plugins.docker.DockerExecCommand
2 errors
I think reason for that error is deprecation of org.gradle.api.internal.provider.DefaultPropertyState . But I am still not able to find proper solution for solve that error.
This is the full code of java class,
package com.mxi.gradle.plugins.docker;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.gradle.api.internal.provider.DefaultPropertyState;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
public final class DockerExecCommand {
private final List<String> options = new ArrayList<String>();
private final Property<String> command = new DefaultPropertyState<String>( String.class );
public DockerExecCommand(String aCommand, String... aOptions) {
command.set( aCommand );
options.addAll( Arrays.asList( aOptions ) );
}
public DockerExecCommand(Provider<String> aCommandProvider, String... aOptions) {
command.set( aCommandProvider );
options.addAll( Arrays.asList( aOptions ) );
}
public String getCommand() {
return command.get();
}
public List<String> getOptions() {
return Collections.unmodifiableList( options );
}
}
I need to initialize
private final Property<String> command
variable without null and without adding additional parameters to class constructor.
Upvotes: 0
Views: 16