How to access Gradle internal api from plugins


(Marcel Overdijk) #1

I was upgrading a custom plugin based on 1.3 to 1.6 but faced the problem accessing Gradle internal api classes. After doing some investigation I found out that it breaks when moving 1.3 to 1.4 or higher.

The class I’m using is org.gradle.api.internal.artifacts.configurations.conflicts.StrictConflictResolution (it still exists in 1.6)

I’ve added the Gradle api via my dependencies block like:

dependencies {

groovy localGroovy()

compile gradleApi()

Is there something changed after 1.3 and what is the best way to include the internal Gradle api in my plugin?

Kind regards, Marcel


(Peter Niederwieser) #2

The class was moved from ‘core’ to ‘core-impl’, which means that it can no longer be used directly. Why and how are you using this class?


(Marcel Overdijk) #3

In our custom plugin we defined:

@Override

public void apply(Project project) {

// fail on version conflicts

project.configurations.all { resolutionStrategy.failOnVersionConflict() }

and it’s test case I’m verifying this like:

def “configures fail on version conflict resolution strategy for each configuration”() {

expect:

project.configurations.all { configuration ->

assert configuration.resolutionStrategy.conflictResolution instanceof StrictConflictResolution

}

}


(Peter Niederwieser) #4

You’ll need to change the test. You can either check the class name, or write a higher-level test that actually tries to resolve conflicting module versions.