RAML to JAX-RS conversion Using Gradle


(Vijayakumar J) #1

Hi Guys,

I have to convert the RAML file to java classes using gradle plugin and i am not finding a exact plugin to parse the RAML.

Can you help me in providing solution for conversion and correct the script if i have done any mistake

buildscript {
ext {
springBootVersion = ‘1.4.1.BUILD-SNAPSHOT’
}
repositories {
maven { url “http://repo1.maven.org/maven2” }
maven { url “http://repo.spring.io/snapshot” }
maven { url “http://repo.spring.io/milestone” }
maven { url “https://repository-master.mulesoft.org/releases/” }
maven { url “https://repository-master.mulesoft.org/snapshots/” }

}
dependencies {
	classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}

}

apply plugin: 'java’
apply plugin: 'spring-boot’
apply plugin: 'war’
apply plugin: ‘raml’

repositories {
maven { url “http://repo1.maven.org/maven2” }
maven { url “http://repo.spring.io/snapshot” }
maven { url “http://repo.spring.io/milestone” }
maven { url “http://repo.spring.io/release” }
maven { url “https://repository-master.mulesoft.org/releases/” }
maven { url “https://repository-master.mulesoft.org/snapshots/” }

}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
// https://mvnrepository.com/artifact/org.raml/raml-parser
compile group: ‘org.raml’, name: ‘raml-parser’, version: ‘0.8.11’
// https://mvnrepository.com/artifact/org.raml/raml-gradle-plugin
compile group: ‘org.raml’, name: ‘raml-gradle-plugin’, version: ‘1.3.4’

compile('org.springframework.cloud:spring-cloud-starter-hystrix')
compile('org.springframework.boot:spring-boot-starter-web')
compile 'io.springfox:springfox-swagger2:2.1.2'
compile 'io.springfox:springfox-swagger-ui:2.1.2'
compile 'org.apache.commons:commons-lang3:3.1'
testCompile 'junit:junit:4.12'
compile('org.springframework.boot:spring-boot-starter-log4j2')
compile group: 'org.mockito', name: 'mockito-core', version: '1.9.5'
compile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
compile group: 'org.springframework', name: 'spring-test', version: '4.1.6.RELEASE'
compile group: 'com.jayway.jsonpath', name: 'json-path', version: '0.8.1'
compile group: 'com.jayway.jsonpath', name: 'json-path-assert', version: '0.8.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.7'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.7'
compile group: 'org.springframework', name: 'spring-aop', version: '4.1.6.RELEASE'
compile group: 'org.aspectj', name: 'aspectjrt', version: '1.8.9'
compile group: 'org.aspectj', name: 'aspectjweaver', version: '1.8.9'
compile group: 'org.skyscreamer', name: 'jsonassert', version: '1.3.0'
compile group: 'org.json', name: 'json', version: '20160810'
compile group: 'org.apache.poi', name: 'poi', version: '3.15'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.15'
compile group: 'org.apache.poi', name: 'poi-scratchpad', version: '3.15'
compile group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '3.15'
compile group: 'com.jayway.restassured', name: 'json-schema-validator', version: '2.2.0'

}

configurations {
compile.exclude group:‘ch.qos.logback’

}

raml {
basePackageName = 'example.resources’
jaxrsVersion = '2.0’
jsonMapper = 'JACKSON2’
outputDirectory = 'src/main/gen-src’
sourcePaths = files(‘src/main/resources/raml/example.raml’)
useJsr303Annotations = true
}

dependencyManagement {
imports {
mavenBom “org.springframework.cloud:spring-cloud-dependencies:Brixton.BUILD-SNAPSHOT”
}
}