Skip to content

Conversation

@rahulshishodia
Copy link

Reference: org.apache.grails.buildsrc.CompilePlugin#configureCompiler
Issue: #13028

Sample build.gradle file

buildscript {
    repositories {
        maven {
           url = 'file:/Users/rahul/Dev/grails-core/build/local-maven/'
        }
        mavenCentral()
        maven {
           url = 'https://repo.grails.org/grails/restricted'
        }
        maven {
           url = 'https://repository.apache.org/content/groups/snapshots'
           content {
              includeVersionByRegex('org[.]apache[.]grails.*', '.*', '.*-SNAPSHOT')
           }
           content {
              includeVersionByRegex('org[.]apache[.]groovy.*', 'groovy.*', '.*-SNAPSHOT')
           }
           mavenContent {
              snapshotsOnly()
           }
        }
        maven {
           url = 'https://repository.apache.org/content/groups/staging'
           content {
              includeVersionByRegex('org[.]apache[.]grails[.]gradle', 'grails-publish', '.*')
           }
           content {
              includeVersionByRegex('org[.]apache[.]groovy.*', 'groovy.*', '.*')
           }
           mavenContent {
              releasesOnly()
           }
        }
    }
    dependencies { // Not Published to Gradle Plugin Portal
        classpath "cloud.wondrify:asset-pipeline-gradle"
        classpath platform("org.apache.grails:grails-bom:$grailsVersion")
        classpath "org.apache.grails:grails-data-hibernate5"
        classpath "org.apache.grails:grails-gradle-plugins"
    }
}

plugins {
    id "war"
    id "idea"
    id "eclipse"
}

// Not Published to Gradle Plugin Portal
apply plugin: "org.apache.grails.gradle.grails-web"
apply plugin: "org.apache.grails.gradle.grails-gsp"
apply plugin: "cloud.wondrify.asset-pipeline"

group = "example.grails"

repositories {
    maven {
       url = 'file:/Users/rahul/Dev/grails-core/build/local-maven/'
    }
    mavenCentral()
    maven {
       url = 'https://repo.grails.org/grails/restricted'
    }
    maven {
       url = 'https://repository.apache.org/content/groups/snapshots'
       content {
          includeVersionByRegex('org[.]apache[.]grails.*', '.*', '.*-SNAPSHOT')
       }
       content {
          includeVersionByRegex('org[.]apache[.]groovy.*', 'groovy.*', '.*-SNAPSHOT')
       }
       mavenContent {
          snapshotsOnly()
       }
    }
    maven {
       url = 'https://repository.apache.org/content/groups/staging'
       content {
          includeVersionByRegex('org[.]apache[.]grails[.]gradle', 'grails-publish', '.*')
       }
       content {
          includeVersionByRegex('org[.]apache[.]groovy.*', 'groovy.*', '.*')
       }
       mavenContent {
          releasesOnly()
       }
    }
}

dependencies {
    profile "org.apache.grails.profiles:web"
    developmentOnly "org.springframework.boot:spring-boot-devtools" // Spring Boot DevTools may cause performance slowdowns or compatibility issues on larger applications
    testAndDevelopmentOnly "org.webjars.npm:bootstrap"
    testAndDevelopmentOnly "org.webjars.npm:bootstrap-icons"
    testAndDevelopmentOnly "org.webjars.npm:jquery"
    implementation platform("org.apache.grails:grails-bom:$grailsVersion")
    implementation "org.apache.grails:grails-core"
    implementation "org.apache.grails:grails-data-hibernate5"
    implementation "org.apache.grails:grails-databinding"
    implementation "org.apache.grails:grails-events"
    implementation "org.apache.grails:grails-gsp"
    implementation "org.apache.grails:grails-interceptors"
    implementation "org.apache.grails:grails-layout"
    implementation "org.apache.grails:grails-logging"
    implementation "org.apache.grails:grails-rest-transforms"
    implementation "org.apache.grails:grails-scaffolding"
    implementation "org.apache.grails:grails-services"
    implementation "org.apache.grails:grails-url-mappings"
    implementation "org.apache.grails:grails-web-boot"
    implementation "org.springframework.boot:spring-boot-autoconfigure"
    implementation "org.springframework.boot:spring-boot-starter"
    implementation "org.springframework.boot:spring-boot-starter-actuator"
    implementation "org.springframework.boot:spring-boot-starter-logging"
    implementation "org.springframework.boot:spring-boot-starter-tomcat"
    implementation "org.springframework.boot:spring-boot-starter-validation"
    console "org.apache.grails:grails-console"
    runtimeOnly "cloud.wondrify:asset-pipeline-grails"
    runtimeOnly "com.h2database:h2"
    runtimeOnly "com.zaxxer:HikariCP"
    runtimeOnly "org.fusesource.jansi:jansi"
    integrationTestImplementation testFixtures("org.apache.grails:grails-geb")
    testImplementation "org.apache.grails:grails-testing-support-datamapping"
    testImplementation "org.apache.grails:grails-testing-support-web"
    testImplementation "org.spockframework:spock-core"
}

compileJava.options.release = 17

tasks.withType(Test).configureEach {
    useJUnitPlatform()
}

assets {
    excludes = [
            'webjars/jquery/**',
            'webjars/bootstrap/**',
            'webjars/bootstrap-icons/**'
    ]
    includes = [
            'webjars/jquery/*/dist/jquery.js',
            'webjars/bootstrap/*/dist/js/bootstrap.bundle.js',
            'webjars/bootstrap/*/dist/css/bootstrap.css',
            'webjars/bootstrap-icons/*/font/bootstrap-icons.css',
            'webjars/bootstrap-icons/*/font/fonts/*',
    ]
}

tasks.withType(GroovyCompile).configureEach {
    // encoding needs to be the same since it's different across platforms
    groovyOptions.encoding = 'UTF_8'
    // Preserve method parameter names in Groovy/Java classes for IDE parameter hints & bean reflection metadata.
    groovyOptions.parameters = true
    // encoding needs to be the same since it's different across platforms
    options.encoding = 'UTF_8'
    // https://github.com/apache/grails-core/issues/15321
    groovyOptions.optimizationOptions.indy = false
}

tasks.withType(JavaCompile).configureEach {
    // Preserve method parameter names in Groovy/Java classes for IDE parameter hints & bean reflection metadata.
    options.compilerArgs.add('-parameters')
    // encoding needs to be the same since it's different across platforms
    options.encoding = 'UTF_8'
}

Copy link
Contributor

@jdaugherty jdaugherty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We maintain 2 app generation tools currently - both grails-profile based and grails-forge based. Can you please update the associated profile skeleton too?

@rahulshishodia
Copy link
Author

@jdaugherty - Thankyou for pointing this out! (TIL). I have added the same in grails-profiles/base/skeleton/build.gradle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants