build.gradle 2.7 KB
Newer Older
1
import io.github.kobylynskyi.graphql.codegen.gradle.GraphQLCodegenGradleTask
2 3 4 5 6

plugins {
    id "java"
    id "idea"
    id "application"
7 8 9

    // use the latest available version:
    // https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
10
    id "io.github.kobylynskyi.graphql.codegen" version "1.7.1-SNAPSHOT"
11 12
}

13
mainClassName = "io.github.kobylynskyi.order.Application"
14 15

dependencies {
16 17
    implementation "org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE"
    implementation "org.springframework.boot:spring-boot-starter-data-mongodb:2.2.6.RELEASE"
18

19 20
    implementation "com.graphql-java-kickstart:graphql-spring-boot-starter:7.0.1"
    implementation "com.graphql-java-kickstart:graphiql-spring-boot-starter:7.0.1"
21

22 23
    // use the latest available version:
    // https://search.maven.org/artifact/io.github.kobylynskyi/graphql-java-codegen
24
    implementation "io.github.kobylynskyi:graphql-java-codegen:1.7.1-SNAPSHOT"
25

26
    implementation "org.apache.httpcomponents:httpclient:4.5.12"
27

28 29
    implementation "org.mapstruct:mapstruct:1.3.1.Final"
    annotationProcessor "org.mapstruct:mapstruct-processor:1.3.1.Final"
30

31 32
    compileOnly "org.projectlombok:lombok:1.18.12"
    annotationProcessor "org.projectlombok:lombok:1.18.12"
33 34 35 36

    testImplementation "io.rest-assured:rest-assured:4.3.0"
    testImplementation "org.junit.jupiter:junit-jupiter-api:5.5.1"
    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.5.1"
37 38 39 40 41 42 43
}

/**
 * Generate requests and model from external service
 */
compileJava.dependsOn "graphqlCodegenProductService"
sourceSets.main.java.srcDirs "$buildDir/generated-client"
44
task graphqlCodegenProductService(type: GraphQLCodegenGradleTask) {
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
    graphqlSchemaPaths = ["$projectDir/src/main/resources/external/schema-product-service.graphqls".toString()]
    outputDir = new File("$buildDir/generated-client")
    modelPackageName = "io.github.kobylynskyi.product.graphql.model"
    customTypesMapping = [
            DateTime: "java.util.Date"
    ]
    modelNameSuffix = "TO"
    generateRequests = true
    generateApis = false
}

/**
 * Generate apis and model
 */
compileJava.dependsOn "graphqlCodegenOrderService"
sourceSets.main.java.srcDirs "$buildDir/generated-server"
61
task graphqlCodegenOrderService(type: GraphQLCodegenGradleTask) {
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
    graphqlSchemaPaths = ["$projectDir/src/main/resources/schema.graphqls".toString()]
    outputDir = new File("$buildDir/generated-server")
    apiPackageName = "io.github.kobylynskyi.order.graphql.api"
    modelPackageName = "io.github.kobylynskyi.order.graphql.model"
    customTypesMapping = [
            DateTime: "java.util.Date"
    ]
    modelNameSuffix = "TO"
}

repositories {
    jcenter()
    mavenCentral()
    mavenLocal()
}