I'm converting a project from using NAnt to FAKE. The project is using a *.properties file to inform the main build.xml script of the locations of some executables that the build.xml script file will need to execute.
Due to the nature of these executables they are not easily discoverable because installation does not install them in PATH and the user is able to customize the location of where they are installed. Hence the *.properties files for users to set where they are located.
What would be the FAKE equivalent? I thought about having build parameters passed with each invocation of the FAKE build script but this isn't ideal because it requires them to remember what the build parameters are each time they want to run the build script. And having a build parameter be a long string which is the path to an executable is cumbersome to type each time anyway.
Thanks for any help.
As far as I know, FAKE does not have any built-in configuration system, but you can use any of the F# libraries for working with XML to read the configuration file. One nice option would be to use the XML type provider from F# Data.
You'd need to make sure the FSharp.Data package is restored before FAKE is run (in the same way in which you're downloading FAKE). Then you can write config.xml looking like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<temp-folder>C:\temp</temp-folder>
<executable>foo.exe</executable>
</configuration>
If you then add reference to F# Data and open the FSharp.Data namespace:
#r "System.Xml.Linq.dll"
#r "packages/FSharp.Data/bin/FSharp.Data.dll"
open FSharp.Data
You can then use the XML provider. This can actually pick the names of the XML elements and makes them accessible as properties, so you get really nice access to the config:
type Config = XmlProvider<"config.xml"> // Assuming this is in the same folder
let config = Config.GetSample()
config.Executable
config.TempFolder
Put the values for these custom paths in a .fsx file
Include this .fsx file in your main build script
Related
I'm getting started with FunScript with a working example. Using Nuget to add the needed libraries, it works well.
In watching a 2013 video on channel9, they are making use of TypeScript.Api<...> to load types from typescript definition files.
I'm however unable to find this type provider anywhere.
Where is it located?
I realized that a good number of the type definitions have been compiled into libraries and available on nuget but I can't really use this since some of the code will be local typescript definition files.
The questions therefore are
Where is the TypeScript.Api<...> type provider?
If it is not available or the best way to use typescript definition, what other options exists.
As Thomas said, the type provider was removed mainly because it couldn't generate generic types, but the idea is to bring it back at some point.
For the moment, though not ideal, you can generate your own bindings following these steps.
Download or clone Funscript repository
git clone https://github.com/ZachBray/FunScript
Build the project
cd FunScript
build.cmd
This needs to be improved but for now you need to zip the .d.ts files you want to convert and then:
cd build\TypeScript
bin\FunScript.TypeScript.exe C:\Path\to\typedefinitions.zip
cd Output
Please note the first time you build the definitions it may take several minutes. Once it's done in the output folder you'll find the compiled .dll libraries with the bindings.
Also, while you're at it. It's better if you use the FunScript version you just build into build\main\bin, as it will probably be more updated than the nuget package.
Good luck and have fun(script)!
There were a bunch of changes in FunScript, so the TypeScript.Api<...> type provider is no longer the recommended way of calling JavaScript libraries from FunScript.
Instead, the bindings for JavaScript libraries are pre-generated and you can find them as packages on NuGet, if you search for the FunScript tag (NuGet search is not very good, so you may need to go through a number of pages to find the one you need...).
If you want to use a local TypeScript definition, then you'll need to run the command line tool to generate the bindings. The F# Atom plugin does this in the build script, so looking there is a good place to start. It has a local copy of various TypeScript bindings in the typings folder (together with the FunScript binaries needed to process them).
I liked the type provider approach much better, but sadly, type providers are somewhat restricted in what kind of types they can provide, so it wasn't all that powerful...
Is there an easy way for me to get the path of the executing .fsx file using FAKE? Powershell and (psake) by nature of its use and MSBUILD provide this functionality but as FAKE/F# a noob it is not immediately apparent how to do this.
Try __SOURCE_DIRECTORY__ or
__SOURCE_FILE__.
It should work like in every other F# script file see F# for scripting: location of script file.
I`m using Apache Tika 1.4 to extract content from my documents. But it also comes with org.bouncycastle.* classes, and I use another version of bouncycastle which is conflicting with the Tika packages.
If the Tika was using the bouncycastle (bcprov) jar, I could exclude that using exclusion tag from Maven, but the TikaApp has copied the org.bouncycastle classes into it, so, I cannot exclude them.
There`s some way to remove this package without recompiling or branching Apache Tika and set to use another JAR to this specified package or something like that?
Thanks
Your problem is that you're using completely the wrong packaging of Tika!
The tika-app jar is a standalone, runnable jar, containing all of the Tika code + all dependencies required to let it run. It's intended to be used from the command line, standalone, to allow non-Java users to call Tika, and to allow for easy testing.
If you're writing your own Java application, which it sounds like you are, you will want to depend on the tika-core artifact as a minimum. That contains all the interfaces, the mime detection, service loaders etc. You'll then almost certainly also want to depend on tika-parsers , which provides all the code to do the actual parsing of the file formats, along with pulling in their required dependencies. This gives you the full control you seem to want.
Finally, there's also an OSGi bundle available, for those who prefer the control and classloading that OSGi offers, that's in the tika-bundle artifact. There's also a CXF powered JAX-RS version, which offers Tika's services over a RESTful interface, that comes in the tika-server artifact.
I need the JRE to use translated versions of a JRE resource that is available only in English.
As per the ResourceBundle.java doc, it's easy: add localized resources with the right locale suffix. For example, the standard
XMLSchemaMessages.properties
would become a translated version:
XMLSchemaMessages_FR.properties
And so on.
EDIT: this particular file lives in :
com\sun\org\apache\xerces\internal\impl\msg\XMLSchemaMessages.properties
My question is: how do I make those extra resources visible to the JRE ?
Thanks in advance, for any help.
-- cheers
Assuming that Xerces uses ResourceBundle to get the messages, you should put a new file in
com\sun\org\apache\xerces\internal\impl\msg\XMLSchemaMessages<locale>.properties
where locale is a correct identifier for the locale you need.
Then pinpoint the exact location where the XMLSchemaMessages resource bundle is loaded, and set a breakpoint so you single step through the ResourceBundle loading procedure in the JRE (a JDK is recommended here, so you have source for the runtime) and you can see what is being searched for.
Note: You are dealing with a vendor specific XML Parser here meaning this will be Oracle specific and may even only work on some Java versions. Considered bringing in your own validating XML Parser and localize it instead?
The above answers took me a little while to work out.
Just to make it easier for others, here's my summary of how to get Locale specific error messages to appear if you try parsing an XML document using XML schema with Java's internal Xerces parser:
Find an appropriate properties file in the format
XMLSchemaMessages_<lower_case_language_code>.properties
For Italian I found XMLSchemaMessages_it.properties on the following site (which might be an old version, but it worked for me)
http://grepcode.com/file/repo1.maven.org/maven2/com.sun.xml.parsers/jaxp-ri/1.4.5/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_it.properties
I then created a directory structure in my temp directory to hold the new file
com\sun\org\apache\xerces\internal\impl\msg
Since jar files and zip files share the same format (and I'm lazy and today I was using Windows), I then zipped the above com directory, creating a file called com.zip. I then changed the name of the file
rename com.zip to XMLSchemaMessages_Locale.jar
and then moved the new jar file to
C:\Program Files\Java\jdk1.7.0_04\jre\lib\ext
Of course the above path depends on your platform and specific version of Java (I was using Windows 7).
Instead of zipping, if you have JDK you could easily build the jar file using the command-line jar command, from Unix, Linux or Windows.
I am using Apache Ant to generate Javadoc for my program which has many projects (or modules). However, I want to generate Javadoc for Interfaces only, and I do not know how to check if a file is a class or interface in Ant. Someone suggested me that I should use <fileset> and specify a list of files to exclude or include. However, there are hundreds of files in my program and specifying a list of class files to exclude is impossible.
Does anyone have some ideas, please?
I don't believe this is possible unless you write your own custom ant-task, (which wouldn't be that hard actually) and reference that in your Ant-script.
Another, (much uglier) way would be to generate the complete java-doc and remove non-interface files. These could for instance be identified by looking at the allclasses-frame.html:
ComponentView
<I>Composite</I>
where you have both the type (in the title=...) and file (href=...) available.
Have you considered writing your own doclet? Instead of trying to get ant to do the work, create a doclet that knows how to discard every non-interface. Then, using the javadoc task in ant is simple.
Hope that helps.