I am working on a project whose build.gradle includes the following line:
def availablePortFinder = AvailablePortFinder.createPrivate()
props.setProperty(‘mcast-port’, Integer.toString(availablePortFinder.nextAvailable))
AvailablePortFinder was deprecated and removed in Gradle 3.0, so I am trying to replace org.gradle.util.AvailablePortFinder with org.apache.mina.util.AvailablePortFinder. I have added the following configuration:
buildscript {
repositories {
mavenCentral()
maven { url “https://plugins.gradle.org/m2/” }
}
dependencies {
classpath group: ‘org.apache.mina’, name: ‘mina-core’, version: ‘2.0.14’
}
}
However, I don’t know how to qualify which AvailablePortFinder I want to use. I have tried fully qualifying the classname:
props.setProperty(‘mcast-port’, Integer.toString(org.apache.mina.util.AvailablePortFinder.AvailablePortFinder.getNextAvailable()))
which gave this error
Could not get unknown property ‘org’ for root project ‘XXX’ of type org.gradle.api.Project.
as well as a static import
import static org.apache.mina.util.AvailablePortFinder.AvailablePortFinder.getNextAvailable
…
props.setProperty(‘mcast-port’, Integer.toString(AvailablePortFinder.getNextAvailable(49152)))
which gave this error
- What went wrong:
Could not compile script ‘XXXXX/build.gradle’.startup failed:
script ‘XXXXX/build.gradle’: 1: unable to resolve class org.apache.mina.util.AvailablePortFinder
@ line 1, column 1.
import org.apache.mina.util.AvailablePortFinder
^1 error