buildscript {
repositories {
- maven { url "https://plugins.gradle.org/m2/" }
+ maven { url 'https://plugins.gradle.org/m2/' }
mavenCentral()
}
dependencies {
- classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.1.1"
- classpath "de.thetaphi:forbiddenapis:3.1"
+ classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.1.1'
+ classpath 'de.thetaphi:forbiddenapis:3.1'
}
}
plugins {
id 'base'
- id("org.nosphere.apache.rat") version "0.7.0"
+ id('org.nosphere.apache.rat') version '0.7.0'
+ id 'distribution'
}
repositories {
// Only add the plugin for Sonar if enabled
if (project.hasProperty('enableSonar')) {
println 'Enabling Sonar support'
- apply plugin: "org.sonarqube"
+ apply plugin: 'org.sonarqube'
}
// For help converting an Ant build to a Gradle build, see
// initial try to provide a combined JavaDoc, grouping is still missing here, though!
task allJavaDoc(type: Javadoc) {
- source subprojects.collect { it.sourceSets.main.allJava }
+ var prj = [ project(':poi'), project(':poi-excelant'), project(':poi-ooxml'), project(':poi-scratchpad') ]
+ source prj.collect { it.sourceSets.main.allJava }
// for possible settings see https://docs.gradle.org/current/dsl/org.gradle.api.tasks.javadoc.Javadoc.html
classpath = files(subprojects.collect { it.sourceSets.main.compileClasspath })
destinationDir = file("${buildDir}/docs/javadoc")
- maxMemory="768M"
+ maxMemory="2048M"
// for possible options see https://docs.gradle.org/current/javadoc/org/gradle/external/javadoc/StandardJavadocDocletOptions.html
options.use = true
options.group('POIFS - POI File System', 'org.apache.poi.poifs*')
options.group('Utilities', 'org.apache.poi.util*')
options.group('Excelant', 'org.apache.poi.ss.excelant**')
- options.group('Examples', 'org.apache.poi.examples*')
+// options.group('Examples', 'org.apache.poi.examples*')
}
-task jenkins
-jenkins.dependsOn allJavaDoc
+
+task jenkins(dependsOn: ['replaceVersion', subprojects.build, 'binDistZip','binDistTar','srcDistZip','srcDistTar']) {}
clean {
delete "${rootDir}/build/dist"
//compileJava.dependsOn 'downloadJarsToLibs'
-task site(type:Exec) {
- doFirst {
- if (System.env.FORREST_HOME == null) {
- throw new InvalidUserDataException(
- 'Apache Forrest is not installed.\n' +
- 'Please install Apache Forrest (see https://forrest.apache.org/index.html) and set the\n' +
- 'FORREST_HOME environment variable!')
- }
-
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
- // maybe Java 9-11 works too?
- throw new GradleException("Apache Forrest must be executed with Java 8!")
- }
- }
-
- if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
- commandLine 'cmd', '/c', "${System.env.FORREST_HOME}/bin/forrest.bat"
- } else {
- commandLine "${System.env.FORREST_HOME}/bin/forrest"
- }
+task replaceVersion() {
+ outputs.upToDateWhen { false }
- //store the output instead of printing to the console:
- standardOutput = new ByteArrayOutputStream()
+ var version = subprojects[0].version
+ var tokens = [
+ [ 'sonar', '**/pom.xml', '(packaging>\\n\\s*<version>)[0-9.]+(?:-SNAPSHOT)?', "\\1${version}" ],
+ [ 'sonar', '**/pom.xml', '(poi-parent</artifactId>\\n\\s*<version>)[0-9.]+(?:-SNAPSHOT)?', "\1${version}" ],
+ [ 'osgi', 'pom.xml', '(packaging>\\n\\s*<version>)[0-9.]+(?:-SNAPSHOT)?', "\\1${version}" ]
+ // [ '.', 'build.gradle', ' version = \'[0-9.]+(?:-SNAPSHOT)?\'', " version = '${version}'" ]
+ ]
- ext.output = {
- return standardOutput.toString()
+ doLast {
+ tokens.forEach {
+ var dir = it[0], name = it[1], match = it[2], replace = it[3]
+ ant.replaceregexp(match: match, replace: replace) {
+ fileset(dir: dir) {
+ include(name: name)
+ }
+ }
+ }
}
+}
- doLast {
- println 'Broken links:'
- println file("${buildDir}/tmp/brokenlinks.xml").text
+task zipJavadocs(type: Zip, dependsOn: allJavaDoc) {
+ from('build/docs/javadoc/')
+ destinationDir = file('build/dist')
+ archiveBaseName = 'poi'
+ archiveVersion = subprojects[0].version
+ archiveAppendix = 'javadoc'
+ archiveExtension = 'jar'
+}
- /* Apache Forrest is dead, so we cannot expect fixes there however it does not handle "https" in "credits"
- currently if the *.xml file is in a sub-directory, see Apache Forrest code at
- main/webapp/skins/pelt/xslt/html/site-to-xhtml.xsl:350
+tasks.withType(Tar) {
+ compression = Compression.GZIP
+ archiveExtension = 'tgz'
+}
- So we need to replace the links afterwards to have a fully "https" website and avoid browser warning about
- a "mixed content" website */
- def buildSite = "${buildDir}/site"
+distributions {
+ var version = subprojects[0].version
+ var date = new Date().format('yyyyMMdd')
- println "Fix https in ${buildSite}"
+ var poiDep = project(':poi').configurations.getAt('compileClasspath')
+ var ooxmlImp = project(':poi-ooxml').configurations.getAt('compileClasspath')
- ant.replace(dir: buildSite, summary:'true', includes:'**/*.html',
- token:'http://www.apache.org/events/current-event-125x125.png',
- value:'https://www.apache.org/events/current-event-125x125.png')
+ bin {
+ distributionBaseName = "poi-bin-${version}-${date}"
+ contents {
+ from('build/dist/maven') {
+ include "**/*${version}.jar"
+ exclude "**/*lite-agent*.jar"
+ exclude "**/*integration*.jar"
+ }
- ant.replace(dir: buildSite, summary:'true', includes:'**/*.html',
- token:'http://www.google.com/search',
- value:'https://www.google.com/search')
+ from('build/dist') { include 'poi-javadoc*.jar'}
+ from('legal') { exclude 'HEADER' }
+ from(poiDep) { include "**/*.jar" }
+ from(ooxmlImp) { include "**/*.jar" }
+
+ includeEmptyDirs = false
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+
+ eachFile {
+ var root = "poi-bin-${version}/"
+ if (name.startsWith('poi')) {
+ path = root + name
+ } else if (poiDep.contains(file)) {
+ path = root + 'lib/' + name
+ } else if (name =~ /^(batik|bc|fontbox|graphics|pdfbox|xml-apis|xmlgraphics|xmlsec)/) {
+ path = root + 'auxiliary/' + name
+ } else if (ooxmlImp.contains(file)) {
+ path = root + 'ooxml-lib/' + name
+ } else {
+ path = root + name
+ }
+ }
+ }
+ }
- ant.fixcrlf(srcdir: buildSite, includes:'**/*.html,**/*.css', eol:'unix', eof:'remove')
+ src {
+ distributionBaseName = "poi-src-${version}-${date}"
+ contents {
+ from('.') {
+ exclude '*/build/**'
+ exclude 'build/**'
+ exclude 'dist*/**'
+ exclude 'lib/**'
+ exclude 'lib.stored/**'
+ exclude 'bin/**'
+ exclude 'out/**'
+ exclude 'tmp/**'
+ exclude 'gradle/**'
+ exclude 'sonar/**/target/**'
+ exclude 'sonar/*/src/**'
+ exclude 'compile-lib/**'
+ exclude 'ooxml-lib/**'
+ exclude 'ooxml-testlib/**'
+ exclude 'scripts/**'
+ exclude '.gradle/**'
+ exclude '.idea/**'
+ exclude '.classpath'
+ exclude '.settings/**'
+ exclude '.project'
+ exclude 'TEST*'
+ exclude 'gradlew'
+ exclude 'gradlew.bat'
+ exclude '**/*.iml'
+ exclude '*.ipr'
+ exclude '*.iws'
+ exclude '*.rdf'
+ exclude '*.png'
+ exclude '*.gif'
+ exclude '*.jpg'
+ exclude '*.jpeg'
+ exclude '*.swp'
+ exclude '*.lnk'
+ exclude '*.log'
+ exclude '*.launch'
+ exclude '*.docx'
+ exclude '*.pptx'
+ exclude '*.xlsx'
+ }
+ from('legal') { exclude 'HEADER' }
+ }
}
}
+
+binDistZip.dependsOn 'zipJavadocs'
+binDistTar.dependsOn 'zipJavadocs'
+
+var srcDep = [
+ ':poi:cacheJava9',
+ ':poi:cacheTest9',
+ ':poi-ooxml-full:cacheJava9',
+ ':poi-ooxml-lite-agent:cacheJava9',
+ ':poi-ooxml:cacheJava9',
+ ':poi-ooxml:cacheTest9',
+ ':poi-scratchpad:cacheJava9',
+ ':poi-scratchpad:cacheTest9',
+ ':poi-excelant:cacheJava9',
+ ':poi-excelant:cacheTest9',
+ ':poi-examples:cacheJava9',
+ ':poi-integration:cacheTest9',
+ ':poi-ooxml-lite:cacheJava9',
+ ':poi-ooxml-lite:generateModuleInfo'
+]
+
+srcDistTar.dependsOn srcDep
+srcDistZip.dependsOn srcDep
+rat.dependsOn srcDep
\ No newline at end of file
final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique()
final String OOXML_LITE_REPORT = '../build/ooxml-lite-report'
-
-task compileOoxmlLite(type: Copy) {
+task generateModuleInfo() {
dependsOn ':poi-ooxml:build', ':poi-integration:build', ':poi-excelant:build'
File fileIn = file("${OOXML_LITE_REPORT}.clazz")
File fileOut = file("src/main/java9/module-info.java")
- outputs.upToDateWhen{
- ant.uptodate(property: "ooxmlLiteUnchanged", srcfile: fileIn.path, targetfile: fileOut.path)
- ant.properties.ooxmlLiteUnchanged
- }
-
- // copy re-/sources to modules own directory to pacify IntelliJ, which doesn't like the same source dir in multiple modules
- from(project(':poi-ooxml-full').buildDir) {
- include 'generated-sources/**'
- include 'generated-resources/**'
- include 'classes/java/main/**'
- }
- into(buildDir)
+ inputs.file fileIn
+ outputs.file fileOut
doLast {
String header = fileOut.collect().findAll { !(it =~ /exports|}/) }.join('\n')
collect { " exports ${it.replaceAll('[/\\\\][^/\\\\]+$', '').replaceAll('[/\\\\]', '.')};" }.
findAll { !(it =~ /\.impl;$/) }.unique().sort().join('\n')
- String content = header + '\n' + exports + '\n}'
+ String content = header + '\n' + exports + '\n}\n'
if (fileOut.text != content) {
fileOut.write content
}
}
}
+task compileOoxmlLite(type: Copy) {
+ dependsOn 'generateModuleInfo'
+
+ // This task is currently always executed, because gradle thinks files with two dollar signs
+ // (as in AlternateContentDocument$AlternateContent$Choice.class) are always stale
+
+ // copy re-/sources to modules own directory to pacify IntelliJ, which doesn't like the same source dir in multiple modules
+ from(project(':poi-ooxml-full').buildDir) {
+ include 'generated-sources/**'
+ include 'generated-resources/**'
+ include 'classes/java/main/**'
+ }
+ into(buildDir)
+}
+
java {
sourceCompatibility = JavaVersion.VERSION_1_8