Including user home dir in Jrebel.xml - jrebel

Using Jrebel with NetBeans 8.0.2, projects shared by multiple users. The root of the projects is variable "dev.env.home" defined as an ant variable in Netbeans settings. Is it possible to pass this variable to rebel.xml file? I have tried this:
<dir name="${dev.env.home}\java\projects\Generator\target\classes"/>
But it does not seem to work

try providing the value for that placeholder as JVM parameter.
-Ddev.env.home=C:\myhomedir
That should work.

Related

How to convert picocli groovy-grape script to native standalone app?

I have a made my first groovy CLI app with picocli. Now, I want it to be available for use without any JVM installed on the client machine, maybe with the use of GraalVM.
This is for an opensource project:
https://github.com/kchaitanya863/db2csv
Another easy option is to dockerize your script (read this blog about how to do it https://groovy-lang.gitlab.io/101-scripts/docker/basico-en.html)
If you want to build a linux executable you need to change your project:
convert to a gradle project (maven is also an option but gradle has a lot of plugins)
change your script to a class with a tipical main (and move it to the standard directory src/main/groovy/mypackage)
add some tasks into you build.gradle similar to these https://gitlab.com/snippets/1797638
You will need to:
statically compile your groovy script
make the args variable available after static compilation with
final String[] args = getProperty("args") as String[]
specify a reflection configuration file for the classes dynamically loaded/invoked using reflection by Groovy (this may be useful)
specify a reflection configuration file for the classes loaded/invoked using reflection by picocli. The picocli-codegen module provides a picocli.codegen.aot.graalvm.ReflectionConfigGenerator tool to generate the configuration file.
If your script has any #Grape dependencies, you may need to turn off the Grape dependency manager with -Dgroovy.grape.enabled=false and add all dependencies to the classpath manually instead
Credit: I got most of these tips from this article by Szymon Stepniak
If you want to use Graal with Groovy, check out this article:
https://e.printstacktrace.blog/graalvm-and-groovy-how-to-start/

Delphi Linux64: how to retrieve the version information set by Project Options Version?

I gather there is no universal standard for putting version numbers into executables on Linux, in contrast to Windows which requires a certain structure for those details.
FreePascal has made its own standard and Delphi lets you define Version information for a Linux executable.
If we can put Version information in, we must be able to get it back out? How? Specifically on Linux64?
I have searched *.pas and *.inc in Studio\19.0\source\rtl\posix and I have not found anything on 'version' nor 'fileinfo' that could help.
Back with Kylix, I used to use argp_program_version from libc.
On a clean new DUnitX project, after adding {$ *.res} to the DPR so that the version information will stick, I can look at Project Options for Linux64 and I can see that they have a CFBundleVersion number defaulting to 1.0.0 for the project. How can I get the CFBundleVersion at runtime in my Linux64 executable?
Or, if that is not possible, could/should Delphi match the FreePascal standard and put the fileinfo into something which both Lazarus and Delphi could view at runtime??
This excerpt (metioned at both Windows and MacOS/iOS sections) from https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Version_Info may help:
Go to Tools > Options > IDE > Environment Variables and add a new User variable called SAVEVRC with Value=TRUE. This variable enables the generation of a .vrc file with an auto generated build number and other information.
another excerpt from there (not sure if related to the aforementioned SAVEVRC or not) is:
Note: If you define the VersionInfo resource and add it to the project via a $R directive in the project file, the compiler will ignore settings of Version Info at Project Options dialog box and use the custom resource data instead, given an application can have only one VersionInfo resource on Windows.

Environment Variables in Hybris local.properties

I'm wondering if, in a Hybris properties file, there is a way to reference environment variables.
For example, in local.properties:
my.property = ${MY_ENVIRONMENT_VARIABLE}
My searching has concluded that this is possible in Spring, but doesn't appear to work in Hybris.
Any thoughts would be appreciated.
It's possible to access to environment variables within hybris. A partner of my company found out this deep down in hybris documentation:
Platform allows you to specify properties also as environment variables
# security: make the platform *abort startup* if no one overrides the settings below
db.url=<CHANGE_ME>
db.username=<CHANGE_ME>
db.password=<CHANGE_ME>
# security: end
The special property value has been introduced exactly for such use cases where administrators want to ensure that: a) files do not contain sensible settings, and b) the system doesn't start up if those settings haven't been overridden.
On the server, those settings are to be exposed as environment variables just before starting Platform:
foo$ export y_db_url=jdbc:mysql://my.secret-db-host.com/AlfavaMetraxis?useConfigs=maxPerformance&characterEncoding=utf8
foo$ export y_db_username=Amy
foo$ export y_db_password=Rory
foo$ ./hybrisserver.sh start
...
As you can see, settings need to be prefixed and escaped in order to work as environment variable.
https://help.sap.com/viewer/a74589c3a81a4a95bf51d87258c0ab15/1905/en-US/8b8e13c9866910149d40b151a9196543.html?q=CHANGE_ME
Hope this is useful for you.
I found this related to your question on Hybris Experts. Hope it helps.
It is not possible to access shell environment variables inside local.properties file. As a workaround you can do echo "my.property = $MY_ENVIRONMENT_VARIABLE" >> local.properties before starting platform.
No it's not possible.
Actually hybris use org.apache.commons.configuration package. In the documentation you'll find that it's possible to use environment variable.
user.file = ${sys:user.home}/settings.xml
action.key = ${const:java.awt.event.KeyEvent.VK_CANCEL}
java.home = ${env:JAVA_HOME}
Unfortunately hybris has done something I can't explain, they have overidded the default implementation and removed all interpolation features.
If we analyze the issue further, the configuration class used is called HybrisConfiguration. This class extends AbstractConfiguration from Apache Commons Configuration. The getProperty method use an other interface called ConfigIntf. The implementation is found in the class AbstractConfig. There every getString getInteger, etc... methods are overrided.
For example, for String, the method does not call the interpolate method but instead you'll find a really simple...
StringUtils.isEmpty(value) ? def : value;
So if you want to use all features of Apache API, then try to replace hybris implementation... However I think that it won't be so easy to do that without modifying the platform since I don't see any beans there that could be injected.

Android Studio - Include ResourceBundles in Module

I currently switched from eclipse to android studio. In eclipse I had 2 projects, one android application project and one java project which I included in the android project as library. This java project uses ResourceBundles to create internationalized error messages for it's own errors. This has been my project structure:
/MyApp
/src
/res
...
/MyLibrary
/src
/res (added as source folder to build path)
/loc
Bundle_en.properties
This worked when loading the RessourceBundles as following:
ResourceBundle.getBundle("loc.Bundle", Locale.ENGLISH);
Now I switched to android studio and my new project structure looks like this (added the java library as module):
/MyProject
/MyApp
...
/MyLibrary
/src
/main
/java
...
/res
/loc
Bundle_en.properties
But I'm not able to load the ResourceBundles anymore, it's just throwing a java.util.MissingResourceException. I tried a lot of different locations for the ResourceBundles and different paths but I'm going to get crazy because nothing seems to work. Could anybody explain where to put those bundles and how to load them?
Thank you!
Faced exactly the same problem. To make it work I finally had to create a resorces folder in my project module's main folder.
here multiple files starting with the same name (as messages in this picture) gets bundled as a resource bundle.
Finally had to call it using
ResourceBundle.getBundle("org.eclipse.paho.client.mqttv3.internal.nls.logcat")
or
ResourceBundle.getBundle("org.eclipse.paho.client.mqttv3.internal.nls.messages")
to get the required resource.
If you include the second project as a library, you might not want to create a new resource folder as suggested in a previous answer (which does work). Instead, you can simply add the library's resource folder to your resource directories in your module's build.gradle: to the android section add
sourceSets {
main.resources.srcDirs += 'path/to/your/libs/res'
}
If now the added res folder contains org/mypackage/Bundle.properties you can refer to it using
ResourceBundle.getBundle("org.mypackage.Bundle")
Actually adding a new resource folder does nothing more then adding it as a resource directory in build.gradle.
I never tried but Intellij comes with very good integration of Resource Bundles.
Refer this link
http://www.jetbrains.com/idea/webhelp/resource-bundle.html
From the link above
Resource bundle is a set of properties files that have same base name
with different language-specific suffixes. A resource bundle contains
at least two properties files with similar base name, for example
file_en.properties and file_de.properties.
IntelliJ IDEA recognizes properties files, and if two or more
properties files with the names that differ only in suffix, are
encountered, joins them into a resource bundle. The new node Resource
Bundle '(base name)' appears in the Project Tool Window:
You can have these files inside your module or on root as well.
First please ensure your resource folder (where the property file is localted) is in the classpath and you can easily find that by calling the following.
URLClassLoader ldr = (URLClassLoader)ClassLoader.getSystemClassLoader();
URL[] urls = ldr.getURLs();
for(URL url : urls)
{
System.out.println(url.getPath());
}
Now if you find your resources folder in the classpath then you can simply call the bundle base name, in your case ResourceBundle.getBundle("Bundle"), no need for a fully qualified path. Assuming you are using English locale, it should find it. You can further add en_US, en_NZ, en_GB etc if needed.
If you do not find your property folder then make sure it is in the classpath and if you need to add it dynamically follow this thread.
How do you change the CLASSPATH within Java?
Remember the only addition for loading property files dynamically is that you MUST call findResource or findResources API on the class loader to load the property file. Hope this helps.

Is there a way to prevent IntelliJ IDEA from compiling logback.groovy?

I have a groovy project in IntelliJ IDEA that uses logback.groovy. It's in src/main/resources so that it ends up in the classpath of the project, but IDEA compiles it into logback.class. Logback expects this to be in .groovy format, so this won't do. Is there a way to prevent this behavior? I just want logback.groovy in my classpath for running unit tests and webapp debugging.
IDEA 13 now supports new types of directory assignments under your content root: the relevant one for this question is "resources".
In previous versions, IDEA only supported marking directories as "sources" or "tests".
So the new correct answer is to mark src/main/resources directory as a resources folder of your content root. By marking the contents of a directory as "resources", you're telling IDEA that the contents are not source code but need to be accessible on the classpath at runtime.
[Added as a separate answer because the first one is still potentially useful if your file is stuck under your source tree for whatever reason - feel free to merge it in to the other answer if that's more appropriate.]
I guess /src/main/resources is marked in IDEA as a source root? That's pretty much explicitly telling IDEA "the stuff under this directory is source files".
You could try adding the file to /Settings/Project Settings/Compiler/Excludes - but that will probably mean that your file won't get copied onto your output path (and thus won't be on the runtime classpath so logback won't see it).
My personal solution is that my logback.groovy sits outside of my /src tree - I consider it to be configuration rather than a source/resource file. My config directory itself is then added to the runtime classpath directly via /Project Structure/Modules//Dependencies (marked as runtime scope).
My solution was to modify the artifact to explicitly include logback.groovy in the WEB-INF/classes directory. It isn't ideal since this file could only be referenced by the absolute path and not as a project file, so any suggestions are still welcome.
I put logback.groovy in src/main/resources and added it to Resources patterns in IDEA's Compiler settings (ctrl + alt + s; Compiler > Resource patterns). And it works :)

Resources