]> source.dussan.org Git - poi.git/commitdiff
provide dist files via gradle
authorAndreas Beeker <kiwiwings@apache.org>
Mon, 19 Jul 2021 21:59:38 +0000 (21:59 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Mon, 19 Jul 2021 21:59:38 +0000 (21:59 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891666 13f79535-47bb-0310-9956-ffa450edef68

build.gradle
poi-integration/build.gradle
poi-ooxml-lite/build.gradle

index 8d19892cd3ce5de2f608e618329000840265afe5..165c1fe420a4fd6bc26e9baa5484604b0fed967c 100644 (file)
 
 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 {
@@ -39,7 +40,7 @@ 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
@@ -393,12 +394,13 @@ subprojects {
 
 // 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
@@ -427,11 +429,11 @@ task allJavaDoc(type: Javadoc) {
        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"
@@ -501,56 +503,152 @@ rat {
 
 //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&lt;/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
index 22114ba9b4c7ad4d9c974ad03c2f77238c089870..43afa39b512a754dcf3e6d431206efbc905d4543 100644 (file)
@@ -138,3 +138,9 @@ test {
         }
     }
 }
+
+javadoc.onlyIf { false }
+
+javadocJar.onlyIf { false }
+
+sourcesJar.onlyIf { false }
\ No newline at end of file
index a5245419d61f2097ab6157a364839f7b5aa2532a..96d58f3ec3fb3e51c21642b983e2dd3952290716 100644 (file)
@@ -46,25 +46,14 @@ final Pattern MODULE_REGEX = ~'\\.jar$'
 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')
@@ -74,13 +63,28 @@ task compileOoxmlLite(type: Copy) {
             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