Giter Club home page Giter Club logo

foprenderer's Introduction

fopRenderer

Gradle Plugin for Validating XMLs and rendering them with Apache FOP.

Note: The plugin is no longer in active development by me. I will try to maintain existing functionality whenever needed. Also see 'Contributing'.

Usage

plugins block:

groovy

plugins {
  id "com.github.ramonwirsch.FopRenderer" version "0.4.0"
}

kotlin

plugins {
    id("com.github.ramonwirsch.FopRenderer") version "0.4.0"
}

or via the

buildscript block (groovy):

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "gradle.plugin.com.github.ramonwirsch:fopRenderer:0.4.0"
  }
}

apply plugin: "com.github.ramonwirsch.FopRenderer"

fopRenderer configuration:

groovy

fopRenderer {
  // groups of files to validated each against 1 schema (URL or local file)
	schemas {
		schemaGroupName { // used for task names
			files = file('some.xml') // or fileTree(dir: 'xmlDir', include: '*.xml')
			schemaUri = 'http://www.url.com/to/some/schema.xsd'
			offlineSchema = file('offlineSchema.xsd') // [optional]
			useInherentSchemas = false // [default: false] uses xsi:schemaLocation tags or Doctype statements in the XML files for validation instead of forced schema
		}
		// ... as many different groups as you like
	}
	
	// files that should be rendered with FOP
	render {
		renderGroupName { // used for task names
			stylesheet = file('stylesheet.xsl')
			rootSrc = file('main/file/to/render.xml')
			dependencies = fileTree('dep-files/*.xml') // files that are monitored by transformTask. Defaults to siblings of rootSrc
			resourcesBaseDir = file('resources/dir') // pictures and other resources. Links will be interpreted relative to this
			resourceCollectionParams = [exclude: '**/*.xml'] // default: params for resource fileTree.
			// resources + resourceCollectionParams will be combined into a FileCollection that is monitored for changes by the renderTask
			requiresValidation = true // [default: true] whether to require passing of schema validation before attempting to transform/render
		}
	}
}

kotlin

fopRenderer {
  // groups of files to validated each against 1 schema (URL or local file)
	schemas {
		"schemaGroupName" { // used for task names
			files = file("some.xml") // or fileTree(dir: "xmlDir", include: "*.xml")
			setSchemaUri("http://www.url.com/to/some/schema.xsd")
			offlineSchema = file("offlineSchema.xsd") // [optional]
			isUseInherentSchemas = false // [default: false] uses xsi:schemaLocation tags or Doctype statements in the XML files for validation instead of forced schema
		}
		// ... as many different groups as you like
	}
	
	// files that should be rendered with FOP
	render {
		"renderGroupName" { // used for task names
			stylesheet = file("stylesheet.xsl")
			rootSrc = file("main/file/to/render.xml")
			dependencies = fileTree("dep-files/*.xml") // files that are monitored by transformTask. Defaults to siblings of rootSrc
			resourcesBaseDir = file("resources/dir") // pictures and other resources. Links will be interpreted relative to this
			resourceCollectionParams = mapOf("exclude" to "**/*.xml") // default: params for resource fileTree.
			// resources + resourceCollectionParams will be combined into a FileCollection that is monitored for changes by the renderTask
			isRequiresValidation = true // [default: true] whether to require passing of schema validation before attempting to transform/render
		}
	}
}

The plugin will prioritize the online schemas if they are set, except if the gradle property offlineSchemas is true. This can be done via command line with -PofflineSchemas=true.

The render block is optional, as is any actual schema group, so both functions can be used pretty much separately.

tasks

  • validate<SchemaGroupName> tasks for every schema group
  • validate task that depends on all other validations
  • transform<RenderGroupName> tasks for every render group. Apply the respective XSLT stylesheets.
  • render<RenderGroupName> tasks for every render group. This will use FOP to generate a PDF.

the render<> tasks depend each on their transform<> task, which in turn depends on validate. the base build task is configured to depend on all render<> tasks, the base check task is configured to depend on validate

Contributing

I originally wrote this plugin to replace really old Ant and Make code in a preexisting project. Therefore the plugin did, what I needed it to do and I just used said project to test the plugin, instead of writing automated tests for it. Given, that I no longer have any active need for the plugin, I am very unlikely to add any new features to it. I am however happy to update the plugin to keep working on new Gradle versions. If the plugin starts failing, create an issue. I am also happy to accept merge requests with additional functionality and will test the plugin against my old use case and publish it. But if new features are added, we really also need to add (automated) tests, as I otherwise cannot verify the plugin keeps working, before publishing updates. I will try to find time and aid in adding CI support and tests for my existing functionality, should there be any interest in doing so.

foprenderer's People

Contributors

ramonwirsch avatar jakobwenzel avatar dgeissl avatar vjlamp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.