Rule based configuration with custom java plugin

software-model
plugins

(John Scancella) #1

Hello,

I have a created a custom plugin using java, and was wondering how I convert it to using the new rule based configuration. I have looked at your examples, but they are all in groovy so I am a little lost.

The first step was just to compile it (packaging for upload to the gradle plugins site is next), but it is complaining that it can’t find package org.gradle.api does not exist. In the “old way” I used the dependencies closure and added gradleApi().

Here is what I have in my build script:

plugins {
  id 'jvm-component'
  id 'java-lang'
  id 'junit-test-suite'
  id "eclipse"
}

repositories {
  jcenter()
}

model {
  components {
      main(JvmLibrarySpec){
        targetPlatform 'java8'
        dependencies {
          module 'org.slf4j:slf4j-api:1.7.18'
          module 'org.apache.httpcomponents:httpclient:4.5.1'
          module 'org.apache.httpcomponents:httpmime:4.5.1'
          module 'com.google.code.gson:gson:2.5'
//          What goes here for gradleApi()?
        }
      }
  }
  testSuites {
    test(JUnitTestSuiteSpec) {
        jUnitVersion '4.12'
        dependencies {
          module 'org.mockito:mockito-core:1.10.19'
        }
    }
  }
}

Thanks for all the help!