How to build guice-3.0-no_aop.jar from guice source - build-process

Currently in our Android project, we're linking against guice-3.0-no_aop.jar for Guice. I need to do some timing measurement around injection, so I've check out the source code of Guice (git clone https://code.google.com/p/google-guice/), but don't know how to make the needed file. I've tried ant build with different options listed in build.xml (e.g. 'ant jar' or 'ant dist') but none of these produce the file.
So could anyone tell me how to build this jar from source?

From google-guice groups:
If you want to use Ant:
ant no_aop<br>
cd build/no_aop<br>
ant jar<br>
cd ../..
and the no_aop flavour jar can be found under:
build/no_aop/build/dist/guice-snapshot.jar
ie. the tree under "build/no_aop" is just like the original tree, but has been 'munged' to remove AOP, so it still uses the original filenames for the binaries
If you want to use Maven:
mvn package
and the no_aop flavour jar can be found under:
core/target/guice-<version>-no_aop.jar
the difference with Maven is that the 'munging' is done as part of the main build, and the "no_aop" flavour jar is attached alongside the original jar

Related

Where do I find JavaFX ant tasks in Java 11?

VSCode, Java 11 JavaFX 18.0.2
I am trying to package my code up for distribution as a desktop app. In my case I want a fully self-contained app because of my target user's profile.
I have been through Jenkov add the Oracle docs here and here which suggest I need ant-javafx.jar. That jar file seems to have been dropped from the standard Java SDK some time around Java 7 and put into the regular JavaFX install lib folder.
It's not there in the build I have.
JavaFX seems to have gone to openjfx.io and nowhere in there can I see support for the ant packaging jar. In fact I see openjfx as a retrograde step as they are increasingly forcing everyone into paid plans (try going round and round the loop of downloading anything that doesn't require an LTS payment).
I have a suspicion that there is some silent assumption that everyone will use something from maven or gradle, and maybe the packaging tools are buried away in one of those build tools. For historical reasons I don't use either and it should be possible to do this packaging without one of them.
So where do I get the JavaFX Ant build tasks from without having to pay someone?
I have found that the following works as an alternative with Java 19 and OpenJFX 19. I use the maven-dependency-plugin to copy all the dependency jars (excluding JavaFX, which I use as modules from a "full" JDK [one that includes JavaFX)] into the target/lib directory.
#!/bin/bash
set -o errexit
set -o noclobber
set -o xtrace
# find dependency modules of required modules
DEP_MODS=$(jdeps -quiet --class-path "target/lib/*" --add-modules java.base,java.logging,java.sql,javafx.controls,javafx.fxml --multi-release base --ignore-missing-deps --print-module-deps target/myapp-4.0-beta.jar)
# create a modular runtime image
jlink --compress=1 --no-header-files --no-man-pages --add-modules "java.logging,java.sql,javafx.controls,javafx.fxml,$DEP_MODS" --output target/myapp-4.0-beta
# Example of running it out of the runtime image
# TEST target/myapp-4.0-beta/bin/java -cp "../../myapp-4.0-beta.jar:../../lib/*" org.myapp.App
# symlink to the artifact jar from the lib directory
$(cd target/lib && ln -s ../myapp-4.0-beta.jar)
# use the lib directory and modular runtime image as input to jpackage
jpackage --input target/lib --runtime-image target/myapp-4.0-beta --main-jar myapp-4.0-beta.jar --main-class org.myapp.App --type app-image --app-version 4.0 --name app --dest target/dist/bundle --mac-entitlements src/dist/mac/entitlements.plist

Error: JavaFX runtime components are missing, (Permanent Solution)

I know you can solve this by adding
--module-path "pathToLib" --add-modules javafx.controls,javafx.fxml,javafx.graphics when running the jar file in command line.
But my question is, Is there no permanent solution to solve this error in system settings or configurations and be able to run a jar file as normal as java -jar myfile.jar rather than every time I am suppose to add the module java --module-path "C:\Users\..\Downloads\javafx-sdk-17.0.2\lib" --add-modules javafx.controls,javafx.fxml,javafx.graphics -jar myfile.jar
Also I know you can make a script for this operation for every jar file, but I was thinking of something like system settings or configuration that will be applicable for all jar file with javafx, and be able to run the jar file as normal as java -jar myFile.jar
I am using Ant as a build tool.
Recommended Alternatives
See the packaging resources of the JavaFX tag for recommended alternate solutions to a jar distribution: jlink, jpackage, or native image.
Using JRE's that include JavaFX
Pre-installed JREs that include JavaFX, such as some Bellsoft, Zulu, and Corretto distributions, will execute JavaFX apps without additional module specifiers because they include the JavaFX modules in the base module setup for their distributions.
Note, you must use the correct versions of the JDKs if you want a JDK which includes JavaFX (not all JDKs include JavaFX):
for BellSoft, download and install the "Full JDK", not the "Standard JDK".
for Zulu, download and install the package type "JDK FX", not "JDK".
You can also create your own JRE distribution that includes JavaFX modules using jlink (which is actually simpler to do than it may sound).
Using ant to build a single JAR containing App and JavaFX components
But I still hope that there might be a solution for the above while working with ANT as building tool for JavaFX.
There is some info on building modular JavaFX apps with ant in this answer:
bad name in value for --add-modules when trying to compile through ant
It probably isn’t everything you are looking for though.
To create a single executable jar using ant, you could try emulating the output of this maven JavaFX shade on classpath answer:
Maven Shade JavaFX runtime components are missing
But use ant tasks to build the massive shaded jar instead of maven. I don’t have explicit instructions for that, you would need to work out to accomplish that non-trivial task yourself.
The created jar will include a launcher class, your application code, dependent library code, JavaFX java, and native code. The jar will run on any modern JRE as long as you have included the native code for the relevant platform. The jar will run in the unsupported classpath configuration.
Zip Distributions
Or (better) create a zip distribution:
only put your own code in your app jar.
place the dependent libraries and JavaFX modules in a lib directory.
Create a script that invokes Java with your jar file running with the modules in the lib directory added.
Make your app modular if possible:
Define a module-info.java.
This step isn’t strictly necessary or reasonably possible for some apps.
Use ant to place everything in a zip file for distribution.
Include a jlink generated JRE in the zip if you want.
Note: the maven JavaFX plugin, once properly configured, can accomplish most of these tasks with a single command:
mvn javafx:jlink
Additional info
See the eden guide for resolving JavaFX runtime components.
Add a module-info.java file under your java/ folder and populate it with the following content:
module module_name {
requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires java.base;
requires java.desktop;
opens com.example.matformater to javafx.graphics;
opens com.example.matformater.controller to javafx.fxml;}

How to build a selection of Qt5 submodules from source?

The Qt download page (http://download.qt.io/official_releases/qt/5.12/5.12.2/) offers multiple source archives that can be used to build Qt5 from source. One contains all sources, which I managed to build successfully, but it takes rather long and contains a lot of stuff that I do not use.
They also offer submodule source packages that can be used to only build a subset of what Qt offers. Howerver I could not find a manual on how to properly build these. I need the QtBase and the QtXmlPatterns packages. I manged to build the QtBase package on its own, but I would like to know how to build multiple of the submodules.
The QtXmlPatterns package can not be build on its own, so I tried to simply copy the sources from the QtXmlPatterns submodule into the QtBase submodule. But that gives me errors when I execute the configure step.
So what is the correct procedure for combining multiple of the submodule source packages into one setup that can be build?
Thank you for your time.
Edit:
Not sure if it is relevant, but I am building Qt5.12.2 on Windows with Visual Studio 2019.
The build flow is a bit different from building the full source package.
configure and build qtbase stand-alone as you have already done it. Use a PREFIX so that you can call make install and install the build results to some location in your file system.
you may want to add the resulting bin folder to your PATH environment variable
extract the other submodule you want to build into a separate folder
run qmake, make and make install on your submodule as if it was a "normal" Qt project. This will install the submodule to the PREFIX location of qtbase.

Qt program deployment

In one of my programs I use QWebView to load and print reports made from HTML documents. So while deployment I copy these libraries, in additional to all other relevant Qt libraries:
Qt5WebKit.dll
Qt5WebKitWidgets.dll
Qt5PrintSupport.dll
plugins/printsupport/windowsprintersupport.dll
After testing on destination machine I've found that printing doesn't work. Thanks for Dependency Walker I've get all the missed libraries. Here is the list:
Qt5Multimedia.dll
Qt5Positioning.dll
Qt5MultimediaWidgets.dll
Qt5Qml.dll
Qt5Quick.dll
Qt5Sensors.dll
Qt5OpenGL.dll
Ok, I can understand why it wants Qt5Multimedia.dll. Browser can play sound etc. But QML! Why I need all these libraries related to QML?? I don't use neither OpenGL nor sensors or positioning. So it's just unnecessary in my case.
And so my question - is there way to deploy only libraries I need in actual fact? And get the program work of course.
I would suggest you to use windeployqt.exe.
From the docs:
The Windows deployment tool can be found in QTDIR/bin/windeployqt. It
is designed to automate the process of creating a deployable folder
that contains all libraries, QML imports, plugins, translations that
are required to run the application from that folder. This is used to
create the sandbox for Windows Runtime or an installation tree for
Windows desktop applications that can be easily bundled by an
installer.
This is how I do:
cd [my program dir]
mkdir RELEASE
cd RELEASE
copy ..\"progname.exe" .
set QTDIR=C:\Qt\Qt5.4.1\5.4\mingw491_32\bin
call %QTDIR%\qtenv2.bat
windeployqt --force "progname.exe"
You could adapt that for your need by changing [my program dir] to your application's folder (containing the .exe file), QTDIR to your Qt MinGW folder (that's what I use) and progname.exe with the name of your executable file.
It will create a release directory with your executable and the needed Qt libraries (.dll's, etc).

How to build into Desktop Java?

So I know you can use ant and mvn to test the project, but I was wondering if there was a way to deploy the project directly as a executable jar or otherwise compile it into a format that can be directly ran? Thanks!
if you are serious about making a launchable desktop program (and especially if its going to be a game), you should use launch4j to make an exe file that launches the jar. It isn't hard to use, and it makes the program much more end user friendly
If your project was generated from the 1.7.2 PlayN archetype or newer, that functionality is already built in. Simply invoke:
mvn package
and a dependencies-included jar file will be generated in:
yourgame/java/target/yourgame-java-1.0-SNAPSHOT-jar-with-dependencies.jar
you can test it by running it standalone like so:
java -jar yourgame/java/target/yourgame-java-1.0-SNAPSHOT-jar-with-dependencies.jar
If your game was generated via an older PlayN archetype, the you can add the necessary bits to your java/pom.xml file by pasting in this in (merging with any existing <build> <plugins> blob):
maven-assembly-plugin
2.4
jar-with-dependencies
${mainClass}
make-assembly
package
single
Then just run mvn package as above to generate the file. Note that you will need to be building against PlayN 1.7.2 or newer as that version is the first one that supported automatic unpacking of the LWJGL native libraries needed to run on the desktop.

Resources