diff --git a/build.gradle b/build.gradle index ebc7b13..c7f57b2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,34 @@ +buildscript { + repositories { + maven { url "https://repo.grails.org/grails/core" } + mavenCentral() + } + dependencies { // Not Published to Gradle Plugin Portal + classpath "org.grails:grails-gradle-plugin:6.2.4" + } +} + plugins { id "groovy" id "java-library" id "war" id "idea" - id "org.grails.grails-plugin" - id "org.grails.internal.grails-plugin-publish" id "application" id "eclipse" + id "maven-publish" } -group "org.grails.plugins" +// Not Published to Gradle Plugin Portal +apply plugin: "org.grails.grails-plugin" -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +group "org.grails.plugins" repositories { mavenCentral() - maven { url "https://repo.grails.org/grails/core" } + maven { + name "Grails" + url "https://repo.grails.org/grails/core" + } } dependencyManagement { @@ -35,18 +47,23 @@ dependencies { implementation "org.grails:grails-web-boot" implementation "org.grails:grails-dependencies" - api 'net.sf.opencsv:opencsv:2.3' + api 'com.opencsv:opencsv:5.10' - api 'com.lowagie:itext:2.1.7' - api "com.lowagie:itext-rtf:2.1.7" + api 'com.github.librepdf:openpdf:1.4.2' + api 'com.github.librepdf:openrtf:1.2.1' runtimeOnly 'xerces:xercesImpl:2.12.2' - api 'org.odftoolkit:simple-odf:0.6.6' - api 'net.sourceforge.jexcelapi:jxl:2.6.12' - api 'commons-beanutils:commons-beanutils:1.9.4' - api 'commons-codec:commons-codec:1.17.0' + api 'org.odftoolkit:simple-odf:0.9.0' + api 'org.apache.poi:poi:5.4.0' + api 'org.apache.poi:poi-ooxml:5.4.0' - testCompileOnly "org.grails:grails-plugin-testing" + api 'commons-beanutils:commons-beanutils:1.10.1' + api 'commons-codec:commons-codec:1.18.0' +} + +java { + sourceCompatibility = JavaVersion.toVersion("11") + targetCompatibility = JavaVersion.toVersion("11") } jar { @@ -64,24 +81,94 @@ jar { archiveClassifier='' } -grailsPublish { - license { - name = 'Apache-2.0' - } +publishing { + publications { + maven(MavenPublication) { + pom { + name = "Grails Export Plugin" + description = "This plugin offers export functionality supporting different formats e.g. CSV, Excel, Open Document Spreadsheet, PDF and XML and can be extended to add additional formats." - title = "Grails Export Plugin" - desc = "This plugin offers export functionality supporting different formats e.g. CSV, Excel, Open Document Spreadsheet, PDF and XML and can be extended to add additional formats." - - developers = [ graemerocher: 'Graeme Rocher', - puneetbehl: 'Puneet Behl', - nwwells: 'Nathan Wells', - tulu: 'Ruben', - arturoojeda: 'Arturo Ojeda López', - fabiooshiro: 'Fabio Issamu Oshiro', - ddelponte: 'Dean Del Ponte', - cristallo: 'Cristiano Limiti', - mirweb: 'Mirko Weber', - joasgarcia: 'Joás Garcia', - frangarcia: 'Fran García', - dustindclark: 'Dustin Clark' ] + licenses { + license { + name = "The Apache License, Version 2.0" + url = "http://www.apache.org/licenses/LICENSE-2.0.txt" + } + } + developers { + developer { + id = "graemerocher" + name = 'Graeme Rocher' + } + developer { + id = "puneetbehl" + name = 'Puneet Behl' + } + developer { + id = "nwwells" + name = 'Nathan Wells' + } + developer { + id = "tulu" + name = 'Ruben' + } + developer { + id = "arturoojeda" + name = 'Arturo Ojeda López' + } + developer { + id = "fabiooshiro" + name = 'Fabio Issamu Oshiro' + } + developer { + id = "ddelponte" + name = 'Dean Del Ponte' + } + developer { + id = "cristallo" + name = 'Cristiano Limiti' + } + developer { + id = "mirweb" + name = 'Mirko Weber' + } + developer { + id = "joasgarcia" + name = 'Joás Garcia' + } + developer { + id = "frangarcia" + name = 'Fran García' + } + developer { + id = "dustindclark" + name = 'Dustin Clark' + } + developer { + id = "miq" + name = 'Mihael Koep' + email = 'mihael.koep@softwareschneiderei.de' + } + } + } + + versionMapping { + usage('java-api') { + fromResolutionOf('runtimeClasspath') + } + usage('java-runtime') { + fromResolutionResult() + } + } + from components.java + repositories { + maven { + credentials { + username "$mavenUser" + password "$mavenPassword" + } + url "$mavenUrl" + } + } + } + } } diff --git a/gradle.properties b/gradle.properties index bdfdba0..b666168 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,5 @@ grailsVersion=5.3.6 grailsGradlePluginVersion=5.3.1 org.gradle.daemon=true org.gradle.parallel=true -org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1024M \ No newline at end of file +org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1024M +org.gradle.logging.level=info diff --git a/gradle/publish.gradle b/gradle/publish.gradle index fb15ed4..67c9451 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -39,8 +39,6 @@ if (bintrayProperties.exists()) { } } -// Publish gh-pages on github -apply plugin: "org.ajoberstar.github-pages" File githubProperties = project.rootProject.file('github.properties') if (githubProperties.exists()) { diff --git a/grails-app/controllers/grails/plugins/export/TestController.groovy b/grails-app/controllers/grails/plugins/export/TestController.groovy index 40713ac..8375632 100644 --- a/grails-app/controllers/grails/plugins/export/TestController.groovy +++ b/grails-app/controllers/grails/plugins/export/TestController.groovy @@ -4,13 +4,19 @@ class TestController { def exportService def index() { - def list = [[name:'Grails', version:'5.0']] - String ext = params.extension?:params.format - if (ext in ['csv', 'xls', 'ods', 'pdf', 'rtf', 'xml']) { + def data = [[name:'Grails', version:'5.0', 'current date': new Date()]] + String ext = params.extension ?: params.format + if (ext in ['csv', 'xls', 'xlsx', 'ods', 'pdf', 'rtf', 'xml']) { response.setHeader("Content-disposition", "attachment; filename=test.${ext}") - exportService.export(ext == 'xls'?'excel':ext, response.outputStream, list, [:], [:]) - } else { - respond list + def parameters = [ + 'fileFormat': ext, + 'dateFormat': 'yyyy-MM-dd HH:mm:SS', + 'column.width.autoSize': true + ] + exportService.export(ext == 'xls' || ext == 'xlsx' ? 'excel' : ext, response.outputStream, data, [:], parameters) + return } + + respond data } } diff --git a/grails-app/services/grails/plugins/export/ExportService.groovy b/grails-app/services/grails/plugins/export/ExportService.groovy index 4b23c96..3a4450e 100644 --- a/grails-app/services/grails/plugins/export/ExportService.groovy +++ b/grails-app/services/grails/plugins/export/ExportService.groovy @@ -6,8 +6,6 @@ import grails.core.GrailsApplication class ExportService { - boolean transactional = false - def exporterFactory GrailsApplication grailsApplication @@ -32,5 +30,4 @@ class ExportService { Exporter exporter = exporterFactory.createExporter(type, fields, labels, formatters, parameters) exporter.export(response.outputStream, objects) } - } diff --git a/grails-app/taglib/grails/plugins/export/ExportTagLib.groovy b/grails-app/taglib/grails/plugins/export/ExportTagLib.groovy index e3266e8..1a7d7a8 100644 --- a/grails-app/taglib/grails/plugins/export/ExportTagLib.groovy +++ b/grails-app/taglib/grails/plugins/export/ExportTagLib.groovy @@ -1,6 +1,7 @@ package grails.plugins.export import grails.plugins.export.taglib.util.RenderUtils +import groovy.xml.MarkupBuilder class ExportTagLib { @@ -8,7 +9,7 @@ class ExportTagLib { def formats = { attrs -> StringWriter writer = new StringWriter() - def builder = new groovy.xml.MarkupBuilder(writer) + def builder = new MarkupBuilder(writer) if(!attrs?.'class'){ attrs.'class' = "export" @@ -27,7 +28,7 @@ class ExportTagLib { attrs.remove("controller") } - List formats = ['csv', 'excel', 'ods', 'pdf', 'rtf', 'xml'] + List formats = ['csv', 'excel 97', 'excel (NEW)', 'ods', 'pdf', 'rtf', 'xml'] if(attrs?.formats){ formats = new ArrayList(attrs.formats) attrs.remove("formats") @@ -39,7 +40,7 @@ class ExportTagLib { attrs.remove("params") } - Map extensions = [excel: "xls"] + Map extensions = ['excel 97': "xls", 'excel (NEW)': 'xlsx'] builder."div"(attrs){ formats.each { format -> @@ -75,7 +76,7 @@ class ExportTagLib { def resource = { attrs -> StringWriter writer = new StringWriter() - def builder = new groovy.xml.MarkupBuilder(writer) + def builder = new MarkupBuilder(writer) String resourcePath = RenderUtils.getResourcePath("export", request?.contextPath) diff --git a/grails-app/views/test/index.gsp b/grails-app/views/test/index.gsp index 797e349..1a4e60b 100644 --- a/grails-app/views/test/index.gsp +++ b/grails-app/views/test/index.gsp @@ -5,6 +5,6 @@
-