Pre-commit hook for Java Project - java

is it possible to set pre-commit hook for java & pom based project? I came across blog https://dwmkerr.com/conventional-commits-and-semantic-versioning-for-java/ and able setup commit-msg and he mentioned the command "git config core.hooksPath .githooks" it will work but each developer needs to manually run the command. is there any other way to make automated process?

it will work but each developer needs to manually run the command
That is the problem with client-side hooks: there is always an "activation" to be set by the user.
I know only of one "semi-automatic" way to setup such hooks: using a template directory which can be referenced by a git clone.
Then you would get a repository with addition hooks already in place.

Related

Right way of working Java Eclipse project with GIT

What's the right way of working with an Eclipse Java project with GIT?
I have the plugin EGIT installed and a simple java project. I did a commit/push of this java project by using the GIT bash console. I pushed only the source files.
Is that correct? Should I use Eclipse IDE somehow to make the init, commit and push? I couldn't find how to do this in Eclipse.
How should I retrieve the project from another machine? Should I use GIT console to retrieve the project or Eclipse?
I did the procedure in several ways, but they failed.
The generic answer is: whatever works for you, works.
We have a large git repository, and users with eclipse and intellij.
Some IDE users use specific plugins, such as Egit, others simply use the "default" support that most IDEs are shipped with. Such users simply go command line, or maybe, some other 3rd party tool.
Me, personally, I only rely on the IDE to show me the history of a file, or sometimes to quickly diff to revisions. Anything else I do on the command line.
From that point of view, as said: anything that works for you, works for you. You can use eclipse to manage the aspects of a git repository, but you don't have to.
Personally, I suggest to first get a good book on git, and to then extensively study the command line tooling. You also seem to be confused between the responsibilities of your IDE, and your source code management system.

Selenium-java,TestNG and jenkins on CentOS

I have recently setup integration of Selenium (Java bindings) with TestNG and Jenkins in a Windows environment, which is running absolutely fine.
I have created a batch file of TestNG and executed it through Jenkins using Windows batch file command. Now the situation is that I have to run these Selenium test cases on a Linux (Centos 7) environment as the Jenkins is setup there.
I am not quite sure how I should approach that. I have gone through some articles, but really could not find anything related to this for Selenium/Java things.
I have already done some initial steps, but I'm stuck after that:
I have setup CentOS 7;
Installed Java on it;
Installed Jenkins on it;
I have also installed xvfb as it would be required for headless execution.
From here I need some guidance in terms of how to proceed further, or put all things together. For example, should I move Selenium/Java project on VM and somehow run the TestNG file through Jenkins? (but not sure how to do that need some steps to follow or are there any more prerequisite to it). Or some other approach which is better.
It would be great if someone can guide me towards any article or can explain here with steps.
Here's what you can try doing to get this working:
You need a version control system(VCS) such as GIT/SVN, wherein you would need to push in your test code. That way, your Jenkins Instance will be able to pull in code from the VCS.
Once you have pushed in your code into the VCS, you can create a build job which would pull code from your VCS, build it using a build tool such as Maven/Gradle/Ant and then execute your tests (again using the build tool)
To learn how to setup your Jenkins instance with Git (One of the popular VCS flavors), please refer to this blog.
To learn how to go about setting up a Continuous Integration system with Selenium, you can also refer to this blog post of mine.

How to configure eclipse to only run one executable at a time?

How can I configure eclipse to only let me run one executable at a time? I often find that I have started an executable and forgotten about it. I'd like eclipse to stop me doing that.
There's no such configuration for Eclipse; it goes against the fundamental concept that the IDE supports arbitrary numbers of projects and debug processes. The only options you have involve custom code, either in your application (as suggested by #Gábor Bakos in the comments above) or via a plug-in you write yourself.

Coq as part of continuous integration

In my current project we use Java and Coq. We have a continuous integration set up, using maven. We want to check coq files as part of it. I.e. we need:
Download and install coq locally if it isn't installed (like maven does with frameworks like gwt, etc)
Check that coq files are correct
Did anybody try setting up this? How can this be done?
I don't recommend automate that from your CI Build. Instead, it looks more like a Machine Configuration Dependency.
In cases like this, it is worth it to rely in tools like Puppet and Vagrant in order to ensure your Development Environment conforms to a given context, so your code needs to deal with this as either a premise or - better yet - ensure it is available in your PATH.
I know this is a really old question, but I have a different answer.
I have a similar CI setup that needs to install build tools. In some cases, such as on bitbucket, I pre-build a docker image containing the tools and update the build configuration each time I update the tools. In bitbucket, this works well because the source code of the package being built points to the particular docker image version to use to build it, which ensures that older builds can still be built, assuming the older docker images are retained.
Otherwise, I just script the installation of the tools using wget or curl to download as necessary.

Automate Runs in Eclipse

I have a main class that takes a series of arguments and I have 10 run configurations. Is there a way to have eclipse run them one after another?
The other answers are probably better solutions to your problem. However, if you install the Eclipse CDT into your Eclipse installation (using update manager or market place client), then you get an additional launch configuration type called Launch group.
Those launch groups allow creating a list of other launch configurations to be run one after the other. Make sure to set the Post build action in the dialog to "Wait until terminates" for each included launch configuration.
#Steven: To do it quick, you can write a JUnit Test case that just calls the intended classes in desired order and execute it. Eclipse already has the necessary jar for JUnit, so you are ready to go. Definitely, writing ANT/MAVEN script is a good practice.
As #gotuskar suggested, write test cases for your class. If you can afford running your ten configurations each time you build your project put them in its src/test/java directory, otherwise create a sibling project to your original one, make it depend on it, and put your tests there.

Categories

Resources