asciidoctor / asciidoctor-fopub

A portable DocBook-to-PDF build command that wraps DocBook XSL and Apache FOP
MIT License
113 stars 37 forks source link

fopub fails for offline builds on Windows #78

Closed apnadkarni closed 7 years ago

apnadkarni commented 7 years ago

asciidoctor-fopub works fine for me as long as I have network connectivity. Offline however, it fails with error messages:

Apr 06, 2017 11:20:53 AM org.apache.fop.cli.InputHandler error 
SEVERE: javax.xml.transform.TransformerException: Had IO Exception with stylesheet file: http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl
Apr 06, 2017 11:20:53 AM org.apache.fop.cli.InputHandler error 
SEVERE: javax.xml.transform.TransformerException: Had IO Exception with stylesheet file: http://docbook.sourceforge.net/release/xsl/current/highlighting/common.xsl

I thought the presence of the catalog.xml file(s) would permit offline operation? And moreover does the failure mean it fetches those stylesheets on every run?

apnadkarni commented 7 years ago

Ok, I think I know what the problem is - it's Windows specific. The build/bin/fopub.bat uses APP_HOME to initialize DEFAULT_JVM_OPTS before APP_HOME is set. Thus xml.catalog.files is incorrectly set. Moving the lines


@rem Add default JVM options here. You can also use JAVA_OPTS and FOPUB_OPTS to pass JVM options to this script. 
set DEFAULT_JVM_OPTS="-Dxml.catalog.files=%APP_HOME%/catalog.xml" 

to be after the line

set APP_HOME=%DIRNAME%..

seems to fix the problem.

I'm unclear where to fix this in the sources.

mojavelinux commented 7 years ago

I think this is as simple as changing the replacement of APP_DIR to %APP_DIR% instead of %APP_HOME%. The %APP_HOME% is calculated later and is thus a different variable. See if #79 fixes your issue. I'm hoping that doesn't break the intention of #34.

apnadkarni commented 7 years ago

That does not fix it for me. At that point the APP_DIR env variable is undefined as well and resolves to an empty string resulting in the same (broken) behaviour as before.

mojavelinux commented 7 years ago

That's actually a different problem. The APP_DIR is supposed to be set by the main fopub script (in this case fopub.bat). We need to do for the Windows batch file what we do for the *nix script.

See https://github.com/asciidoctor/asciidoctor-fopub/blob/master/fopub#L77-L80

mojavelinux commented 7 years ago

See if it works now.

apnadkarni commented 7 years ago

Yes, that seems to work. Thanks.

OT, I'd submitted a pull request to align Windows fopub with Unix. Any idea when that might get looked at ? I know you are hugely busy, just being selfish not wanting to maintain my own fork for that :-)

mojavelinux commented 7 years ago

Merged!

If you are interested, I'd be glad to invite you to be a committer on the project.

apnadkarni commented 7 years ago

Thanks for the merge.

Regarding commit rights, I don't mind if it results in less work for you to adopt these small patches. But not sure I have the skills to contribute, completely lacking Ruby, Java, Javascript and having only a rudimentary knowledge of XML. Perhaps if I do come up with something substantial, I'll ping you.