QuarkusTest ignores custom Maven user settings file - java

Running a QuarkusTest fails, when Maven settings are set in a user settings file (i.e. ~/.m2/settings-custom.xml as opposed to a more standard scenario ~/.m2/settings.xml).
This is also the case when a .mvn/maven.config file with a reference to the settings file is defined at project level with contents as follows: -s /Users/johndoe/.m2/settings-custom.xml.
Also, IntelliJ has a setting, which allows setting custom Maven settings files:
That setting does not seem to work either.
Any ideas?
If I replace settings.xml with the contents of settings-custom.xml, everything works as expected.

Related

Access a Java variable from Jenkins

I am trying to find out if I could get the value of a variable declared inside a Java program or maven-plugin and store it in a Jenkins environment variable.
This is because the Jenkins file has to create a new git branch from dev and call it Release-9.0.86 for example but the version number is inside a pom.xml.
I have already written a maven-plugin that retrieves the version from the pom.xml an writes it into another XML file, but I need to know if I could send the version to Jenkins to handle it.
You could perhaps create a properties file instead of a xml file with the needed information. Example contents of created branch-name.properties file:
NEW_BRANCH_NAME=Release-9.0.86
Then you can add a build step "Inject environment variables" after the one that produces the properties file, and configure that to read the properties file you just created.
Properties File Path: branch-name.properties
After that you can use the environment variables as usual in the jenkins build, for example a "Execute shell" build step that creates the branch:
git branch ${NEW_BRANCH_NAME}
To then push the newly created branch you could add a "Git Publisher" post-build action.
Branch to push: ${NEW_BRANCH_NAME}
Please note that it might be useful to configure Git Publisher to "Push Only If Build Succeeds" i.e. branch will not be created if the build fails for any reason.

Eclipse IDE : How to know exact jar file for classes loaded at runtime?

I have web application that is running in Jboss container.
Sometime I need to debug the code and for the I need to know from which jar current class is being referred (so that i could search of source jar of the corresponding jar)
Is it possible to get this Jar information (name of the jar file) from which current class is being referred. See the attached screen shot - from where i am trying to get this jar file information. Not sure if my approach is right or wrong
Eclipse allows you to make code changes during debug time.
So, if you want to entering in a class and know what is the jar source of this class just do CTRL + Mouse Right click in the class name and you enter inside the class.
If you have the "Link with Editor" option selected in your Package Explorer you can see automaticly what is ths jar file you are importing.
Compile time classpath settings are different from Runtime server classpath settings.
So if you want to know all the locations/jars that contain a particular class at compile time in eclipse then use Ctrl+T and type the class name. If there are multiple jar files with same class/namespace, then the order will be defined in Build Path settings --> Order and Export.
Runtime reference depends on class loading policy of your server configuration. But usually first it refers from local project, then manifest and then from common class path library.
If your server is configured to refer the workspace location of your project, then most probably the order would be as you defined in .classpath file, and you can use Ctrl+T to find it out.
Edit
It seems you want eclipse to resolve the source file automatically. If you are using maven then run below commands to refresh the source and javadoc for all your jar files.
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc

IntelliJ - How to add a default run configuration to a user created project template?

I have my own user created project template that spawns a Main.java file under a src package. I would like the project template to also have a particular run configuration that executes the Main.java file with the VM parameter
-Djava.library.path=/usr/lib/lwjgl-2.9.1/native/linux
I'm having a lot of trouble finding this in the documentation. Can anybody guide me in the right direction?
I'm running IntelliJ 13.1. The following is a screenshot of the run configuration I would like to be part of the project template, which was created from the project on the left.
In your screenshot, you have two categories: Application and Defaults. If you expand Defaults, it will list Application. Click on the Application and set the default value there. Any runtime configuration built from the default will carry those default values from now on.

IntelliJ Problem with+get current working directory

Here is my maven project structure
ProjectParent
-Class1
-Class2
-Module1 (another sub directory)
--Module1Class1
--Module1Class2
Now when I run Module1Class1 from IntelliJ my current working directory is where ProjectParent directory, but when I run Module1Class1 from eclipse, my current working directoru is ProjectParent/Module1 directory.
Why this is different in intellij & how can I change this, so my current directory is always from where my class started execution like in this example 'Module1Class1' directory.
You should edit the template Run/Debug configuration and specify $MODULE_DIR$ variable in the Working directory field.
All the new configurations will inherit this default setting and the variable will be substituted with the directory of the module that you want to run.
There is a feature request to make it the default setting, please vote.
You can edit the working directory from within the run configurations dialog.

How do I save Eclipse launch profiles across workspaces?

When I copy an Eclipse project directory, it contains the .classpath and .project files so that when I take that same directory to another Eclipse instance, I don't have to setup my build path and such (assuming that all the resources are contained in the project, and not external.)
However, this procedure doesn't cause launch profiles to "travel" with the directory.
Is there some other file/directory structure I can "carry around" to another instance of Eclipse that will include my launch profiles?
The .launch xml files (launcher definition) are found in
[eclipse-workspace]\.metadata\.plugins\org.eclipse.debug.core\.launches
Just copy them into your <project>/.settings directory.
Refresh your project, and there you have it: those launcher configuration are available, and you can copy them along the rest of your project files.
Warning: do uncheck the option "Delete configurations when associated resource is deleted" in the Run/Launching/Launch Configuration preference panel: it is common ot soft-delete a project in order to import it back again, to force a reinitialization of the eclipse metadata,... but this option, if checked, will removed your detailed launch parameters!
See also Which eclipse files belong under Version Control, and where are the external tools launch configurations in Eclipse.
Jared adds:
There is no .settings directory in my project directory - I created it and put the .launch file in there, refreshed my project, and it doesn't have any Run profiles. Do you have to mirror the directory structure under .metadata?
Just create the .settings directory (it is actually created when you have project specific settings as illustrated in the question "Maintaining a common set of Eclipse preferences").
Then delete the same .launch file from the .metadata directory.
Then refresh your project and go to the "Run Configurations" Panel: you will see your launch configurations still available, except they are stored where they belong: within your project directory and not buried under an obscure workspace metadata thingy.
Update June 2012
I always seen my launch configurations, saved under PROJECT_LOC/.settings, automatically imported when reloading the Eclipse workspace.
However, as described in "Tip: Creating and Sharing Launch Configurations (2007)", you should be able to reference a launch configuration saved into any subdirectory of your project if you go to the "Common" tab of your "Run Configurations" wizard.
So saving your launcher anywhere in the project won't display them automatically in the "Run Configurations" section of the preferences.
But declaring a new one, sharing its launcher as a "Shared file" (as illustrated above), and then overwriting that launcher with the actual one you had previously saved would update that run configuration.
Try choosing a shared file location inside your workspace from the "Common" tab of the launch configurations (profiles).
Depending on the amount of moving around you do and the number locations you move to, storing your launch files in an online storage space and then setting up folders at the new locations to synchronize with it may be a viable solution.
Dropbox
is a decent online storage system that gives users up to 2 gigabytes of storage.
Here is an example of how you can synchronize folders out side the Dropbox folder curtiousy of
LifeHacker.com :
Use either the JUNCTION utility from Sysinternals, or the MKLINK command built in to Windows Vista and Server 2008, for example:
junction "C:\Documents and Settings\User\My Documents\My Dropbox\DesiredFolder" "C:\Path\To\DesiredFolder"
mklink /D "C:\Users\Steve\Documents\Dropbox\DesiredFolder" "C:\Path\To\DesiredFolder"
Or, if you prefer a GUI, install Link Shell Extension.
[eclipse-workspace].metadata.plugins\org.eclipse.debug.core.launches
would be the DesiredFolder.
You could also use SyncToy to echo changes from another folder to your Dropbox folder. This keeps 2 copies on disk though.
On OS X or Linux, try the following:
Use the ln command, for example:
ln -s /path/to/desired-folder ~/Dropbox/desired-folder
This works with files too:
ln -s /path/to/desired-file ~/Dropbox/desired-file
Another easy way to do this with Terminal is type the ln -s part, then from Finder drag the folder/file that you want into the Terminal window then drag the Dropbox folder and hit return.
Note that an Alias file or folder does not work.
Another solution could be to keep your launch files in an svn repository. Search for How to run Eclipse launch configurations programmatically? on this site. Sorry can only post one url so I used it on Dropbox.
There is an another clean way to share the launch configurations in Eclipse.
Create a java project. For instance lets name it Launches-Configs.
Now create a new Run Configuration for a project that you need to
run.
On the Run Configurations window navigate to Common tab. Ensure
Shared File option is selected and input the Shared File location is set to
\Launches-Configs\src
Check in Launches-Configs to a VCS and share with other teams
I have had good use of creating a /launch folder, and then setting the launch configuration to be "Shared file:" (the Commons panel) to the above mentioned launch folder.
The resulting launch file can be checked into e.g. CVS git and be pulled into a fresh workspace.
Create a Launch Configuration with Shared File option selected under Common Tab.
This will create a configuration file with .launch extension.
Now in another workspace just go to Import and select Launch Configurations, choose the configurations from the directory and finish.
It will appear in the Run configuration now.

Categories