}
import com.fasterxml.jackson.databind.ObjectMapper;
public class A {
}
If move the class A into a separate java file (content is as below), the import part will fail - can not find class com.fasterxml.jackson.databind.ObjectMapper.
import com.fasterxml.jackson.databind.ObjectMapper;
public class A {
}
I have tried to add “build” in dependency block, it still doesn’t work.
It can be imported from build.gradle because you’ve declared the dependency on Jackson in your buildscript block. The buildscript block places the dependency on the classpath of your buildscript, but not on the compile classpath for the buildSrc project, which is built separately as the first step.
With your example on GitHub, you need to declare the Jackson dependencies in buildSrc/build.gradle as that’s the project that’s trying to use them. You do not need to declare any dependencies in build.gradle as the compiled ReleaseVersionTask is automatically on the classpath of your buildscript in the StandAloneGradleClass folder due to it being in buildSrc.