How to get the version of a module [duplicate] - version

I want to do something like this:
die "Fatal error: application version $MY-APPLICATION-VERSION"
Since a Perl6 module cannot assume the relative locations of files it was packaged with (for instance installed modules are all put into a flat directory structure) I can't just do $?FILE.IO.add("../META6.json").slurp. Is there a way to get the version declared in META6.json in a Perl6 app/module that may or may not be installed?

As of rakudo v2019.03 modules may access the Distribution object used to load it via $?DISTRIBUTION. This allows the following:
unit module My::Module;
BEGIN my $VERSION = $?DISTRIBUTION.meta<version>;
use My::SubModule:ver($VERSION); # ensure we only ever use the version included in this distribution
die "Fatal error: application version $VERSION"

Related

hugo builds with read-only source-tree

We would like to integrate hugo for documentation generation in our automake project.
The problem i'm facing is, that I would like to support
out-of-tree builds
builds from read-only source trees (which is related to out-of-tree builds)
out-of-tree builds kind of work with:
hugo --source $(srcdir) --destination $(abs_builddir)
However, when my source-tree is read-only (e.g. as tested by make distcheck), this fails with:
$ make
hugo --source ../../../hugo --destination "<<SRCDIR>>/project-0.1/_build/sub/hugo"
Error: add site dependencies: create deps: failed to create file caches from configuration: mkdir <<SRCDIR>>/project-0.1/hugo/resources: permission denied
Total in 1 ms
make: *** [Makefile:555: all] Error 255
Obviously, hugo tries to create it's "file caches" as a resources/ directory in the (read-only) <<SRCDIR>>.
How can I tell hugo to creat this "file caches" directory in an alternative (writeable) place?
I tried setting --cacheDir (to $(abs_builddir), but this didn't change anything.
apparently there's a resourceDir config-file option, but afaict that is not available via the cmdline (and I don't know whether it would actually help).

Redefining a Deleted Package (Common Lisp)

I’m using delete-package as a simple way to unintern a lot of old (user specified) variable names, before loading a project back in following certain edits to the package files. (Otherwise, new values can get pushed onto the old values for those variable names defined by the end-user.) But SBCL complains when I try to reload after the deletion.
After one-time loading an init.lisp file which sets up Quicklisp, ASDF, and installs some Quicklisp libraries, I then load the project with (progn (asdf:load-system “my-project”) (in-package :my-package)), where the project definition my-project.asd file contains
(when (find-package :my-package)
(delete-package :my-package))
(defpackage :my-package
(:use :cl))
(asdf:defsystem "my-project"
…)
This all works fine on the first load, but stumbles on the second load of the project, because
*PACKAGE* can't be a deleted package:
It has been reset to #<PACKAGE "COMMON-LISP-USER">.
Where is the error coming from? Can it be fixed, retaining the same functionality?
Create a separate package to hold the user-defined symbols, say (defpackage :us) in addition to the working package. (:use :cl) is not required since the package contains only data. Install the user symbols using (in-package :us) when loading the user files, intern into :us programmatically, or direct reference with the package prefix. Access the symbols with the package prefix. The (delete-package :us) should then work.
Fundamentally SBCL can delete and recreate packages with the same name. The error message indicates that the current package (*PACKAGE*) has been deleted. Try to assure that the current package is a different package, e.g. CL-USER, when deleting your package.

How to run Apache CXF wadl2java with JDK 12?

The following command used to work flawlessly:
C:\tools\apache-cxf-3.3.1\bin\wsdl2java -client -d generated foo.wsdl
It no longer works with the latest version of JDK - 12. I have downloaded the latest version of Apache CXF, and still get the same error:
-Djava.endorsed.dirs=C:\tools\apache-cxf-3.3.1\bin\..\lib\endorsed is not supported. Endorsed standards and standalone APIs
in modular form will be supported via the concept of upgradeable modules.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Could anyone offer a tip on how to remedy this?
I got the Apache CXF 3.3.1 wsdl2java utility to work with the latest OpenJDK 11 by doing 4 things:
Pull down this jar and place it into the {CXF_HOME}/lib directory: https://mvnrepository.com/artifact/javax.jws/jsr181-api/1.0-MR1
Pull down this jar and also place it in the {CXF_HOME}/lib directory: https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api/2.3.1
In my case, since I'm running on a Mac, I vi'd the wsdl2java script and made sure these two jars are explicitly being set on the CXF classpath, by doing the following declaration within the script right before the execution of the java command:cxf_classpath=${cxf_classpath}:../lib/jaxws-api-2.3.1.jar:../lib/jsr181-api-1.0-MR1.jar
Lastly, I removed the '-Djava.endorsed.dirs="${cxf_home}/lib/endorsed"' parameter from the java command at the end of the script, since newer JDKs no longer support this argument, so my command now looks like this:$JAVA_HOME/bin/java -Xmx${JAVA_MAX_MEM} -cp "${cxf_classpath}" -Djava.util.logging.config.file=$log_config org.apache.cxf.tools.wsdlto.WSDLToJava "$#"
Now, using OpenJDK11, I'm able to point to an external WSDL file and successfully generate the client code I need to consume this SOAP service with the following command:
./wsdl2java -client -d src https://somewhere.com/service\?wsdl
Whether or not this all works yet is TBD in terms of being able to call and consume the SOAP service I'm coding against, but I've at least now overcome the Java9+ support issue with this tool specific to generating client code from a WSDL.
If your needs are different, I would at least remove the '-Djava.endorsed.dirs="${cxf_home}/lib/endorsed"' JVM parameter and start calling the wsd2java command with the parameters you need set and just start iteratively adding back in the missing libs it starts throwing java.lang.NoClassDefFoundError errors for.
Their FAQ specifically says starting in 3.3.x, Java 9+ will be supported but something clearly dropped the ball between the no-longer-supported hardcoded JVM arguments still being passed in the utility and the missing libraries to support the newer JDKs where these legacy libs have been removed.
Hope this helps someone out there unfortunate enough to ALSO still be programming against SOAP endpoints but trying to at least keep the client-side code you're writing up to date and taking advantage of the newer features of the modern JDK.

Distributing jar containing a library path pointer

I am trying to connect to a MS SQL database using integratedSecurity.
If you do not define a java.library.path to sqljdbc_auth.dll, you will get a: WARNING: Failed to load the sqljdbc_auth.dll cause : no sqljdbc_auth in java.library.path
I have tried the standard solution, which is to define a library path: -Djava.library.path=
This works insofar as I can define the library path in Netbeans (project>properties>run>VMOptions) and can access the database when I run from netbeans.
However, I would like to be able to connect to the database outside of Netbeans as well. The aim is to build an executable jar that can be used from different workstations, pointing to a single instance of the DLL on a shared disk.
However when I build and try to execute the jar, it fails.
How do I get the java.library.path pointer to remain the same in the jar as it is in Netbeans (or otherwise enable the jar to use integratedSecurity to connect to the database)?

How do I compile/build against Ocamlodbc

I've installed Ocamlodbc using opam install odbc, but I can't work out how to build an app that uses it with ocamlbuild. The examples that come with the source don't build either.
If I put
#require "odbc";;
into my .ocamlinit, I can open Odbc_unixodbc;; in utop, but any reference to functions in that module result in a "Reference to undefined global 'Odbc_unixodbc'" error.
The following snippet also fails with an error about no implementation for "Odbc_unixodbc"
open Odbc_unixodbc
let () = ignore (Odbc_unixodbc.connect "DSN" "UID" "PWD")
Trying
open Odbc
fails with "Unbound module Odbc"
I'm building the code with
ocamlbuild -pkg odbc test.native
The generated documentation for the package seem to suggest I should be opening the "Ocamlodbc" module, but that also results in an "Unbound module" error.
TL;DR
ocamlbuild -use-ocamlfind -pkg odbc test.native
Description
-use-ocamlfind tells ocamlbuild to use ocamlfind system to find libraries on your system. Otherwise, without this flag, you need to provide flags with concrete locations and also take care of the package dependencies. So, it is a good idea to always use ocamlfind.
If this command still doesn't work for you, then make sure, that you chose the right package name. You can use ocamlfind list to look at the set of all packages available on your system.
Further reading
While the above is ok for small programs, I would suggest to use OASIS system to handle all the flags for you.
You can start from this example, adapting dependency list to your neeeds.

Resources