Hi again Dirk,
This is excellent, thanks for helping me along here.
As for maven project setup, I am pretty certain that one of the shelf-standard archetypes would do just fine -- I just don't have enough experience in Java development to be able to make educated guess which one(s) would be best. Maybe I'll make some experiments. Of course in the scenario you are suggesting, any future users of my project would not have to do that for themselves, so stumbling forward may get me to the goal as quickly as "doing it right".
If/as I grope my way, I'll try to keep notes...
Cheers, Wendell
On Sun, Feb 8, 2015 at 5:34 AM, Dirk Kirsten dk@basex.org wrote:
Hello Wendell,
I guess you are correct and quite likely we should ship the archetype generators somehow, but I am personally am no Maven expert. Personally (and I think this is what everyone using Maven+BaseX is currently doing) I simply copy my default pom.xml to a new project.
Regarding your questions
- This is quite simple and the reason why Maven is quite nice. It is in fact as simple as including
<dependency> <groupId>net.sf.saxon</groupId> <artifactId>Saxon-HE</artifactId> <version>9.6.0-4</version> </dependency>
into your pom.xml (of course you can change the Saxon version number)
The BaseX location is configurable in the jetty configuration in this setup. You can do this either in the jetty.xml file using
<Set name="host"><SystemProperty name="org.basex.dbpath" default="/your/db/path"/></Set>
or in the web.xml using
<context-param> <param-name>org.basex.dbpath</param-name> <param-value>your/db/path</param-value> </context-param>
The default is to use the data/ directory of the directory where the pom.xml file is located.
Happy to help and to answer more questions. Maybe we can actually use this and write down some Maven+BaseX Getting started guide in our documentation.
Cheers, Dirk On 02/07/2015 08:47 PM, Wendell Piez wrote:
Dear Dirk,
Thanks for all the input and advice! It is a great deal to digest, but I am sure I will figure it out.
My questions about which archetype to use stem from the fact that every How-to-start-with-Maven tutorial tells me to choose an archetype, and I simply don't know enough to guess how I would skip this step or follow it.
It is completely possible I have just chased myself into a rathole with this (in which case forgive me). I am sure the lightbulb will go on if I just persist.
However, your advice does raise a couple of other questions:
- My projects all require SaxonHE. BaseX is very good about using
SaxonHE if I put a copy of the Saxon .jar into BaseX itself -- as it will be presumably if I simply put saxon9he.jar on the classpath.
What do I do to get SaxonHE into BaseX under Maven? I can list it in the pom.xml - is it as simple as this? If this is the approach, then I guess I don't have to mess with its (or anyone's) .jar files? (which is the point of the exercise? :-)
- Where does BaseX store its databases when I run it under Maven?
I'm sure I'll have more questions. Thanks again.
Cheers, Wendell
On Thu, Feb 5, 2015 at 5:49 AM, Dirk Kirsten dk@basex.org wrote:
Hi Wendell,
I have attached a sample pom.xml file. This should allow you to cover your two main use cases (at least, that is what I see here): 1) Starting a Jetty server, so you can run RestXQ and 2) Running BaseX standalone so you can e.g. run a script
Using the exec maven plugin you can run any java program from Maven. So this part
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <configuration> <mainClass>org.basex.BaseX</mainClass> <arguments> <argument>-q 4+2</argument> </arguments> </configuration> </plugin>
simply output 6 if run via
mvn exec:java
You can also override the arguments via command line like so
mvn exec:java -Dexec.args="-q 7+1"
Starting jetty can be done as usual running mvn jetty:run
I would recommend you have such a pom.xml file in each of your project directories. This allows you e.g. to use different BaseX versions for your different projects (your latest project might want to use our 8.0 snapshot, your potential high-security banking project in production most likely should not run unstable software) . In the pom.files you can also incorporate different JVM parameters (as I suggested before using export BASEX_JVM=-p=/my/restxq/directory && basexhttp, but this time using maven).
If you use Maven in general, it does not mean you have to compile anything at all. On the contrary, it allows programmers to fetch already compiled versions and fit them into their program.
I should not that you could also use a more complex Maven approach and use a parent pom.xml file and subprojects (we do this in the core BaseX files, as basex-core and basex-api are actually different projects, bundled together in a parent project). This is all Maven specific - Maven is a build system, sou basically you can do almost anything. Question is, how much you want to dive into Maven configuration or if it is good enough for you for now to simple have something you can share and others can check out easily.
If you have a project with such an pom.xml file and you share it e.g. via github, it should be enough for your users to check out the repository and run e.g. mvn jetty:run. Of course, you can then also write maven goals for repeating task, e.g. optimizing the database. So you than would have to write a simple mvn exec:optimize, which would call BaseX with the require parameters to do your optimization.
Of course, you could also do all this completely without Maven. You could also write custom shell scripts and automatically download BaseX, etc. pp. Essentially, Maven is just a tool which saves you same work and simplifies dependency-management.
Regarding the maven archetypes, I don't think we use them at all. I don't have much knowledge about them (also about Maven, I just use it as a tool, but I am always amazed how complex it is), but I guess we would have to write same sample archetypes for them - Which we didn't, as far as I know.
And sorry about being pedantic on using the mailing list. But I truly think many people stumble onto the problems faced with project setup and Maven usage, so I think these people can benefit.
I hope this helps.
Cheers Dirk
On 02/04/2015 06:52 PM, Wendell Piez wrote:
Hi again Christian and Dirk:
I should also mention - another goal for me is that things be self-contained enough that I can share the whole thing on github, like here:
https://github.com/wendellpiez/Luminescent
Of course this is a huge mess since it has been architected by accretion, but the idea is that I (or anyone) would be able to download the stuff and start playing as quickly as possible. Mind you, this is meant as a long-term backup and project management strategy for me as much as anything -- since the point is less the processing than the results. However, I am working on the assumption that any improvement for anyone is an improvement for myself.
I don't need to deliver BaseX to my user, but I would like to give users (my future self) an easy way to run BaseX with the necessary settings and resources available, to get my XSLT/XQuery-driven functionality onto their systems and screens as speedily as possible.
Thanks again, Wendell
On Wed, Feb 4, 2015 at 12:36 PM, Wendell Piez wapiez@wendellpiez.com wrote:
Dear Christian,
Absolutely, the BaseX wiki page helps.
The one thing I am stuck on is the selection of the Maven archetype. I vaguely get that it will generate a POM (an editable and extensible configuration file) and a subdirectory structure, wherein I can develop my BaseX application.
But *which* Maven archetype of the many available is the appropriate one for my needs ... I cannot pretend to know.
I do not, however, wish to compile BaseX locally -- or at least, that is not a goal. (As a means to an end I can be convinced it'd be okay.) I won't be extending or manipulating BaseX itself or writing any Java; all my code is XQuery and XSLT.
(Indeed, minimizing a dependency on BaseX -- maintaining the capability to use the same libraries in another framework or environment -- such as Apache Cocoon, XProc pipelines, eXist, MarkLogic, what have you -- is a strategic goal for me. BaseX's support of standards along with its ease of use is thus very important to me.)
Currently, I have everything running well from a single BaseX installation, without Maven (tweaking the RESTXQ directory setting to point it to my project). However, I have more than one project using BaseX, and wish to keep them independent.
I am considering Maven as a good way for me to set up and configure BaseX, with minimal overhead, in a portable and project-specific way, not to customize or compile it, but just to run it ... call a script to update a database, then call another to start the http server ...
But my goal would also be accomplished if I knew how to do something comparatively simple (or so I would think): start up BaseX to run with a project-specific runtime setting.
So Dirk suggests a script that runs
export BASEX_JVM=-p=/my/restxq/directory && basexhttp
which I could totally do, as soon as I upgrade BaseX to v8.0.
Or, if Maven is a simple, clean, and lightweight way to do it, I'm not opposed. It's how that would or could work (in specific) for me, that has me stumped. I can type mvn generate:archetype and then fake it, and I can edit the POM and sniff around in the directory structure ... feeling increasingly like a blind monkey, if you get my drift.
But Dirk urged that I help support other newbies by asking these questions in public, albeit they are slightly OT (Maven, Linux scripting), since they have to do with setting up and running BaseX ...
So what's the appropriate maven archetype for me given I wish to run BaseX but not compile any Java, per se?
Thanks! Wendell
On Wed, Feb 4, 2015 at 2:58 AM, Christian Grün christian.gruen@gmail.com wrote:
Hi Wendell,
> For all us Maven innoscenti, I wonder if you could recommend which > maven archetype one should use when getting started running BaseX? > (Any guidance or resource appreciated.)
I would like to redirect you to our Wiki documentation [1]. Does it help, or do you think some essential information is missing here (which we could/should add)?
It's absolutely ok to run BaseX without Maven. The easiest thing is to use the zip file and start "basexhttp" (see e.g. [2] for more information).
Best, Christian
[1] http://docs.basex.org/wiki/Maven [2] http://docs.basex.org/wiki/Startup
On Tue, Feb 3, 2015 at 10:47 PM, Wendell Piez wapiez@wendellpiez.com wrote: > Dear Christian and Dirk, > > > I am guessing something with 'webapp' but I have no idea, I don't even > know what "webapp" means in this context (although I think it may be > what I want). > > Cordially, Wendell > > > > On Mon, Jan 19, 2015 at 1:55 AM, Christian Grün > christian.gruen@gmail.com wrote: >> Hi Wendell, hi Dirk, >> >> I'd like to jump in: Depending on the use case, I think I can >> absolutely make sense to work with the snapshot. The more feedback we >> get on potential errors, the more we'll be forced to keep it as stable >> as possible, and write more test cases ensuring it. Moreover, >> obviously, you'll always have access to the latest features. >> >> This is how your maven snippet needs to look like: >> >> <dependency> >> <groupId>org.basex</groupId> >> <artifactId>basex-api</artifactId> >> <version>8.0-SNAPSHOT</version> >> </dependency> >> >> Hope this helps, >> Christian >> >> >> On Sun, Jan 18, 2015 at 10:52 PM, Dirk Kirsten dk@basex.org wrote: >>> Hi Wendell, >>> >>> no, actually this is even bad practice. You should always explicitly set the required version in your pomfile. Otherwise, your application always uses the latest version and isn't realiably testable. The following should fetch BaseX 7.9, the latest stable release: >>> >>> <dependency> >>> <groupId>org.basex</groupId> >>> <artifactId>basex-api</artifactId> >>> <version>7.9</version> >>> </dependency> >>> >>> >>> >>> >>> For Saxon, if you have the jar file in your lib you should be good to go (are you sure however that you included it via maven). Should be somethin like that as dependency: >>> >>> >>> <dependency> >>> <groupId>net.sf.saxon</groupId> >>> <artifactId>Saxon-HE</artifactId> >>> <version>SAXON-VERSION-YOU-LIKE</version> >>> </dependency> >>> >>> >>> Cheers, >>> Dirk >>> >>> >>> On 01/18/2015 10:29 PM, Wendell Piez wrote: >>>> BaseX friends, >>>> >>>> If I run BaseX from Maven, do I always get to use the latest BaseX? >>>> >>>> Do I have to do anything special to set up BaseX in Maven to use >>>> SaxonHE instead of Xalan for xslt:transform()? (I have Saxon9he.jar in >>>> my BaseX lib.) >>>> >>>> Thanks! Wendell >>>> >>>> >>> >>> -- >>> Dirk Kirsten, BaseX GmbH, http://basexgmbh.de >>> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >>> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >>> | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle >>> `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22 >>> > > > > -- > Wendell Piez | http://www.wendellpiez.com > XML | XSLT | electronic publishing > Eat Your Vegetables > _____oo_________o_o___ooooo____ooooooo_^
-- Wendell Piez | http://www.wendellpiez.com XML | XSLT | electronic publishing Eat Your Vegetables _____oo_________o_o___ooooo____ooooooo_^
-- Dirk Kirsten, BaseX GmbH, http://basexgmbh.de |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
-- Dirk Kirsten, BaseX GmbH, http://basexgmbh.de |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22