Markdown to HTML from Ant or Commandline - java

I have a build server (running windows) and would like to convert markdown (including tables) to HTML.
I don't want to write software for this but rather use something existing from the Java World.
The whole thing should work from the command line:
Example:
java -jar some.jar -Dinput someMarkdownfile.md -Doutput someOutputfile.html
Is there an elegant way to do something like this?
Update: Java is not a hard "must-be" in my case. I thought that Java is a good option so it would be platform independent.

For a java solution you could use markdownj
The following example uses ivy to retrieve the jar from Maven Central
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="markdownj" default="build">
<target name="resolve">
<ivy:cachepath pathid="build.path">
<dependency org="org.markdownj" name="markdownj" rev="0.3.0-1.0.2b4" conf="default"/>
</ivy:cachepath>
</target>
<target name="build" depends="resolve">
<java classname="com.petebevin.markdown.MarkdownProcessor" classpathref="build.path" input="test.markdown" output="test.html">
</java>
</target>
</project>

I found a command line tool that does just what I want to do:
Multimarkdown can handle tables and converts HTML output like so:
mulimarkdown.exe -o someOutputfile.html someMarkdownfile.md
What is a bit tedious is that I don't have an option to provide a CSS but I can do that manually by stitching together a header the generated content and a footer.

Related

Skip DLL compilation if no changes

I'm attempting to optimize our build procedure for our applications we have here. I'd like to skip the compilation of our backend .dll file should the file timestamp not have change using Netbeans Ant scripts.
I've been using Incremental and fast build using Ant and Advanced Free-form project configuration as a reference point but it seems to require 2 build targets to create the .timestamp comparison in the first link.
Is there a way to circumvent the need for 2 targets and check the timestamp of the .dll file instead? or do I simply need to add another tag inside of my call to make the comparison, or is what I'm trying to do not feasible?
Any help would be greatly appreciated or if better methods of doing this are known I am open to listening to it.
We use Netbeans to compile our projects, and uses Ant by default. I've included a snippit of my build.xml Ant script so far.
Thanks in advance!
<target name="init-skip-dll" description="initializes the skip property for the Ada dll">
<uptodate srcfile="create-ada-dll.timestamp" targetfile="ada-dll.timestamp" property="ada-dll.skip" value="true" />
</target>
<target name="-build-dll" description="builds the Ada dll if needed" depends="init-skip-dll">
<exec executable="gprbuild.exe">
<arg value="-P"/>
<arg file="..\DLL\ifccs_dll.gpr"/>
</exec>
<touch file="create-ada-dll.timestamp"/>
</target>
I don’t use Ant, but the same problem exists with Make; the Ada dependency rules are complex, and best handled by unconditionally letting gprbuild do whatever it needs to to bring the DLL up-to-date. Gprbuild will do nothing besides checking dependencies if the DLL is actually up-to-date.
In Make, this involves a phony target: e.g. for a real target testbed,
testbed: force
gprbuild -p -P testbed
.PHONY: force
or for an already-phony target
all:
gprbuild -p -P build_runtime.gpr
.PHONY: all
By the way, note the -p, which says to create needed directories, e.g. an object directory.

Using changeset number in a java program

I am using Mercurial HG for versioning my projects. To keep my version-number in my build/compiled programs uptodate I am using this approach. I've modified the build.xml to override a predefined target.
<target name="-pre-compile">
<!-- getting the version in a fancy format -->
<exec executable="hg" outputproperty="version.mercurial">
<arg value="parent"/>
<arg value="--template"/>
<arg value="{latesttag}.{rev}-{branch}-{node|short}"/>
</exec>
<echo level="warning">Version ${version.mercurial}</echo>
<manifest file="${manifest.file}" mode="update">
<attribute name="Implementation-Version" value="${version.mercurial}"/>
</manifest>
</target>
** note hg.exe is in my classpath.
To retrieve the version property I use the following code snippet in my mainclass
String version = Main.class.getPackage().getImplementationVersion();
When I build my project and run it with this java -jar myproject.jar the version number is correct and from that point everything is fine.
But when I run it in my IDE the version string ist null, so the manifest file isn't read.
So this makes me thinking if this approach is valid or is there another, even a simpler way to keep the version number uptodate?
EDIT: Is there a more sophisticated way to include the version number into your program?
Consider using the output attribute to Ant's <exec ..> task to write a properties file instead. Then you can use the <properties file="..."> method to read it in Ant, and can load it like a normal properties file when running in your IDE.
Good for you for not using the KeywordsExtension for this. It's a horrible solution in a DVCS world.

Running GWT from Ant buildfile with special arguments?

I would like to run the GWT compiler from my Ant buildfile with the compiler the following flags:
-compileReport
-XsoycDetailed
-extra
-XfragmentCount <x> (where <x> is an integer that I'll determine over time)
I looked into ant-gwt, which seemed pretty stable, however after a thorough inspection of the documentation and code, it doesn't seem like that plugin can handle these GWT compiler options.
Checking out the GWT command-line tools, I see a code snippet for an Ant task that runs a GWT class called com.google.gwt.dev.Compiler from inside a buildfile:
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg value="com.example.foo.Foo"/>
</java>
Is this the correct way to run the GWT compiler from Ant (that ant-gwt probably wraps)? I think the word dev in the package name is throwing me off: is this some smart compiler stub or is it actually the GWT compiler?
If not, then what is the proper way to run GWT from inside of Ant? The only other thing I can think of would be to kick off a Python script from inside the Ant task, and have the Python script call the GWT compiler, but even then, not sure what command-line tool to call from that Python script (maybe webAppCreator?). Thanks in advance.
After downloading GWT from http://code.google.com/p/google-web-toolkit/downloads/list, extract the content from zip folder. Please refer the build scripts "build.xml" provided by GWT team in "sample" folder projects like "Hello" .
or
Example Hello World Ant build.xml
Modify 4th line to add your compiler options - <property name="gwt.args" value="-draftCompile -ea -style pretty -logLevel TRACE -workDir work" />
com.google.gwt.dev.Compiler is the GWT compiler; dev is for developer tools: compiler, DevMode, etc.
BTW, the documentation for the compiler is here.

Using Acceleo 3 with Ant

I'm looking for information on how to perform Acceleo source generation with an Ant script. I've done some Googleing, but I haven't really found any straightforward way to do that. I'm looking first to do it in Eclipse, but a headless (is that the right word?) script would also be nice for semi-automatic builds.
Can anyone offer any help? Or are my expectations of what Acceleo can do unreasonable?
I believe all you need to do is to use a ant task to call your generation class.
The generation class is the one generated along your mtl file that contains an "#main" annotation.
Beware though, the generation will run in standalone mode, so don't use services that rely on eclipse API!
The ant task should look like this:
<java classname="your.generation.class.GenerateJava"
classpathref="your.classpath.defined.in.ant">
<arg value="your/input/model/example.uml"/>
<arg value="your/target/folder" />
</java>
Hope this will help...

Javadoc on Android (Eclipse)

I am trying to generate Javadoc html pages for my Android project in Eclipse. I have tried using the -linkoffline argument, as suggested here, as well as using the -classpath argument pointing to my android.jar file. Neither of these worked, as I still get package android.app does not exist (and other) warnings. I have also tried running the javadoc tool from the command line, rather than using Eclipse.
Ideally I would like to have my own generated pages for my classes, with all android.* and java.* classes linking to the online pages. I am using Mac OS 10.6 with Java version 1.6.0_20.
While trying to resolve a similar issue myself, the two main points I've found have been:
To include the android.jar file you're linking to within the classpath attribute of the javadoc Ant task. That means something like the following:
<javadoc ...
classpath="some/local/library.jar;
C:/Android/platforms/android-8/android.jar;
D:/another/library.jar" ... >
To add a link subitem under javadoc task in order to match the online Android Reference URL with a local copy of Android Reference package-list. That means something like the following:
<javadoc ...>
<link offline="true"
href="http://developer.android.com/reference/"
packagelistloc="C:/Android/docs/reference" />
</javadoc>
This was enough for me in order to show Android links within my project Javadoc.
Have you tried using an ant script for the javadocs? Name it javadoc.xml or something other than build.xml - else eclipse will pick it up as the default build script. Run the ant script either from inside eclipse (RMB on file | Run As | Ant Build), or from the console: ant -f <file-name.xml>.
Mine looks something similar to this:
<project basedir="." default="doc" name="metagloss api docs">
<property
name="android-sdk-docs"
value="/home/blackrax/opt/dev/android-sdk-linux_86/docs/reference"/>
<target name="doc" description="api docs - no piwik" depends="clean, delombok">
<javadoc destdir="docs">
<link offline="true"
href="http://d.android.com/reference"
packagelistLoc="${android-sdk-docs}" />
<fileset dir="src" includes="**/*.java" />
</javadoc>
</target>
<!-- more implementation, any remaining targets -->
</project>

Categories