Friday, April 28, 2017

Excluding Property Files from Jar File : Maven Shade Plugin

Recently, i wanted to create a single Jar file with all the dependencies while the property files are excluded which are coming from the project. But the property files which are coming from dependencies should be preserved. My idea was to externalize property file so that someone can edit them without going inside Jar.

I tried several options.

Resources plugin perfectly work for the need. But it excludes the property files even when i run the project from the IDE (Eclipse/NetBeans)

I tried jar-with-dependencies pre-defined assembly descriptor with few customization. I used exclusion in unpackOptions. But it excludes property files which are coming from all the dependent modules.

Finally i found the working solution. It was Maven Shade Plugin

Following is example pom.xml. There you can see how i have used Maven Shade Plugin with property file excluding configurations. Shade plugin can be use to filter any file file from any dependent module conveniently.
Since i wanted an executable Jar i have specially used ManifestResourceTransformer in the Shade configurations.



Tuesday, December 20, 2016

Getting Start with MySQL Community Server ZIP Archive on Windows

It's always easy to use a zip archive than installing a software on your machine. Recently I've got to use MySQL Community Server ZIP Archive (mysql-5.7.17) and faced some problem when setting up the server. I will give you few step by step guidelines for a successful set up so that you won't face the same problems.

Step 1: Extract the zip archive.
Lets say the base directory path is D:\mysql-server

Step 2: Open the command prompt in Administrator Mode and navigate to MySQL base directory.
This is the most important step. MySQL needs access to your registry at the initial execution. If you execute the initial MySQL commands without administrator mode you will get an error message like follows.
Could not create or access the registry key needed for the MySQL application
to log to the Windows EventLog. Run the application with sufficient
privileges once to create the key, add the key manually, or turn off
logging for that application.

Step 3: Enter following commands.
D:\mysql-server> mysqld --initialize
or
D:\mysql-server>mysqld --initialize-insecure

Above first command will create a random password for root user account while second won't.

Setp 4: Enter mysqld in the command prompt.
D:\mysql-server> mysqld
Now your MySQL server is up and running!

Using command prompt in administrator mode is only for the setting up. You don't want administrator mode in the later sever startups.

A Note for MySQL Workbench Users:
I use MySQL Workbench as the IDE. My OS is a 64bit OS and I downloaded 64bit non-install zip version of MySQL Workbench. But it got crashed when i started it. Then i browsed internet and found that 32bit version is the solution. I downloaded MySQL Workbench 32 bit non-install zip and it worked fine.


Thursday, January 28, 2016

Find Eclipse IDE Information - Eclipse Plugin Development

This simple Eclipse plugin program shows you how to retrieve following information regarding the Eclipse IDE.
  • IDE name
  • IDE version (.., Kepler, Luna, Mars,..etc with version number) 
  • Plugin version
  • Platform user name




You can test the program by running it your RCP environment. When you ran it, click on the LakJ Comspace icon in the tool bar of Eclipse sandbox window. Then you will see the information.
Following is the java code related to the program. You can download the complete project from the github links given at the end of the tutorial.

Here the InfoUtil.java does the information retrieving. Rest of the two classes (Activator and InfoAction) help the program to behave as a Eclipse plugin.

Following are the GitHub URL's for complete plugin project. You can clone the project or downolad the project as a zip file. To run the project open an Eclipse RCP environment and import the project as a maven project.

GitHub repository URL - https://github.com/lakjcomspace/Eclipse-Find-IDE-Info
GitHub HTTPS clone URL - https://github.com/lakjcomspace/Eclipse-Find-IDE-Info.git
Download Project as a Zip - https://github.com/lakjcomspace/Eclipse-Find-IDE-Info/archive/master.zip