Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 8
java-version: 11
cache: 'gradle'

- name: Run Checks
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ This repo is open-source under the [Universal Permissive License](https://openso
Gradle build
------------

### Java version

The build now targets Java 11.

Use a Java 11 runtime when invoking `./gradlew`.

### Tests

To run all self-tests, run

./gradlew test

To run the full verification build, run

./gradlew check

21 changes: 10 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ apply plugin: 'java'

repositories {
mavenCentral()
jcenter()
maven{url "https://jaspersoft.jfrog.io/artifactory/third-party-ce-artifacts/"}
maven { url = uri("https://jaspersoft.jfrog.io/artifactory/third-party-ce-artifacts/") }
}

def formsSourceDir = file(formsSourceDir)
Expand All @@ -15,13 +14,13 @@ def formsParamDir = file(formsParamDir)
def errorFormFile = file(errorFormFile)

task (compileErrorForm, type: JasperReportsCompile) {
srcDir file('buildSrc/src/main/resources')
outDir errorFormFile.parentFile
srcDir.set(file('buildSrc/src/main/resources'))
outDir.set(errorFormFile.parentFile)
}

task (compileForms, type: JasperReportsCompile) {
srcDir formsSourceDir
outDir formsOutputDir
srcDir.set(formsSourceDir)
outDir.set(formsOutputDir)
}

task (copyResources, type: Sync) {
Expand All @@ -41,10 +40,10 @@ task (cleanPDF, type: Delete) {
}

task (renderForms, type: RenderFormsTask, dependsOn: [compileForms, copyResources, compileErrorForm]) {
dataDir = formsParamDir
formSrcDir = formsSourceDir
localFormDir = formsOutputDir
outputDir = formsPDFDir
errorForm = errorFormFile
dataDir.set(formsParamDir)
formSrcDir.set(formsSourceDir)
localFormDir.set(formsOutputDir)
outputDir.set(formsPDFDir)
errorForm.set(errorFormFile)
}

62 changes: 33 additions & 29 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,55 @@ apply plugin: 'groovy'

repositories {
mavenCentral()
maven{url "https://jaspersoft.jfrog.io/artifactory/third-party-ce-artifacts/"}
maven{url "https://jitpack.io"}
maven { url = uri("https://jaspersoft.jfrog.io/artifactory/third-party-ce-artifacts/") }
maven { url = uri("https://jitpack.io") }
}

dependencies {
compile gradleApi()
compile localGroovy()
implementation gradleApi()
implementation localGroovy()
// These are available only when running inside the forms repo
compile fileTree("../../../fonts")
compile 'net.sourceforge.nekohtml:nekohtml:1.9.21'
testCompile ("org.spockframework:spock-core:1.0-groovy-2.4") {
implementation fileTree("../../../fonts")
implementation 'net.sourceforge.nekohtml:nekohtml:1.9.21'
testImplementation ("org.spockframework:spock-core:2.3-groovy-3.0") {
exclude group: "org.codehaus.groovy"
}
compile 'com.github.riege:jasper-service-functions:1.2.5'
implementation 'com.github.riege:jasper-service-functions:1.2.5'

// dependencies for com.riege.akka.* packages
compile 'org.scala-lang:scala-reflect:2.12.8'
compile 'com.typesafe.akka:akka-http-spray-json_2.12:10.1.10'
compile 'com.typesafe.akka:akka-stream_2.12:2.5.20'
implementation 'org.scala-lang:scala-reflect:2.12.8'
implementation 'com.typesafe.akka:akka-http-spray-json_2.12:10.1.10'
implementation 'com.typesafe.akka:akka-stream_2.12:2.5.20'

// BEGIN AUTO-GENERATED JASPER SERVICE DEPENDENCIES
compile 'com.github.pathikrit:better-files_2.12:3.7.0'
compile 'com.google.zxing:core:3.4.0'
// compile 'com.riege:rsi-akka-json_2.12:1.1.4'
// compile 'com.riege:rsi-akka-utils_2.12:1.1.4'
compile 'com.typesafe.akka:akka-actor_2.12:2.5.20'
compile 'com.typesafe.akka:akka-slf4j_2.12:2.5.20'
compile 'net.sf.barcode4j:barcode4j:2.1'
compile 'net.sf.jasperreports:jasperreports-fonts:6.14.0'
compile 'net.sf.jasperreports:jasperreports:6.14.0'
compile 'net.sourceforge.barbecue:barbecue:1.5-beta1'
compile 'org.apache.xmlgraphics:batik-bridge:1.10'
compile 'org.apache.xmlgraphics:batik-codec:1.10'
compile 'org.apache.xmlgraphics:batik-gvt:1.10'
compile 'org.apache.xmlgraphics:batik-svg-dom:1.10'
compile 'org.scala-lang:scala-library:2.12.8'
implementation 'com.github.pathikrit:better-files_2.12:3.7.0'
implementation 'com.google.zxing:core:3.4.0'
implementation 'com.typesafe.akka:akka-actor_2.12:2.5.20'
implementation 'com.typesafe.akka:akka-slf4j_2.12:2.5.20'
implementation 'net.sf.barcode4j:barcode4j:2.1'
implementation 'net.sf.jasperreports:jasperreports-fonts:6.14.0'
implementation 'net.sf.jasperreports:jasperreports:6.14.0'
implementation 'net.sourceforge.barbecue:barbecue:1.5-beta1'
implementation 'org.apache.xmlgraphics:batik-bridge:1.10'
implementation 'org.apache.xmlgraphics:batik-codec:1.10'
implementation 'org.apache.xmlgraphics:batik-gvt:1.10'
implementation 'org.apache.xmlgraphics:batik-svg-dom:1.10'
implementation 'org.scala-lang:scala-library:2.12.8'
// END AUTO-GENERATED JASPER SERVICE DEPENDENCIES
}

compileGroovy {
classpath = classpath.plus(files(compileScala.destinationDir))
dependsOn compileScala
tasks.named('compileGroovy') {
dependsOn tasks.named('compileScala')
classpath += files {
def scalaCompile = tasks.named('compileScala').get()
scalaCompile.hasProperty('destinationDirectory')
? scalaCompile.destinationDirectory.get().asFile
: scalaCompile.destinationDir
}
}

test {
useJUnitPlatform()
ignoreFailures = true
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@

package com.riege.scope.gradle.forms

import org.gradle.api.tasks.incremental.InputFileDetails

class FormRenderDataCache {

private Map<String, FormRenderData> cache = [:]

void invalidate(List<InputFileDetails> dirtyFiles) {
dirtyFiles.each { change ->
void invalidate(Collection<File> dirtyFiles) {
dirtyFiles.each { dirtyFile ->
def it = cache.entrySet().iterator()
it.forEachRemaining { entry ->
if (entry.value.hasDependency(change.file)) {
if (entry.value.hasDependency(dirtyFile)) {
it.remove()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import net.sf.jasperreports.engine.SimpleJasperReportsContext
import net.sf.jasperreports.engine.design.JRCompiler
import net.sf.jasperreports.engine.xml.JRReportSaxParserFactory
import org.gradle.api.DefaultTask
import org.gradle.api.logging.Logger
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.FileType
import org.gradle.api.tasks.*
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
import org.gradle.work.ChangeType
import org.gradle.work.FileChange
import org.gradle.work.Incremental
import org.gradle.work.InputChanges

import java.awt.*
import java.awt.Color
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ForkJoinPool
import java.util.concurrent.RecursiveAction
Expand All @@ -25,39 +29,40 @@ import java.util.concurrent.RecursiveAction
*/
class JasperReportsCompile extends DefaultTask {

@Incremental
@InputDirectory
File srcDir
@PathSensitive(PathSensitivity.RELATIVE)
final DirectoryProperty srcDir = project.objects.directoryProperty()

@OutputDirectory
File outDir
final DirectoryProperty outDir = project.objects.directoryProperty()

@Input
String srcExt = '.jrxml'

@Input
String outExt = '.jasper'

@Input
boolean verbose = false

Logger log = getLogger()

protected ClassLoader cachingClassLoader

@TaskAction
def execute(IncrementalTaskInputs inputs) {
def execute(InputChanges inputs) {
// Disable logging for JasperReports
// TODO: this does not work as Gradle uses its own logging
//java.util.logging.Logger.getLogger("net.sf.jasperreports")
// .setLevel(Level.SEVERE)

// Pre-loads AWT classes to avoid strange deadlock in the JVM.
def color = new Color(0)
log.debug("Loaded colors {}", (Object) color)
logger.debug("Loaded colors {}", (Object) color)

cachingClassLoader = new CachingClassLoader(getClass().classLoader)

if (!outDir.exists()) {
outDir.mkdirs()
if (!outDir.get().asFile.exists()) {
outDir.get().asFile.mkdirs()
}

def jasperReportsContext = new SimpleJasperReportsContext()
Expand All @@ -76,58 +81,43 @@ class JasperReportsCompile extends DefaultTask {

def pool = new ForkJoinPool(Runtime.runtime.availableProcessors())

def findFormsTask = new FindFormsTask(manager, inputs)
pool.execute(findFormsTask)
findFormsTask.join()
}

class FindFormsTask extends RecursiveAction {

private final JasperCompileManager manager
private final IncrementalTaskInputs inputs

FindFormsTask(JasperCompileManager manager, IncrementalTaskInputs inputs) {
this.manager = manager
this.inputs = inputs
}

@Override
protected void compute() {
def compilationTasks = []
inputs.outOfDate { change ->
if (change.file.name.endsWith(srcExt)) {
if (verbose) {
log.lifecycle "Found form ${change.file.name}"
}
def compileTask = new CompileFormTask(manager, change.file, toCompiledForm(change.file))
compileTask.fork()
compilationTasks << compileTask
}
def compilationTasks = []
inputs.getFileChanges(srcDir).each { FileChange change ->
if (change.fileType != FileType.FILE || !change.file.name.endsWith(srcExt)) {
return
}
inputs.removed { change ->

if (change.changeType == ChangeType.REMOVED) {
if (verbose) {
log.lifecycle "Removed file ${change.file.name}"
logger.lifecycle "Removed file ${change.file.name}"
}
def fileToRemove = toCompiledForm(change.file)
fileToRemove.delete()
toCompiledForm(change.file).delete()
return
}
compilationTasks.each { CompileFormTask task ->
task.join()
}
}

private File toCompiledForm(File src) {
def form = src.absolutePath.replace(srcExt, outExt).substring(srcDir.absolutePath.length())
def formPath = outDir.absolutePath
if (!formPath.endsWith(File.separator)) {
formPath += File.separator
if (verbose) {
logger.lifecycle "Found form ${change.file.name}"
}
formPath += form
new File(formPath)
def compileTask = new CompileFormTask(manager, change.file, toCompiledForm(change.file))
pool.execute(compileTask)
compilationTasks << compileTask
}

compilationTasks.each { it.join() }
}

protected File toCompiledForm(File src) {
def sourceRoot = srcDir.get().asFile
def form = src.absolutePath.replace(srcExt, outExt).substring(sourceRoot.absolutePath.length())
def formPath = outDir.get().asFile.toString()
if (!formPath.endsWith(File.separator)) {
formPath += File.separator
}
formPath += form
new File(formPath)
}


class CompileFormTask extends RecursiveAction {

private final JasperCompileManager manager
Expand All @@ -146,7 +136,7 @@ class JasperReportsCompile extends DefaultTask {
protected void compute() {
Thread.currentThread().setContextClassLoader(cachingClassLoader)
if (verbose) {
log.lifecycle "Compiling form ${sourceForm}"
logger.lifecycle "Compiling form ${sourceForm}"
}
try {
def destFileParent = compiledForm.getParentFile()
Expand All @@ -155,7 +145,7 @@ class JasperReportsCompile extends DefaultTask {
}
manager.compileToFile(sourceForm.absolutePath, compiledForm.absolutePath)
} catch (JRException e) {
log.lifecycle("Compiling report design '" + sourceForm.absolutePath
logger.lifecycle("Compiling report design '" + sourceForm.absolutePath
+ "' failed due to:\n" + e.getMessage())
throw new TaskExecutionException(JasperReportsCompile.this, e)
}
Expand Down
Loading
Loading