Showing posts with label Eclipse IDE. Show all posts
Showing posts with label Eclipse IDE. Show all posts

Sunday, September 6, 2026

Detecting the Current Branch Failed: Fatal: HEAD Is Not a Symbolic Ref

This issue occurs when I tried with Jenkins build using Maven Release Plugin. I was trying to build my production release artifacts. I was building my "master" branch and its for final release. I have used Git as repository. I faced this issue when clicked on "maven release build" link on left side corner of my Maven project (Jenkins job) .

As we know build issue is common for developers those are actively participating with Build and Release. This issue over Jenkins is common , but I never found any direct or easy solution for this. I spend couple of hour to resolve and google almost all relevant sites and article.But, not able to work out. Finally did it by some HIT and TRY ,then it works for me.   


Issue log details :-

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.884s
[INFO] Finished at: Wed Dec 17 18:05:43 EST 2014
[INFO] Final Memory: 15M/301M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project hello_world_app: An error is occurred in the checkin process: Exception while executing SCM command. Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[JENKINS] Archiving /opt/jenkins_dev/workspace/SDP_BIZ_HELLO_WORLD_APP/pom.xml to in.com.company.xcop.sdp.bizservice.test.dao/hello_world_app/0.0.8-SNAPSHOT/ hello_world_app -0.0.8-SNAPSHOT.pom
channel stopped
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds

Solution :-

 In Jenkins job , open the configuration and go to Git configuration => Advance Options => << add your local branch name >>. In my case I have added "master" .

If you are using some other version of jerkins then , you may find the similar settings with other way. In the same way Git configuration => Advance Options => Additional Behaviors => Check out to specific local branch => << Add your local branch name >>.   

Attached the screenshot below with highlight. 







Monday, February 12, 2018

How to Add Copyright Header to Java Files in Eclipse

How to add @copyright to your code in eclipse ?

As a developer , we mostly want to reduce few development or coding effort while working on a project. Adding @copyright to your java file or your project file is quite easy. There are few ways you can achieve these. 

First Solution :- You can use 3rd party plugin to generate the @copyright. Follow the steps to install the plugin and add copyright for your project.

 1. Go to => Help => Eclipse MarketPlace => Search for copyright generator



2. Click on => Install and proceed further for finishing the installation. After the plugin installed successfully.
3. Go to menu => Project => Apply Copyright 


4. Now , Select custom copyright and paste your copyright header text in the text area. I have used the below sample header for my blogging.


/*******************************************************************************
 * TechBytes - Confidential
 * ____________________
 *
 * [2018] - [2019]  TechBytes Incorporated
 * All Rights Reserved.
 * 
 * NOTICE:  All information contained herein is, and remains
 * the property of  TechBytes Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to  Java Developers Guide Incorporated
 * and its posts and articles are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from TechBytes Blogging.
 *
 * Generated on Feb 12, 2018
 ******************************************************************************/

Then , apply the included or excluded as per your need. I have added the included in this example. That means here I want to add copyright header text for all java file (i.e. *.java).  This expression will to add all .java files. Sample image below.



 5. Next => select the project you want to apply => Then select the java files you want to apply 


6. Now you can see the java files with your header copyright text as below.




Second Solution :-


You can directly add the header copyright text into the {template} in eclipse IDE. Follow the steps below.

1. Go to => Windows => Preferences => Java => Code Style = > Code Templates => Code

Then select "New Java files" , then add your copyrights in the first line as mentioned in the image below. Then Apply and finish.




2. Now create a new file ( Go to = File => New => Java Class)



Now you can see the copyrights has been added to your java classes. Hope it will help you to improve the coding practice and coding standards.


Hope it will help you.

Monday, January 29, 2018

How to Add a Custom Code Formatter to Eclipse

How to add my own or your company specified code formatter into eclipse ? 


Everyday we are facing lots of issues with development environment and its quite genuine. I though to share this steps also to help you to format your code with best practice. Usually, we need to develop a clean, and most readable code. You can add your own formatter into eclipse IDE (I am using Eclipse Mars in my example). But, You can use any other eclipse release version.

Normally we use the formatter with .xml file format. Its, nothing but a set of rules defined in XML. It defines how your code should look like as a structure.

1. Go to ==> Windows ==> Preference 

The below screen will appear.




2. Select ==> Java ==> Code Style ==> Formatter

The below screen will appear.




3. Now click on ==> Import button to import your formatter xml .

 The below screen will appear.




Now you can see the active formatter in eclipse, please see the below image with highlighted area.



The above image shows your selected formatter, now you are ready to do the code formatting as per your defined rule in the formatter xml , that you have just now imported. Now, you can  see the active profile as your formatter. You can use your keyboard shortcut key (Ctrl+Shift+F) for format the code or you can use the code format option from menu options.

In my next post I will post how to define the rules for write your own formatter. So, please keep following me.



Hope it will help you.


Wednesday, April 29, 2015

Eclipse Main Class Not Found: Troubleshooting Classpath Issues

This is the common issue with Eclipse , even I faced many times . This is not related to Eclipse or any other IDE tool.


This issue occurs when you are trying to run your main() method with respective class, its looking for the exact .class file in the class path.During the execution the .class file is not available in the class path. The best way to resolve this is, add the .class file into class path.

There are many possible diagnosis you can do in your Eclipse for this issue. As per the Eclipse behavior when you are updating the class path (Build Path) , your class is getting compiled that time and the .class file got created. So, Be careful when doing the build path for your project.

Also check your Build Path, if any jar file is missing. Because, its might causes sometime.

In my case I just found the jar file missing in the build path , and I removed the missing jar and added new jar file from other location.Then executed my class with main method and it works. Below screenshot shows my issue.


Thursday, September 11, 2014

How to Install Git Plugin in Eclipse Using EGit

This is very easy and you can do this easily. Normally , Eclipse IDE usually comes with Git integration through EGit. But, some how if its missed, we can add as the external plugin. Follow the below step-by-step process .

Step by step process to install git  plugin on eclipse:-

Step 1) Use the repository location. i.e. http://download.eclipse.org/egit/updates

Step 2.) Go to Help > Install New Software

Step 3.) Add repository location, Click Add. Enter repository name as "EGit". Then click Ok to add repository location.

Step 4.) Expand “Eclipse Git Team Provider” and select “Eclipse Git Team Provider”. Then Click Next

Step 5.) Review product and click Next.

Step 6.) Accept the agreement and click Finish.

Step 7.) Then, it will take few time for download the plugin and binaries.

Step 8.) Then ,accept the prompt to restart the Eclipse.

Now Your Eclipse is ready to use Git Repository Plugin.

You can also verify the Git installation.

Step 1.) Go to Help > Install New Software

Step 2.) Click on Already Installed and verify plugin is installed.

Else you can verify by searching on Windows => preference => type egit on search box.