Java magazine july/august 2012


Published on

Matéria falando sobre o poder do desenvolvedor, o grande número de frameworks e ferramentas para o desenvolvimento java.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Java magazine july/august 2012

  1. 1. CHOOSE YOUR TO OL 01 02 03 04 05 06 COMMUNITY 01 BUILD AUTOMATION TOOLS 02 CONTINUOUS INTEGRATION TOOLS JAVA IN ACTION DEVELOPER 03 OPEN SOURCE MODULES 04 SOFT WARE CONFIG MANAGEMENT 05 REPOSITORY MANAGEMENT 06 RUNTIME ANALYSIS JAVA TECH POWER With a bevy of Web-based development tools available, it’s a great time to be a Java developer. BY STEVE MELOAN ABOUT US WITH CONTRIBUTIONS BY JANICE J. HEISS odern era agile software develop- source modules and frameworks obtained in discusses many of the tools available today; ment is predicated upon iterative, a sometimes unregulated and undocumented however, this is by no means a complete, incremental development processes, fashion across the internet. definitive list. You may have other favorites with continuous integration (CI) of fixes and Fortunately, a rich stack of tool offerings that are not included; let us know. blog M enhancements. With the need for such CI enables development teams to more effec-, among other things, provides a comes the complexity of managing geographi- tively track, build, integrate, and manage soft- delivery channel for some of the technologies cally distributed teams that are utilizing open ware projects and their modules. This article described in the following pages. PHOTOGRAPHY BY BOB ADLER 34ORACLE.COM/JAVAMAGAZINE ////////////////////////////////////////// JULY/AUGUST 2012
  2. 2. CHOOSE YOUR TO OL E X PER T OPINION 01 02 03 04 05 06 “For me, the real difference “I find Apache Ant is between tools that have (Another Neat Tool) very a point of view about how COMMUNITY useful for automating the development processes 01 BUILD AUTOMATION TOOLS build process. I especially should work and those that don’t. I call appreciate its use of XML, which facilitates these two types ‘tools and metatools.’ build-script creation, and the JUnit task, A build automation tool ideally provides Maven is a build tool, because it essentially Apache Ant. which facilitates integration of JUnit test- forces you to adapt to the Maven lifecycle the ability to build a given project with a single command, mobilizing all the Ant/Ivy 101 Similar to the ing into the process.” and way of doing things. Ant doesn’t come decades-old —Jeff Friesen, with such a point of view—instead, you modules, artifacts, libraries, and code UNIX Make in some respects, Apache Ant Freelance Developer and Educator have to build up targets and a sequence necessary to that project. is written in Java and is best suited to JAVA IN ACTION based on your own project lifecycle. Some Apache Maven. Hosted by the Apache building Java projects. It uses an XML file teams prefer the additional structure which Software Foundation and written in Java, (build.xml) to define a given build process “I love using Maven in large comes with a tool like Maven, whereas other Maven can be used to build projects in and its dependencies. Within the build file, organizations—where many teams object to having to fit in with the Java, as well as C#, Ruby, Scala, and other Ant can also delegate build work to either developers are working on demands of the Maven lifecycle.” languages. It operates from an XML file, native or Java-based external programs. multiple projects. Some very —Ben Evans, Coauthor, but uses a very different paradigm from One of Ant’s primary goals was to solve deep thought about the software project The Well-Grounded Java Developer Ant. Rather than simply chaining together the portability issues of Make, where dif- JAVA TECH lifecycle has gone into Maven over the years, sequential build tasks, as occurs with ferent platforms required different script and its strict standards approach works bril- commands. Ant provides built-in func- Ant, Maven defines a project in terms of liantly where chaos can potentially abound. “Identifying and download- tionality designed to behave the same on its dependencies, external modules and It doesn’t matter which project developers ing the correct versions of a all platforms. It has limited fault-handling components, build order, directories, and join. A Maven mvn clean install command Java project’s dependent JAR capabilities and no persistence of state, so builds, tests, packages, and installs a local required plug-ins. Maven projects are files, which may have been it is primarily useful only for classic build copy of the application for them, letting defined via a Project Object Model (POM) obtained from a variety of online sources, is and test processes. them get started with their coding. file (pom.xml). Maven dynamically down- a thankless and often error-prone activity. ABOUT US Ant is supported by most major IDEs, Having good build and CI processes in Maven takes care of this for you, and effec- loads Java libraries and Maven plug-ins including Eclipse, IntelliJ, JBuilder, place means that you can write code more tively structures your project so as to elimi- from either the Maven Central repository JDeveloper, NetBeans, and WebSphere. quickly and maintain a higher bar of qual- nate a host of setup and configuration issues. or other defined software repositories. Apache Ivy. Written in Java, Apache Ivy ity. In conjunction with TDD [test-driven Maven provides plug-ins that encourage and Larger Maven projects are typically is a subproject of the Apache Ant project, development], build and CI means you can promote good standard software practices— divided into several subprojects, each serving as a transitive relation depen- rapidly refactor without fear! Think of it as including unit testing, version control, and with its own POM file, but with a root dency manager. An XML file defines having a mentor looking over your shoulder— standardized release processes. POM to compile the master project via project dependencies and the resources providing a safe and controlled environment A controlled process like Maven’s makes a single command. The Maven plug-in necessary to build the given project. in which you can quickly code and make development within a team far more effi- architecture allows it to interface with Ivy resolves and downloads required bold changes.” cient and scalable. And the documentation resources from the specified repositories. build tools for other languages, including —Martijn Verburg, Coauthor, and site reports add to Maven’s value as Whereas Maven is a complete build tool, the .NET framework and C/C++. Popular The Well-Grounded Java Developer a full-featured project management and with built-in dependency management, IDEs that support development with comprehension tool.” Maven include Eclipse, IntelliJ, JBuilder, Ivy focuses specifically on dependency blog —Cas Saternos, Oracle Certified DBA and management functionality, working in JDeveloper, and NetBeans. Sun Certified Java Programmer partnership with Ant. Gradle. Written in Java and Groovy, Gradle builds upon the concepts of Ant and Maven but uses a Groovy-based Domain- 35ORACLE.COM/JAVAMAGAZINE ////////////////////////////////////////// JULY/AUGUST 2012
  3. 3. CHOOSE YOUR TO OL 01 02 03 04 05 06 E X PER T OPINION “Hudson/Jenkins are CI “Combining smart features COMMUNITY Specific Language (DSL) rather than XML. ligently determines which part of a build tools, so the first thing that of both Ant and Maven, Gradle uses a directed acyclic graph (DAG) tree is current, so that already up-to-date comes to mind is that they and being powered by to determine the order in which build dependent branches needn’t be rebuilt. ‘execute tests.’ Correct. But Groovy, Gradle provides tasks should be run. Gradle’s DSL is exten- Gradle offers support and transitive they do so much more. With the proper set a new and powerful way to handle your sible, allowing for the addition of new dependency management for existing of plug-ins—such as test coverage and delivery pipelines.” language elements or the enhancement Maven and Ivy repositories and also pro- static analysis—they provide everyone in the —Michael Hüttermann, Java Champion of existing elements. Intended to manage vides a converter to translate Maven POM development team with a highly valuable large, multiproject builds, Gradle intel- files into Gradle scripts. information center on the health of the proj- JAVA IN ACTION ect. Developers can autonomously verify the “Having been a Java devel- quality of the code they are writing, and proj- oper since nearly the begin- ect leaders can keep everything under con- ning (summer of ’95), I have 02 CONTINUOUS INTEGRATION TOOLS trol, monitoring both the progress and the a collection of open source technical debt. The best of Hudson/Jenkins projects that I either founded or still main- happens with Maven-based projects, thanks tain. As a full-time researcher, and also a When properly implemented, CI requires and monitoring the results of externally to Maven profiles. This combination makes new father, I need a system to reliably man- that each commit of new software be run jobs (such as cron jobs), including JAVA TECH it easier to build on multiple configurations— age these projects and push out releases. accompanied by a complete build and those that execute on remote machines. such as JDKs and databases. In addition, That’s what Hudson is to me. I’ve been run, and that it pass all defined unit tests. Results can be monitored via e-mail or Maven can warn you about whether the using it for several years now and continue With the advent of CI tools, this change RSS, and third-party plug-ins offer addi- library versions you’re using will break your to love it—it just works.” in commit functionality has increasingly tional extensible functionality. build due to a regression.” —Josh Marinacci, Java Champion become highly sophisticated and auto- Hudson is written in Java, and runs in a —Fabrizio Giudici, mated. CI tools include CruiseControl, Servlet container (such as Apache Tomcat Senior Java Architect, Tidalwave Hudson, Jenkins, Bamboo, BuildMaster, or GlassFish). It can execute Ant- and ABOUT US “Jenkins is an awesome tool AnthillPro, and Teamcity. Maven-based projects as well as simple for continuous integration. The big-picture goal of such CI tools is shell scripts and Microsoft Windows batch “My metatool of choice is With it, you can combine all to wrap configurable intelligence (that commands, and can distribute build/ NetBeans, Java EE Edition. the work of a team with less can be extended with plug-ins) around test loads to multiple computers, as well It integrates Maven 3; error and more quality/productivity—while the process of version control, builds, as keep track of which builds produced JUnit; Ant; Hudson/ monitoring status and the number of tests. testing, and reporting of results. Below is which JARs. Plug-ins provide integration Jenkins; and countless Java EE hints, wiz- And, yes, you can use JUnit! There are a sampling of popular CI tools, including with most version control systems and ards, and extensions. You get an extremely almost too many available plug-ins—for two recent winners of the Duke’s Choice bug databases and can add new func- productive environment with a single click— example, Sonar, which verifies the quality of no plug-in fiddling required.” Award, Hudson and Jenkins. tionality or even change the appearance your team’s code, test coverage, duplication —Adam Bien, Java Champion Hudson. Winner of the 2008 Duke’s of Hudson. Meanwhile, build test reports of code, and so on.” —Otávio Gonçalves de Santana, Choice Award in the Developer Solutions can be generated in a variety of formats JUG Leader, Java Bahia category, Hudson is a popular alterna- (JUnit is supported out of the box). tive to CruiseControl. Hudson provides Oracle continues to develop Hudson blog an easy-to-use, GUI-based configurable along with the community at large. But system for integrating changes to a in January 2011, a fork of the project was project—obtaining explicit fresh builds created and named Jenkins. of the project, scheduling future builds, Jenkins. Originally begun as the Hudson 36ORACLE.COM/JAVAMAGAZINE ////////////////////////////////////////// JULY/AUGUST 2012
  4. 4. CHOOSE YOUR TO OL 01 02 03 04 05 06 CI tool, the Jenkins project was created in as Ant and Maven, as well as a standard COMMUNITY January 2011. Both Hudson and Jenkins exec builder; and ports of CruiseControl OPEN SOURCE MODULES consider the other to be a fork, with sepa- for .NET (CruiseControl.NET) and Ruby 03 rate development branches. (CruiseControl.rb). Winner of the 2008 Duke’s Choice ToolsCloud. Almost in a conceptual cat- Because modern software development tively locate and process the information. Award (as Hudson) in the Developer egory by itself, ToolsCloud is effectively involves geographically distributed teams In the case of a typical Maven reposi- Solutions category, Jenkins provides an a hybrid cloud-based IDE that includes that use diverse open source modules tory, the binary artifact is a JAR file, but it easy-to-use, GUI-based configurable project management, CI functionality and frameworks acquired from across could just as easily be a Flash library or system for integrating changes to a (including build automation and auto- the internet, projects can run consider- a Ruby library. When a Maven POM file JAVA IN ACTION project, obtaining explicit fresh builds mated testing), metrics and analysis, able security, consistency, and reliability lists a project dependency that includes of a project, scheduling future builds, and a broad array of development tools. risks. According to a survey conducted by a repository-based entry, it downloads and monitoring the results of externally Available via a monthly subscription plan, Sonatype, more than 80 percent of typi- that entry’s POM, and then downloads run jobs (such as cron jobs), including and hosted on Amazon Elastic Compute cal software applications consist of open any libraries or modules required by that those that execute on remote machines. Cloud (EC2), ToolsCloud includes Git source components and frameworks. Yet dependency. This ability to determine Results can be monitored via e-mail or (software configuration management), many studies find a staggering use of vul- a project’s dependencies and transitive RSS, and third-party plug-ins offer addi- Redmine (project management and bug- nerable, insecure, and nondocumented dependencies is made possible by the JAVA TECH tional extensible functionality. tracking tool), Nexus (artifact manage- open source offerings. Sonatype finds standards and structure of the repository. Jenkins is written in Java, and runs ment), Hudson/Jenkins (CI), and more. that only 32 percent of teams maintain a Sonatype/Central repository. The default in a Servlet container (such as Tomcat ToolsCloud features a management detailed “bill of materials” record of the configuration of Maven retrieves soft- or GlassFish). It can execute Ant- and calendar and tracking, reporting, and sta- open source components in their devel- ware artifacts from the Central reposi- Maven-based projects as well as simple tistics tools as well as metrics history and opment stack. The survey also revealed tory, a public facility that is stewarded shell scripts and Windows batch com- analysis tools. It easily integrates with that only 50 percent of developers report by Sonatype. Central reportedly receives mands, and can distribute build/test your IDE of choice. that their company has an open source four billion requests per year, contains ABOUT US loads to multiple computers, as well software policy. 300,000 components, and is accessed as keep track of which builds produced Code/artifact repository. In order to deal by 60,000 development organizations which JARs. Plug-ins provide integration E X PER T OPINION with an ever growing and ever more com- worldwide. The average enterprise report- with most version control systems and plex open source ecosystem, enterprises edly downloads more than 1,000 unique bug databases and can add new func- “Using Jenkins is like are increasingly turning to code reposito- components from Central each month. tionality or even change the appearance having an extra member ries and cached repository management Repositories such as Central and tools of Jenkins. Meanwhile, build test reports in your development team. systems—establishing a centralized, such as Maven typically use a Group, It relentlessly builds and can be generated in a variety of formats secure, and managed code repository for Artifact, Version (GAV) “coordinate” sys- tests your software, preventing mistakes (JUnit is supported out of the box). the artifacts required to build and main- tem as a means of storing and locating and freeing up time so that your team can CruiseControl. Written in Java, focus on simply producing great software.” tain projects. a given artifact: CruiseControl provides an extensible —Juliano Viana, A code repository establishes a platform groupID/artifactID/version/. framework for custom CI processing. Its Founder and CTO of LogicStyle for the storage, retrieval, and manage- For example, components produced by features include a Web interface to moni- ment of the binary software artifacts and the Maven project at the Apache Software blog tor current and past builds; plug-ins for a metadata necessary for a given project or Foundation would be stored/located variety of source controls, build technolo- application. The information is archived under a groupID of org.apache.maven. gies, and notification schemes; interfaces and organized in such a way that build An artifactID is the identifier for a given for popular build automation tools such tools such as Maven or Ant/Ivy can effec- component. The combination of groupID 37ORACLE.COM/JAVAMAGAZINE ////////////////////////////////////////// JULY/AUGUST 2012
  5. 5. CHOOSE YOUR TO OL 01 02 03 04 05 06 and artifactID uniquely identifies a given While Maven can be configured to COMMUNITY project, and the version identifier speci- retrieve software artifacts directly from fies the version of the project, while the one of the many Central mirror sites 05 REPOSITORY MANAGEMENT packaging identifier specifies the binary around the world (or any external reposi- software format. tory), an increasingly popular option that A repository management system offers Nexus offers cached components for Once an artifact is assigned a release is faster, more secure, and more eas- a locally cached proxy between develop- quick download, ensures that all users number on Central, the file contents ily managed is to employ a repository ment teams and external repositories. It access the same modules, enables secure cannot be altered. The Central repository manager as a locally controlled proxy to speeds download times, ensures man- and controllable deployment of internally also contains cryptographic hashes and Central and other artifact repositories aged and configurable access to both developed components, and provides JAVA IN ACTION PGP signatures that can be used to verify (such as those provided by Oracle, Red external artifacts and internally cre- configurable, partner-specific access. artifact authenticity and integrity. Hat, and Codehaus). ated modules, and provides tagged and Meanwhile, user-defined metadata offers searchable metadata. rich and customizable search capabilities. Sonatype Nexus. Nexus is a managed, JFrog Artifactory. Winner of the 2011 central point of access for external repos- Duke’s Choice Award for Innovative Tool 04 SOFTWARE CONFIG MANAGEMENT itories, offering configurable permissions for Developers, JFrog Artifactory is a Java- and customizable/searchable user- based binary file repository management JAVA TECH Software configuration management trol and SCM system, suitable to handle defined metadata. Figure 1 depicts how tool, with a free open source version, a (SCM) entails rigorously controlling both large and small development proj- a repository manager fits into a typical paid Pro version, and a software-as- and tracking changes made to soft- ects. GitHub provides a collaborative, development process. a-service (SaaS) cloud-based version ware, and includes a subfunctionality Web-based facility to manage both public Nexus provides a centralized point for (Artifactory Online). Figure 2 shows how of revision control (version handling). and private Git repositories. Written managed access of open source software Artifactory acts as a proxy between your Development tools such as Hudson and using Ruby on Rails, GitHub is the most components and their dependencies, Maven client and the outside world. Jenkins (explored earlier) offer support popular Git hosting site, providing social serving as a configurable proxy between JFrog Artifactory serves as a proxy ABOUT US for a variety of such SCM tools, including networking functionality and usage data organizational and public repositories. between build tools such as Maven, Ant, Clearcase, CVS, Git, and Subversion. specifically directed toward collaborative Git. Git offers a distributed revision con- development. Developer Teams Central Repository E X PER T OPINION “Artifactory is a great “Nexus is a rock-solid vault choice for DevOps. Its for your binaries, tailor- integration with Jenkins made for a Maven-based offers full traceability build process.” across builds, links back to tickets, and Nexus OS allows comfortable build promotions. Easy Build/CI —John Ferguson Smart, Systems CEO, Wakaleo Consulting configuration, openness, and extensibility make Jenkins a central service hub and a smart backbone of your continuous deliv- blog ery and DevOps infrastructure.” —Michael Hüttermann, Java Champion Figure 1 38ORACLE.COM/JAVAMAGAZINE ////////////////////////////////////////// JULY/AUGUST 2012
  6. 6. CHOOSE YOUR TO OL 01 02 03 04 05 06 Ivy, Gradle, and so on—providing local, E X PER T OPINION COMMUNITY fast-access caching of remote artifacts, RUNTIME ANALYSIS offering configurable management of 06 “VisualVM is a tool that repository access permissions and every Java developer customizable/searchable user-defined While not explicitly directed at collabora- Innovation Award for Most Innovative should become familiar metadata. Artifactory is built on top of tive software development/management, Java Technology. At JavaOne 2011, JRebel with. It comes as part the Java Content Repository (JCR), pack- runtime analysis tools offer an essential was awarded the Duke’s Choice Award of every modern Java SDK and enables aged as a standard Java EE Web applica- debugging/tuning window into applica- for Innovative Compiler for Java Code. developers to visualize the internals of tion, and deployable into any standard tions during actual execution and are, Java-based and usable on any operat- their applications as they run, helping diagnose even the most-difficult per- JAVA IN ACTION Servlet container (Tomcat, WebSphere, therefore, an often-used tool class in the ing system that supports Java, JRebel is formance problems. And the integration JBoss, GlassFish, and so on.) development lifecycle. IDE agnostic and designed for integra- with BTrace means that you can perform The Jenkins CI Artifactory Online VisualVM. VisualVM provides an intuitive, tion with various Java EE standards and complex inspections on running produc- repository service—a Jenkins/JFrog graphical interface that allows developers Java application servers. It is freely avail- tion systems, without affecting end-user collaboration offering a cloud-based to monitor and troubleshoot executing able to open source software projects experience.” Artifactory repository solution developed Java applications. While VisualVM itself and developers using Scala. It supports —Juliano Viana, specifically for the Jenkins community— requires JDK 6 to run, it can monitor any immediately visible code changes with- Founder and CTO of LogicStyle JAVA TECH was announced at the April 2012 Jenkins application running at JDK 1.4.2 or greater. out redeploying; handles changes to class User Conference in Paris, France. Utilizing such technologies as jvmstat, structures, frameworks, and Java EE; and Java Management Extensions (JMX), the supports all major Java application serv- Serviceability Agent (SA), and the Attach ers, IDEs, and frameworks. It eliminates “I think VisualVM is underrated by many Java Maven Clients API, VisualVM displays both local and memory leaks and build time during developers. Not only does remote applications, offering visual data development and supports Apache Ant it enable you to monitor on CPU usage, Garbage Collection (GC) and Apache Maven. </article> memory consumption and threads, it’s ABOUT US activity, heap and permanent generation invaluable when it comes to memory memory, loaded classes, running threads, analysis. With this tool, I’ve easily found and more. VisualVM also allows for offline Steve Meloan is a former C/UNIX software the causes of a number of memory leaks analysis of core dumps, as well as analy- developer who has covered the Web and in customer projects.” the internet for such publications as Wired, sis of taken thread dumps, heap dumps, —Fabrizio Giudici, Rolling Stone, Playboy, SF Weekly, and the and profiler snapshots. And because San Francisco Examiner. He recently published Senior Java Architect, Tidalwave Artifactory VisualVM is built on the NetBeans plat- a science-adventure novel, The Shroud, and form, it is readily extensible with plug-ins regularly contributes to The Huffington Post. Remote (available at the VisualVM Plugin Center). Repositories Finally, VisualVM can be integrated with Janice J. Heiss is the Java acquisitions editor at such IDEs as Eclipse and NetBeans. Oracle and a technology editor at Java Magazine. JRebel. Developed by Jevgeni Kabanov and Toomas Römer of ZeroTurnaround, blog JRebel is a plug-in for the Java Virtual Machine (JVM) that enables instant reloading of changes made to a Java Figure 2 class file. In 2011, JRebel won the JAX 39ORACLE.COM/JAVAMAGAZINE ////////////////////////////////////////// JULY/AUGUST 2012