To run many of the tools you find in Java development you first have to ensure the environment you're working in is configured correctly - this is often the command line for Windows or shell for Linux. For example when you want to run the 'javac' program from the command line, your computer needs to knows the path to that executable file.
**NOTE** it is possible to make environment variables permanent on a machine so that they only ever need to be set once. This can be dangerous for several reasons:
a) If you set a faulty path you could crash your machine and the change may be irreversible.
b) If you switch machine you will have to try and remember all the changes you made.
Here enters the setenv script!!
This is a very simple script to set up the Windows command line interface to use Java. Copy this into your favourite text editor and save it as setenv.bat. Now, edit the script to include your Java install then open a command line prompt. Once open type "set" and run. A series of value/variables pairs should be displayed but JAVA_HOME should not be set.
Now, run "setenv.bat" and "set". You should now notice both the PATH and JAVA_HOME variables have been set.
And here is the Linux version:
These scripts I have provided are very simple and only currently set up your Java environment. You can use the same principles to set up your build tools or any other third party tools you may wish to run from the command line.
Sonar has one of the most boring user interfaces I think I've ever seen -- it's butt ugly! but, as ugly as it is there's no denying how useful it is.
A dashboard should be simple, provide enough information about the project ,but not overwhelm the user. If your customers or stakeholders have access to this they may not be technically minded and so this page should show info that anyone can understand.
Dashboard
To change the dashboard, log in as the admin user and on the right of the page select "Edit Filter":
The column headings that I have selected are:
- Lines of code
- Rules compliance
- Unit test success (%)
- Coverage
- Complexity /method
- Complexity /class
- Public documented API (%)
- Duplicated lines (%)
- Total Useless Code (plugin)
- Build date
Project Layout
When you select a project from the name column on the dashboard you will be presented with a page like the following:
Now this is where you can geek out and go crazy with metrics. Hopefully, by this point the non-techies have seen what they wanted and left. This page is where you can get creative.
I hope i'm not generalising too much but I would like to think most technically minded people are working with widescreen monitors for maximum productivity. If this is true I would strongly advise going for a three column layout. This can be done by selecting "Edit Layout" on the right and choosing the tri-colum option.
Finally, to select the widgets you want to display press "Configure widgets" and then you can drag and drop them at your desired locations.
I had an error today when trying to create a datasource in Weblogic. The error was:
ORA-27101: shared memory realm does not exist
Cause: Unable to locate shared memory realm
Action: Verify that the realm is accessible
The cause of this error was due to the number of database sessions being outnumbered by the number of Weblogic instances. We set up 7 environments, each with 50 maximum connections but only 100 sessions on the DB side.... as you can imagine we smashed the limit.
You can check the number of sessions using:
And you can check how many are currently in use using:
ORA-27101: shared memory realm does not exist
Cause: Unable to locate shared memory realm
Action: Verify that the realm is accessible
The cause of this error was due to the number of database sessions being outnumbered by the number of Weblogic instances. We set up 7 environments, each with 50 maximum connections but only 100 sessions on the DB side.... as you can imagine we smashed the limit.
You can check the number of sessions using:
SELECT name, value
FROM v$parameter
WHERE name = 'sessions'
And you can check how many are currently in use using:
SELECT COUNT(*)
FROM v$session
I found this on the net a long time ago and thought I would share. Basically, it parses a log file and extracts the errors.
<target name="build">
<echo message="Add foo bar baz"/>
<exec executable="${db.sqlplus}">
</exec>
<echo message="Load x y z"/>
<exec executable="${db.sqlplus}" dir="foobar">
</exec>
<!--Check the log files here-->
<check-log-file fileToCheck="${output.log.1}"/>
<check-log-file fileToCheck="${output.log.2}"/>
<antcall target="fail-if-error"/>
</target>
<!--=================================================================================
Check the file named in the property file.to.check to see if there are errors.
The way this works is to find all lines containing the text "ERROR" and put
them into a separate file. Then it checks to see if this file has non-zero
length. If so, then there are errors, and it sets the property errors.found.
Then it calls the send-email target, which doesn't execute if the errors.found
property isn't set.
-->
<macrodef name="check-log-file">
<attribute name="file.to.check"/>
<attribute name="file.errorcount" default="@{file.to.check}.errorcount" description="The file to hold the error lines"/>
<sequential>
<copy file="@{file.to.check}" tofile="@{file.errorcount}">
<filterchain>
<linecontains>
<contains value="ERROR"/>
</linecontains>
</filterchain>
</copy>
<condition property="errors.found" value="true">
<length file="@{file.errorcount}" when="gt" length="0"/>
</condition>
<antcall target="check-log-file-send-email">
<param name="file.to.check" value="@{file.to.check}"/>
</antcall>
</sequential>
</macrodef>
<!--=================================================================================
If there are any errors, send an email to let someone know
-->
<target name="check-log-file-send-email" if="errors.found" description="Sends an email out if error detected">
<resourcecount property="error.count">
<tokens><!-- default tokenizer is a line tokenizer -->
<file file="${file.to.check}.errorcount"/>
</tokens>
</resourcecount>
<echo message="Database build (${e1.codeline} - ${error.count} errors found..."/>
<antcall target="mail">
<param name="from-address" value="build"/>
<param name="to-list" value="myemail"/>
<param name="subject" value="Automated database build error report for ${db.host}"/>
<param name="message" value="See attached log file, ${error.count} error(s) found..."/>
<param name="attach" value="${file.to.check}"/>
</antcall>
</target>
<!--=================================================================================
Fails the database build if errors were detected.
-->
<target name="fail-if-error" if="errors.found">
<echo message="Errors found - setting database fail flag..."/>
<fail message="Errors detected during ${codeline} database build. Check logs."/>
</target>
Just yesterday I was offered a new job with a relative large insurance firm in the UK. My role will be to bring the build management team up to scratch and implement a framework from the ground up. This got me thinking... what are the tools and good practices I cant live without?
Build & Release Website
Every software development outfit should have one of these! Some of the information you would store is:
This should be maintained by the Build & Release team and should be automated. Our systems are configured to deploy the documentation once its been created.
Build & Release Calendar
Another tool no serious software company should be without. The projects that you support should be able to see your workload and manage requests accordingly. Also, if you need to justify where you're spending your time this acts as a great record for the finance department or Project Managers. There are free calendars available and tools like Jenkins also provide work well with Google Calendar.
Build Framework
No sh!t, really?! It doesn't matter what tools you use, but you should be able to build, package, run unit tests and deploy at very least. The aim here is to produce a framework that can be used with very little configuration and flexible enough to use with new projects. Some of the "powers-to-be" at my office have been trying to get us to switch to Maven for a while now. The argument that we're forced to use a single framework is a fair one, but my counter argument is that our Ant framework is so well made that we wouldn't be achieving anything by switching. Ant is a highly configurable tool but takes a lot to get up and running, however Maven is not so flexible but is much easier to use "out of the box".
Continuous Integration
CI is often considered something only used by large scale projects. This doesn't have to be the case. Even if you're a small operation with only a handful of developers it makes sense to offload the task of compiling your source and running a few simple tests. To put this into context, if you have 5 developers, a build takes 1 hour and each developer builds at least once a day, thats 25 hours wasted on builds a week. At a very generous rate of £15 per hour thats £375 a week and £1500 a month wasted in consumed resources for builds. Thats the build server bought and paid for!!
Build & Release Website
Every software development outfit should have one of these! Some of the information you would store is:
- Functional Release Notes
- Technical Release Notes
- Continuous Integration Results (Link to tools)
- Project Documentation (Javadocs or LXR)
- Runtime Logs
- Deployed Applications (A list of environments and their current deployments)
- Application Metrics
- Third Party Documentation (Tools, Libraries)
- Misc Documents
This should be maintained by the Build & Release team and should be automated. Our systems are configured to deploy the documentation once its been created.
Build & Release Calendar
Another tool no serious software company should be without. The projects that you support should be able to see your workload and manage requests accordingly. Also, if you need to justify where you're spending your time this acts as a great record for the finance department or Project Managers. There are free calendars available and tools like Jenkins also provide work well with Google Calendar.
Build Framework
No sh!t, really?! It doesn't matter what tools you use, but you should be able to build, package, run unit tests and deploy at very least. The aim here is to produce a framework that can be used with very little configuration and flexible enough to use with new projects. Some of the "powers-to-be" at my office have been trying to get us to switch to Maven for a while now. The argument that we're forced to use a single framework is a fair one, but my counter argument is that our Ant framework is so well made that we wouldn't be achieving anything by switching. Ant is a highly configurable tool but takes a lot to get up and running, however Maven is not so flexible but is much easier to use "out of the box".
Continuous Integration
CI is often considered something only used by large scale projects. This doesn't have to be the case. Even if you're a small operation with only a handful of developers it makes sense to offload the task of compiling your source and running a few simple tests. To put this into context, if you have 5 developers, a build takes 1 hour and each developer builds at least once a day, thats 25 hours wasted on builds a week. At a very generous rate of £15 per hour thats £375 a week and £1500 a month wasted in consumed resources for builds. Thats the build server bought and paid for!!
Posted by
Sion
at
10:08
Here are 2 methods for removing a version of an element. The first method is limited to rolling back the latest version, however, the second will allow a rollback to any version. It's not a good idea to delete a version in ClearCase because they can be problematic.
Method 1- Subtractive Merge:
cleartool merge -graphical -to {ELEMENT} -delete -version {VERSION}
e.g cleartool merge -graphical -to deploy-lib-init.xml -delete -version \main\37
If no manual merges were required on checkin ,then chances are this will be resolved automatically. All of the data for this can be obtained by right clicking on the element in ClearCase Explorer -> Properties of version. You should get a window like:
**NOTE** Because the window has a fixed size you cant see the whole string for "Name", I would advise copying the string into a text editor.
D:\CC\CASPA\willis7_CASPA_int\IPS_Source\System\build\deploy-lib-init.xml@@\main\37
The two highlighted parts are the ELEMENT and VERSION respectively.
Method 2- Hijack with older version:
cleartool get –to {ELEMENT} {ELEMENT}@@{VERSION}
e.g. cleartool get –to deploy-lib-init.xml deploy-lib-init.xml@@\main\5
A slightly easier approach. This involves hijacking your local version with a version specified by yourself (the example above would take version 5). This can then be checked out and back in to create a new version that replicates the specified version.
Method 1- Subtractive Merge:
cleartool merge -graphical -to {ELEMENT} -delete -version {VERSION}
e.g cleartool merge -graphical -to deploy-lib-init.xml -delete -version \main\37
If no manual merges were required on checkin ,then chances are this will be resolved automatically. All of the data for this can be obtained by right clicking on the element in ClearCase Explorer -> Properties of version. You should get a window like:
**NOTE** Because the window has a fixed size you cant see the whole string for "Name", I would advise copying the string into a text editor.
D:\CC\CASPA\willis7_CASPA_int\IPS_Source\System\build\deploy-lib-init.xml@@\main\37
The two highlighted parts are the ELEMENT and VERSION respectively.
Method 2- Hijack with older version:
cleartool get –to {ELEMENT} {ELEMENT}@@{VERSION}
e.g. cleartool get –to deploy-lib-init.xml deploy-lib-init.xml@@\main\5
A slightly easier approach. This involves hijacking your local version with a version specified by yourself (the example above would take version 5). This can then be checked out and back in to create a new version that replicates the specified version.
When we make any changes to our databases we like to restart the application servers to refresh the datasources. Some of our development environments are run as Windows services and so it would be nice to restart them remotely from the build machines. Here's how with Ant:
I hope you can see in this snippet that the code runs 2 tasks - Stop and Start. You can break down the code if you just want a Start or Stop only script.
Subscribe to:
Posts (Atom)