Posts Tagged ‘Maven’
Posted by Jakub Holý on May 22, 2013
You can easily tell Maven to include the version of the artifact and its Git/SVN/… revision in the JAR manifest file and then access that information at runtime via getClass().getPackage.getImplementationVersion().
(All credit goes to Markus Krüger and other colleagues.)
Read the rest of this entry »
Posted in Tools | Tagged: Maven | Comments Off
Posted by Jakub Holý on February 5, 2012
Goal: Execute the slow integration tests separately from unit tests and show as much information about them as possible in Sonar.
The first part – executing IT and UT separately – is achieved by using the maven-failsafe-plugin and by naming the integration tests *IT (so that the unit test running surefire-maven-plugin will ignore them while failsafe will execute them in the integration-test phase and collect results in the verify phase).
The second part – showing information about integration tests in Sonar – is little more tricky. Metrics of integration tests will not be included in the Test coverage + Unit tests success widget. You can add Integration test coverage (IT coverage) widget if you enable JaCoCo but there is no alternative for the test success metrics. But don’t despair, read on!
Important notice: The integration of Sonar, JaCoCo and Failsafe evolves quite quickly so this information may easily get outdated with the next releases of Sonar
Versions: Sonar 2.12, Maven 3.0.3
Read the rest of this entry »
Posted in Languages, Testing, Tools | Tagged: java, Maven, Sonar, Testing | 5 Comments »
Posted by Jakub Holý on January 13, 2012
The dependency:tree goal of the Maven plugin dependency supports various graphical outputs from the version 2.4 up. This is how you would create a diagram showing all dependencies in the com.example group in the dot format:
mvn dependency:tree -Dincludes=com.example -DappendOutput=true -DoutputType=dot -DoutputFile=/path/to/output.gv
(The output is just a text file with the extension Graphviz gv.)
To actually produce an image from the dot file you can use one of dot renderers, f.ex. this online dot renderer (paste into the right text box, press enter).
You could also generate the output f.ex. in the graphml format & visualize it in Eclipse.
Note: Thanks to the reader Not Relevant for pointing out the right extension and a typo.
Posted in Tools | Tagged: Maven | 4 Comments »
Posted by Jakub Holý on December 31, 2011
- The Netflix Chaos Monkey – how to test your preparedness for dealing with a system failure so that you won’t experience nasty wakeup when something really fails in Sunday 3 am? Release a wild, armed monkey into your datacenter. Watch carefuly what happens as it randoly kills your instances. This is exactly what Netflix does with their with their cloud infrastructure – also a great inspiration for my recent project. Do you need to be always available? Than consider employing the chaos monkey – or a whole army of monkeys!
(PS: There is also a post with a picture of the scary monky.)
Links to Keep
- BDD: Write specifications, not scripts (from the Concordion site) – relatively brief yet very enriching practical description of how to do behavior-driven development a.k.a. Specification by Example right, the key point here being “Write specifications, not scripts.” It says why not (for scripts overspecify -> are brittle, specs should be stable) and how to do it (decouple the stable spec and the volatile system via fixture code, expose minimal stuff to the spec, perhaps evolve a DSL between the fixture and the system). It also lists common “smells” of BDD done wrong. If it still isn’t clear to you, read the Script to Specification Makeover example (or perhaps read it anyway). BTW, Concordion is a new tool for doing BDD based on JUnit and HTML, which was created as a response to the weaknesses of Fit[Nesse], i.e. exactly the tendency to do scripting instead of specifications. It looks very promissing to me!
- (Linux/Mac) Autojump – superfast navigation between favorite directories in the command line (via Jake McCrary) – it keeps track of how much time you spend in each directory and when you execute
j <substring of directory path/name>, it jumps into the most frequently used one matching the substring. It awesome! (You can also run
jumpstat to see the statistics.)
- (Linux) Tcpkill – service/network outage testing (via Jake McCrary) – kill connections to or from a particular host, network, port, or combination of all – useful e.g. when you want to test that your software is resilient to the outage of a particular service or server – less brutal than actually killing the database etc. instances. We need to test that our application recoveres properly when one of our MongoDB nodes dies so this may be quite useful.
- Manik Hot Deploy Plugin for Maven Projects (v1.0.2 in 5/2011; older version in the Marketplace) – plugin that can do hot and incremental deployment to any app server (simply by copying to its hotdeploy directory or the directory of an installed webapp) whenever you run mvn install or automatically whenever sources change, multi-module support
- Jake McCrary: Continuous Testing With Clojure and Expectations – continuous test runner lein-autoexpect for Clojure tests written using the library expectations by Jay Field.
- Jake McCrary: Quickly Starting a Powerful Clojure REPL – Clojure REPL only two steps away: 1) Run Emacs, 2) Execute M-x clojure-swank (no more need to open an existing Leinigen project) – the trick is to install the Leinigen plugin swank-clojure and use Jake’s elisp function clojure-swank that automatically starts the swank-clojure server. (I had to hack the function for the clojure-swank output contained “null” instead of “localhost”, likely due to incorrect DNS setup.)
Posted in eclipse, General, Testing, Top links of month | Tagged: BDD, clojure, cloud, eclipse, Maven, performance, SbE, Testing | Comments Off
Posted by Jakub Holý on October 19, 2011
Have you ever wondered what to do when needing “just a small change” to a third-part library your project depended on? This post describes how to use Maven and Javassist to take a dependency of your project, instrument it to modify its behavior, re-pack it, and release it as an artifact with a different name (so that you me depend on my-customized-lib instead of on lib).
The process is as follows:
- Phase process-sources – maven-dependency-plugin unpacks the dependency to classes/
- Phase compile (implicit) – compile the bytecode manipulation code
- Phase process-classes – exec-maven-plugin executes the compiled Javassist instrumenter to modify the unpacked classes
- Phase test – run tests on the instrumented code
- Phase package – let maven-jar re-package the instrumented classes, excluding the instrumenter itself
Read the rest of this entry »
Posted in Languages, Tools | Tagged: AOP, java, Javassist, Maven | 2 Comments »
Posted by Jakub Holý on October 6, 2011
If you need to rename the Java package of a 3rd party library, e.g. to include it directly in your project while avoiding possible conflicts, you can use one of the following Maven plugins (and they may be more) in the package lifecycle phase:
- Uberize plugin (latest – org.fusesource.mvnplugins:maven-uberize-plugin:1.20) – originally inspired by the Shade plugin, intended to overcome some of its limitations. Intended primarily to merge your code and dependencies into one jar.
- Shade plugin
- package-rename-task, Ant-based Maven plugin – I’m not sure whether this is further maintained
Posted in Languages, Tools | Tagged: java, Maven | 1 Comment »
Posted by Jakub Holý on October 2, 2011
It’s pretty useful to have the ability to eperiment interactively with some API using the (desktop) Groovy Console. If the API is in a Maven project, just add dependency on Groovy to your pom.xml:
And execute the console from the project’s folder using the exec plugin:
mvn exec:java -Dexec.mainClass="groovy.ui.Console"
Posted in Tools | Tagged: groovy, Maven, productivity | Comments Off
Posted by Jakub Holý on January 26, 2011
It’s possible to use Apache Ivy with dependencies defined in pom.xml instead of its native ivy.xml but you will need to apply some workarounds and you’re loosing access to some functionality that you might (or might not) need.
The problem is that in a POM you can provide only a subset of settings available in ivy.xml and that Ivy understands only a subset of POM’s syntax. Read the rest of this entry »
Posted in Tools | Tagged: ivy, Maven | Comments Off
Posted by Jakub Holý on November 30, 2010
This month has been quite interesting, among others I ‘ve picked up several blogs by Adam Bien. I really like his brief, practical and insightful posts :-)
Java, Jave EE, architecture etc.
- EJB 3.1 + Hessian = (Almost) Perfect Binary Remoting – “With hessian it is very easy to expose existing Java-interfaces with almost no overhead. Hessian is also extremely (better than IIOP and far better than SOAP) fast and scalable.” See also the discussion regarding a “DynamicHessianServlet” (which would be more comfortable then creating a new servlet for each service).
- Binary XML – Fast Infoset performance results – FI is the name of a standard for binary XML encoding and also of its OSS implementation; according to these measurements (with default settings, compared to Xerces 2.7.1), on average: The FI SAX parser is about 5 times faster than the Xerces SAX parser, the FI DOM serializer (using default settings) is 25% to 30% faster than the Xerces DOM XMLSerializer, and FI documents are 40% to 60% smaller than XML documents (i.e. it can provide modest to good compression). And: “The use of external vocabularies can be a very effective way to increase the efficiency of parsing, serializing and size at the expense of the fast infoset documents no longer being self-describing … .”
For the interested ones: FI is built on ASN.1, a standard for describing data structures in a way that is independent of machine architecture and implementation language, it also includes a selection on different binary encoding rules, e.g. DER (triplets tag id – length – value).
- EJB 3.1 And REST – The Lightweight Hybrid – Why to use @Stateless – there have been recently discussion about Spring vs. EJB and whether @Stateless is of any use. According to this article, the added value of EJB (though some are provided also by Spring) include injection capabilities, transactions, single threading model (for why that is good see #2 on Why I like EJB 3.0/3.1), visibility in JMX, concurrency restriction via thread/bean pools.
- Why Service Isn’t A ServiceFacade, But ServiceFacade Is Sometimes A Service…
- Experiences from migrating Hyperic 4.5 from EJB/JBoss to Spring/Tomcat, what good has it brought – simplified unit and integration tests, simplified code thanks to Jdbc/JmsTemplate, … (My comment: EJB 3.1 would certainly bring at least some of the advantages too.)
Performance – large JVM heaps are very much feasible
- Tuning the IBM JVM for large heaps – tuning 64b IBM JVM 6 with 100GB heap to have acceptable GC times (~ 1/2s as opposed to 25s with the default settings)
- BigMemory: Heap Envy – there have been recently a lot of fuss about Terracotta’s new BigMemory, a GC-resistent many GB cache space (using NIO byte buffer). This post discusses it’s disadvantages and compares it with a solution based on ConcurrentHashMap, comming to the conclusion that the old good ConcurrentHashMap outperforms BigMemory considerably.
Posted in j2ee, Languages, Top links of month | Tagged: java, javaEE, jvm, Maven, performance, spring, tdd, xml | Comments Off
Posted by Jakub Holý on October 31, 2010
Few of my favourite themes this month – TDD, performance, build tools/Maven. Plus a usefel JS library, news from the Java community x Oracle world etc.
- About dying JCP and too silent Oracle (or mostly silent) – a summary of the latest issues and hot topics in the Java community that cause lot of rumor but still no reaction from Oracle including the criticism of JCP and its proclaimed decline. Update 11/1: The article about IBM, Oracle and OpenJDK has links to many related resources and a section on JCP future.
- A fair evaluation of TDD – Test driven development at Transloadit (“honest assessment of the beauty and pain of tdd” – Kent Beck) – according to the author, TDD requires a lot of discipline and is a pain to do but it really pays off if your risks are high, basically it’s something like an insurance – there are people living without it but to some it can save life. I miss there a thing I find essential about good test coverage – namely that it forces you to write a better code (more modular, following the single responsibility principle etc.).
- Why Hibernate 4 switches to Gradle instead of Maven 3 – “a means to describe the issues and frustrations I have seen in my 2.5+ years of using Maven for Hibernate builds; in many cases the cause is simply an assumption or concept in Maven itself which did not line up cleanly with how I wanted to do build stuff in Hibernate.” The main issues were that Hibernate is a very specific project, which doesn’t line up very well with the Maven philosophy and, at the same time, Maven is very strict at forcing it and not really flexible to accommodate to unusual needs (and if Maven is, its plugin often aren’t). For example Hibernate is composed of modules that depend on each other while Maven really supports only an aggregation of independent projects. Also, “the release plugin is completely worthless”. On the other hand, Gradle is very flexible and – among others – offers powerful scripting, doesn’t enforce its way of doing things at all cost (i.e. directory structure), let you also define dependencies on tasks, modules, directories, etc.
- String Concatenation Performance vs. String Builder/Buffer and how Liferay 6 achieved a speedup by not using S.B. [that much] – StringBuilder/Buffer has lot of overhead and thus String.concat or custom code can be faster sometimes. Also see the linked ticket, esp. the comment ‘most javac will try to translate “+” to StringBuilder whenever possible. So if you do need to use String.concate(), you’d better use it explicitly.’
- Paul Graham – Beating the Averages – why it’s good to learn Lisp. (Because it makes you able to see the limitations of you current language as it’s most likely superior to it – among others thanks to Lisp macros.) A really good essay on the power of programming languages, which has persuaded me about some year ago, when I’ve originally read it, to learn Clojure (a modern Lisp dialect running on the JVM).