eerohele / saxon-gradle

A Gradle plugin for running XSLT transformations with Saxon
MIT License
16 stars 6 forks source link

Parameter "input" accepts filetree; how to emit output to a file tree. #18

Open greyp-ionic opened 4 years ago

greyp-ionic commented 4 years ago

Proposed functionality: (1) or (2)

(1) If "input" is a fileTree, "output" should be interpreted as a base folder for output, following input folder structure.

Example:

SOURCE TREE source source/a source/a/foo.xhtml source/b source/b/bar.xhtml

TASK CONFIG SaxonXsltTask

DESIRED TARGET TREE target target/a target/a/foo.xhtml target/b target/b/bar.xhtml

As of version 0.8.0, all output goes to folder specified in "output", ignoring folder structure.

(2) If "input" is a fileTree, and "output" is not specified, overwrite input files with output files as they are processed.

greyp-ionic commented 4 years ago

Since "fileTree" can handle an input folder with arbitrary structure, it would be nice to style content from that fileTree without need for post-processing move / copy.

Maybe this functionality already exists. If so, any pointers to take advantage would be appreciated.

eerohele commented 4 years ago

Thanks for reporting the issue! I see what you mean and why that'd be useful. I'll look into it when I get the chance.

greyp-ionic commented 4 years ago

Thank you

eerohele commented 4 years ago

0.9.0-beta1 adds rudimentary support for nested output directory layouts.

To use it, add outputDirectoryLayout 'nested' into the xslt task in your Gradle build file.

For the moment, it only works if both the input and output directories are under the project root directory. Behavior in all other situations (including symlinks) is undefined. If you need better support than what this version offers, feel free to comment here and I'll see what I can do.

If you can, it'd be a great help if you could try out 0.9.0-beta1 and let me know whether it works for you.

ionicsdk commented 4 years ago

Before I tried out the new option, I replaced the dependency reference in my gradle buildscript declaration.

from:

buildscript { repositories { ... maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "gradle.plugin.com.github.eerohele:saxon-gradle:0.8.0" } }

to:

buildscript { repositories { ... maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "gradle.plugin.com.github.eerohele:saxon-gradle:0.9.0-beta1" } }

When I do this, I get the following error in phase one of Gradle script execution:

gradle clean

running Gradle 2

FAILURE: Build failed with an exception.

BUILD FAILED

Total time: 8.769 secs

C:\Users\pgrey\dev\scm\stash\a2sdk\JavaSDK\Windows>

Java 8 / Gradle 2.14

eerohele commented 4 years ago

That's a really old Gradle version. Gradle is currently at 6.0.

0.9.0-beta1 uses the Gradle Worker API, which was introduced in 5.0, I think, so anything older than that won't work.

Is it possible for you to upgrade to a newer Gradle version?

greyp-ionic commented 4 years ago

Ah, Gradle Worker API. That explains things.

Yes, 2.14 is an old version. I could run a newer Gradle to test this change, but I'm sure it works as advertised.

Thanks so much for your responsiveness and for your work! I do hope this change helps out others who don't have the same constraints.

eerohele commented 4 years ago

If you cannot upgrade from Gradle 2.14, I think I can backport the outputDirectoryLayout change on top of 0.8.0 and shunt the Worker API upgrade to 1.0 (or something), since it’s a breaking change.

I’ll see what I can do.