Using ANT with multiple XSD and single XJB - ant

I have a custom external XJB file that has the schema name within it as follows :
jxb:bindings schemaLocation="completeCheck.xsd" node="/xs:schema"
Just wondering, is there a way to substitute the schema name at runtime within the XJB file using ANT(using ANT XJC) OR have a xjb binding file written such that I do not have to hardcode the schema name in it. Basically, I am trying to see if I can use a single xjb file for multiple XSDs.
Currently, I have the same xjb file all over the place with a different hardcoded schema name referred all over the place in build.xml. Any pointers are highly appreciated. I am using JAXB 2.x

Make a template from your xjb file by replacing the value of your schemaLocation attribute with some sort of marker (e.g. !!!) and save it using some other name/extension. Define a macro with an attribute such as schema-name that will use ant's replace to change the marker in the template file with your schema name and save that as the binding file to be subsequently used by xjc.

Normally, in the latest versions of XJC, you can use schema component designator. More info here :
https://jaxb.java.net/nonav/2.2.1/docs/vendorCustomizations.html#scd and https://jaxb.java.net/guide/Using_SCD_for_customizations.html

Related

How to make a path from a string in starlark?

I'm writing some validation code for a bazel build rule and I need to do some path validation. I need to check that a certain file exists in the same directory as the BUILD file. I notice that there's a context attribute build_file_path which points to the BUILD file. I'd like to extract the parent directory from this.
It looks like I can't create a new path object - I don't see a constructor/initializer. It also seems like Starlark doesn't support os.path like python because imports aren't supported.
What's the canonical way to get the parent directory of a string object representing a path in Starlark?
I can't answer your final question, but hopefully the following will help with the initial problem:
You could use the Label of the target for which this instance of the rule is being built and find its package. This will give you a string representing the parent directory of the BUILD file.
i.e. ctx.label.package
load("#bazel_skylib//lib:paths.bzl", "paths")
paths.dirname(path_str)
See https://github.com/bazelbuild/bazel-skylib/blob/main/docs/paths_doc.md

How to find where is an object declare in GSP

In a gsp file there is line like below
<g:each in="${tools}" var="tool" status="counter">
and when i debug it shows value like below
It's using Grails framework. May I know how can I find where is this ${tools} declared and being called from to this GSP?
Grails uses convention over configuration. So in order to trace back where tool is being set, you have to note the name of the gsp file and the directory in which it is placed.
Ideally if the gsp name is bar.gsp and is placed under foo directory under grails-app/views then the convention is that there could be a FooController.groovy under grails-app/controllers which would have an action called bar(). Most likely the model is set with the variable tools inside the baraction.
This exercise would be a good starting point.
What #dmahapatro suggested is the best approach but if you are still unable to find that tools variable and simply do a project level search in the IDE you are using and find the word tools.
Here are some filters you can apply to fasten your search:
First, search only in the directory grails-app/controllers
Then search in the directory grails-app/directives
Try to search following words: tools, tools:, tools : because it will be rendered as a map.

Grails - how to access properties file from GSP

I need to have access to my properties file from GSP file to get one of it's values.
I tried to find example over the web, but I couldn't.
This is a file which I created and not Grails.
Thanks!
From grails controller and gsp file, you can access your yml file properties using GrailsApplication object:
${grailsApplication.config.get('YOUR_PROPERTY_NAME)}
you can access aaplicationContext from the GSP ... so you can access any configuration property.
Just look at this entry from Mr. Haki:
http://mrhaki.blogspot.com.es/2011/11/grails-goodness-get-grailsapplication.html
If the properties file is under grails-app/i18n/ (it can be your own properties file, doesn't have to be one of the default ones) then you can access property values from the property file in a GSP using the message tag. See http://grails.org/doc/latest/ref/Tags/message.html.
If you are reading simple properties it sounds like what you want is externalized configuration
To use it in a GSP (if you really need to, but not recommended from a GSP):
${Holders.config.myPropertyKey}

Ejb jar for Jboss PER environment

I am trying to read the attributes from a properties file into a field in ejb-jar.xml via ANT.
I have one properties file PER environment which contains an IP address which must be written into ejb-jar.xml when ANT is building the ear.
How would I accomplish that ?
please refer https://ant.apache.org/manual/Tasks/replace.html
check this : if you have someDirectory/cofiguration.properties in which you have IP configuration as per your environments and in that property file ipAddress.key is the key and want to replace with the value of it.
ejbIPAddress will be replaced by ipAddress.key value of someDirectory/cofiguration.properties

How do I find a particular sub directory using Ant and then use it to create a symlink?

I need to create a symlink to a sub-directory using Ant. The issue is that I don't know where the target sub-directory is.
To create a symlink with ant I do this:
<symlink link="${parent.dir}/FOO/linkname" resource="${parent.dir}/BAR/target"/>
But I don't know what BAR is called in advance so I need to do a search for "target" under parent.dir and then pass the one result into the resource.
Is this possible using fileset? Or another way?
It might be possible to use a fileset but that might give you several symlinks or none.
A much better approach is to define the path to BAR in a property. If there is a dynamic part in this path, change the code so that Ant evaluates the dynamic part and everyone else uses Ant's value.
The typical example here is that the path contains a version or timestamp. Define those in your build file so you can use them everywhere. If a Java process needs the values, pass them to the process as a system property (-D...).

Resources