Hiển thị các bài đăng có nhãn Gradle. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Gradle. Hiển thị tất cả bài đăng

Thứ Hai, 4 tháng 6, 2012

Recent Software Development Posts of Interest - Early June 2012

There has recently been a large number of posts on some of my favorite topics and I summarize and reference a few of them here.

Why Developers Should Blog

I devoted a post to why I believe more software developers should write blogs. Ron Gross's post Why you should write a blog post today provides five reasons to write technical blog posts and contrasts blogs to other social media to demonstrate technical memento advantages of blogs.

NetBeans 7.2 Search Capability

There has been significant coverage of NetBeans 7.2 beta in recent weeks. Much of the focus has been on its improved performance, its greater helpfulness and its TestNG support. Geertjan Wielenga focuses on improved searching capability in NetBeans 7.2 beta in his post Beefed Up Code Navigation Tools in NetBeans IDE 7.2.

Running Common Java Development Tools with Ant

Modern Java IDEs often make it easy to integrate Java tools. An example is the NetBeans SQE plugin. However, not all Java development and execution necessarily occurs in the IDE. In addition, some projects may use more than one IDE. In such cases, command-line approaches have their advantages. These can be even easier to use when run as Ant targets. The post How to run Findbugs, Pmd, Checkstyle, JUnit and Cobertrua with an Ant Build-Script? covers using Ant to run popular Java development tools FindBugs, PMD, Checkstyle, JUnit, and Cobertura.

Upgrading Gradle

I think that Gradle has a lot of potential for being a very popular build tool if it can gain enough early traction. The post Upgrading Gradle demonstrates how easy it is to upgrade one's Gradle installation ("It’s basically the same as upgrading ant.").

SVG, FXML, and NetBeans

The post SVG to FXML using NetBeans comprehensively covers issues related to transforming SVG to FXML and ends with a link to another post showing how to use NetBeans to demonstrate the transformation.

Conclusion

There have been numerous posts in recent weeks on some of my favorite topics: NetBeans, blogging, Gradle, and JavaFX. This post has referenced a sample of these posts.

Thứ Bảy, 24 tháng 3, 2012

Software Development Posts of Interest - March 2012

This post references some of the recent blog posts and articles that have interested me. Topics include Java-specific topics such as Java EE, JavaFX, Scala, and Gradle as well as more general software development topics such as software patents and open source.

Why Software Patents are Evil

Simon Phipps summarizes in Why software patents are evil why patents in software may not make sense:

Patents may work in other industries, where the cost of innovation is so high that a temporary, state-sanctioned monopoly provides just enough time to gain a return on the investment. But that investment-return ratio has a completely different value for software. It turns out that software patents have little bearing on encouraging innovation. ... Software patents are ... bad news for most innovators in the software industry.

Phipps also looks at the relationship between software patents and open source software. He writes, "The problem is that open source software is defenseless against the anticompetitive abuse of patents."

Java EE 6 Versus Spring Framework

In the post Why is Java EE 6 better than Spring? Arun Gupta discusses why he believes developers should use Java EE 6 rather than the Spring Framework. Gupta begins the post by referencing several similar blog posts including Java EE wins over Spring and Why I will use Java EE (JEE, and not J2EE) instead of Spring in new Enterprise Java Projects in 2012.

Some of the feedback comments on this post are interesting because they demonstrate the differences of opinions between Java EE evangelists and Spring Framework evangelists (with comments from employees of both Oracle and SpringSource/VMWare among them). It is interesting to see the role reversal in this situation. Evangelists of the Spring Framework (even before it was so named) helped convince the Java enterprise development community of the problems with early J2EE, but now it seems the tables have turned and similar evangelism is advertising the "legacy" nature of Spring Framework as compared to modern Java EE.

Java EE 6 vs Spring - let's get ready to rumble provides another look at this post.

Oracle's Long-Term Intentions for Java

Paul Krill's Oracle lays out long-range Java intentions summarizes the "Oracle slide presentation entitled 'To Java SE 8 and Beyond!' posted on the QCon conference website." Based on Krill's summary, this presentation sounds very similar to the Oracle OpenWorld 2011 presentation From Java SE, 2012, to Java 12: Java SE Roadmap.

Reducing Memory Usage and Garbage Collections with -XX:+UseCompressedOops

Stuart Leneghan's post Reducing Java Memory Usage and Garbage Collections with the UseCompressedOops VM Option looks at the author's observation of the -XX:+UseCompressedOops HotSpot-specific JVM option "[reducing] the memory usage of the application by 14% and the number of garbage collections by 24%."

More on Java Tuning

Speaking of Java performance and memory tuning, Rupesh Ramachandran's post Java Tuning in a Nutshell - Part 1 provides a "JVM tuning cheat sheet" and categorizes JVM options into four categories: garbage collection, heap tuning, logging, and other performance.

The IBM DeveloperWorks article From Java code to Java heap is fairly comprehensive, providing background details on JVM memory handling and a focus on the impact of different Java collections on memory. This article also references the HotSpot option -XX:+UseCompressedOops as well as the similar IBM JVM option -Xcompressedrefs.

Understanding Garbage Collection is another recently-posted resource. This post is "the first of a series of 'Become a Java GC Expert' articles" and its focus is on introducing garbage collection in Java. The same site also hosts the blog post How to Analyze Java Thread Dumps. Figure Out Why Java is Eating CPU provides an interesting tip.

Scala

There continues to be a profusion of Scala posts. Recent posts include How Scala Can Improve Your Life, Is Scala making the right steps forward?, Scala creator Martin Odersky fends off critics of Scala's roadmap, Free online books for learning Scala, and Scala: Sink or Swim? Part 1. I have also seen new references to Twitter's Effective Scala.

Unit Testing

Neil Buesing's post How to Mock Final Classes in Unit Tests examines the problem that "both Mockito and EasyMock cannot mock classes (or methods) that are final." The feedback comments are also informative and discuss other available solutions to this issue: PowerMock), Groovy-based gMock, and JMockit.

Improved Java Stack Trace Presentation

Tomasz Nurkiewicz has posted two blog posts on how to improve Java stack trace experience using the Logback Project. Filtering irrelevant stack trace lines in logs demonstrates his "proof-of-concept" for filtering out selected stack trace frames using Logback and references the StackOverflow thread Cleaning noise out of Java stack traces. An older post, Logging exceptions root cause first, discusses a feature he contributed to Logback for displaying exceptions with root cause first rather than last.

A Peek at NetBeans 7.2

Geertjan Wielenga's NetBeans Java Hints: Quick & Dirty Guide provides a peek at a capability coming in NetBeans 7.2 for creating NetBeans hints.

Gradle

Last milestone for Gradle as it prepares for first major version cites the Gradle roadmap and states that the current version of Gradle ("1.0-milestone-9, released on 13th March 2012") "will be the final one" before Gradle goes into release candidate.

GroovyFX and JavaFX

Gradle is not the only product in the Groovy ecosystem with recent version advancement news. Dean Iverson has announced the GroovyFX First Official Release. He also shows how to use Grape to "grab" GroovyFX similar to the approach shown in my post Easy Groovy Logger Injection and Log Guarding.

Other interesting recent posts related to JavaFX include Example CSS Stylying in JavaFX, New in JavaFX 2.1: ComboBox, and Packaging JavaFX Applications as Native Installers.

Groovy and DevOps

In the post Groovy, A Reasonable JVM Language for DevOps, Geoffrey Papilion writes that Groovy provides the "JVM glue" he sought for "a simple JVM language that allows me to use any native object." After demonstrating use of Groovy for a "quick script to get data from JMX into ganglia fromSsolr," he concludes

So, if you're working in a Java with a bunch of Java apps, think about giving Groovy a chance for writing some of your monitoring tests, and metric collectors. It is a simpler language than Java to put together those little applications that can tell you how your system is performing, and well within the reach of your average DevOps engineer.
DNS for Software Developers

Doug Rathbone's post DevOps DNS for Developers – Now There’s No Excuse Not To Know is intended to help software developers become more familiar with the basics of DNS. This does seem like the sort of article one would except to be associated with the DevOps movement.

The Big Three JVM Languages

The Big Three – Scala, Clojure and Groovy is a blog post with observations about Groovy, Scala, and Clojure seeming to be the most popular JVM languages among Java developers based on two polls (Which alternate JVM language do you prefer? and Which JVM Language Is On Top?). Charles Oliver Nutter has added a feedback comment regarding JRuby being a more popular JVM language when you consider Ruby developers.

Java 7 WatchService

The post What’s New in Java 7: WatchService describes java.nio.file.WatchService and calls the related functionality "one of the more interesting ... new features in Java 7." This is a fairly concise post that quickly introduces the functionality and includes sample code.

Opinions on Rails, Hibernate, Google, JSON's License Agreement, and the Spanish Theory of Management

I started this post with reference to an opinion-oriented post on open source and patents. It seems symmetrically pleasing to close this post with references to other opinion-oriented pieces. Tyler Menezes discusses technical and cultural reasons he won't use Ruby on Rails in the simply titled post I will not learn Rails. James Whittaker provides a articulate and insightful post Why I left Google.

Rob Gordon is "not impressed" with Hibernate 4.1 ease of use. The Dodgy Coder blog ("Never trust a programmer in a suit") includes a post on the "Spanish Theory" of project management.

Brian Fox points out that JSON's license agreement states "The Software shall be used for Good, not Evil." Fox further points out that "compliance is impossible" and that "this isn't even open source." He asserts that "this additional clause adds an unnecessary complication" and I tend to agree. The folks in suits are not comfortable with objective statements in the license agreements.

Conclusion

I have summarized and linked to Java-specific and general software development posts of interest in this blog post. The software development industry continues to be ever-changing and full of news.

Thứ Năm, 8 tháng 12, 2011

Recent Software Development Posts of Interest - Early December 2011

I have run into several software development blog posts over recent weeks that I think are worth reading or keeping links to for future reference. I collect some of these in this post.

An apt Ending

In Java 8 news, Joseph D. Darcy's post An apt ending draws nigh reports that "after being deprecated in JDK 7, the apt command line tool and the entirely of its associated API is on track to be removed from JDK 8 within the next few months." I wrote about the apt tool in a Java SE 6 context in the article Better JPA, Better JAXB, and Better Annotations Processing with Java SE 6.

Devops

I'm still somewhat skeptical of the concept of devops (not the issues the movement is trying to resolve, but rather the movement itself and what it actually is and involves), but I also realize that I still understand very little about it. Neil McAllister is critical of the devops movement in the post Devops: IT's latest paper tiger, but I tend to agree with the majority of the sentiments he expresses in the post.

Matthias Marschall's post DevOps is NOT a Job Description states that "The DevOps hype produces some strange effects." Marschall states that DevOps is not about job ads and then goes on to describe what he believes DevOps is about (culture, automation, measurements, and sharing).

Oracle's Top Ten 2011 Java Moves and the Acquisition of Sun

The post Enterprise Applications: Oracle`s Top 10 Java Moves of 2011 outlines "some of the top Java moves Oracle has made in 2011." This is in slideshow format and includes the list and brief description of each item on the list. Some of the items include JDK 7, OpenJDK, JavaFX 2.0, NetBeans, Java EE 7, and Java/HTML 5 integration.

In How Oracle made the Sun deal work: a lesson for CFOs, Elizabeth Heichler quotes Oracle Chairman Jeff Henley describing Oracle's acquisition of Sun as "unequivocally the finest acquisition we've ever done."

Is 15 Years The Half Life of a Software Development Career?

Matt Heusser's post What I learned from Google - You Get Fifteen Years maintains that "your half-life as a worker in corporate America is about age thirty-five." He explains some reasons for this: "Around that time, interviews get tougher. Your obligations make you less open to relocation, the technologies on your resume seem less-current, and your ability find that next gig begins to decrease." Heusser states in this post that more experienced technology workers do have an advantage in that their experience gives them more opportunities to do a wider variety of work.

I have written previously about older software developers in the post My Thoughts on Thoughts on Developer Longevity I thought that Seth made good points in his feedback to that post. He pointed out that many more experienced developers have stopped job hopping and found deep niches to work in.

HTML5 Continues Its Winning Streak

In mid-November, Adobe announced its intent to attempt to give Flex to the Apache Software Foundation. This move, following Adobe's announcement to abandon future versions of the Flash Player for mobile devices, implies what Adone has explicitly stated: "In the long-term, we believe HTML5 will be the best technology for enterprise application development." Of course, Flash is not completely gone and HTML5 is not completely here yet as we're reminded by the post Five Things You Can’t Do With HTML5 (yet).

Gradle Links

I recently wrote that I'm starting to get very interested in Gradle for building Java projects. As I've looked at Gradle a little more closely since my interest started at JavaOne 2011, I have found several useful resources on Gradle that I list here for future reference. It is likely that I'll reference many of these posts again in future posts I write on Gradle, but here they are in one location.

More Groovy

Several recent posts have provided different perspectives on use of Groovy. Neal Ford's Functional thinking: Functional features in Groovy, Part 1 discusses "how some functional programming has already crept into Groovy." Jakub Holý writes about use of Groovy in Java unit testing in his post Only a Masochist Would Write Unit Tests in Java. Be Smarter, Use Groovy (or Scala…). Tim Myer's post Programming with Groovy: Trampoline and Memoize point out that "Trampolining and memoization are two powerful new features in Groovy 1.8, but the combination of the two is not always straightforward." The post describes with descriptive text and code examples how to use these new Groovy 1.8 closure enhancements.

GroovyMag's News Roundup: Links for December 6 features a link to my post Compressing JPG Images with Groovy. There are several other interesting Groovy posts highlighted there as well, including Five Cool Things You Can Do With Groovy Scripts.

Reading List for JVM Developers

Thomas Lockney's post A Reading List for JVM-based Developers provides a "recommended reading list for developers who find themselves working in a JVM-based environment who need to understand the characteristics of that environment, particularly as it pertains to performance and concurrency issues." The list includes books and online sites. Some of the online resources include JSR-133 (Java Memory Model) FAQ and What Every Programmer Should Know About Memory.

"Lesser-known" Java Libraries

The reddit/java thread Nice lesser-known Java libraries provides several developers' opinions on "nice, lighweight and lesser known libraries solving various problems." Some of the referenced libraries include jcommander, FEST-Assert, jsoup, Project Lombok, and Guava. There is also a reference to the presentation Java Boilerplate Busters.

Thứ Bảy, 26 tháng 11, 2011

A First Look at Building Java with Gradle

I left JavaOne 2011 with several take-aways. One of the most significant was a renewed interest in learning more about Gradle. In this post, I look at using Gradle and at migrating a simple Ant build script to Gradle.

Gradle installation is easy. Gradle can be downloaded and unzipped into the desired location. I am using Gradle 1.0 Milestone 6 for examples in this post.

Once Gradle is downloaded and unzipped, the environment variable GRADLE_HOME can be set to the directory of the unzipped Gradle installation and the PATH should be set to $GRADLE_HOME/bin or %GRADLE_HOME%\bin. The Gradle installation page tells us that JVM options used by Gradle can be set via either GRADLE_OPTS or JAVA_OPTS. The Grade installation and configuration in the path can be confirmed by running gradle -v at the command line once the environment variable settings are sourced.

Besides verifying correct configuration of the Gradle installation, the output from running the -v option also reminds us that Gradle is built on (and brings the best of) Groovy (1.8.4), Ant (1.8.2), Ivy (2.2.0), and the Java Virtual Machine to our task execution.

The Gradle Build Script Basics documentation describes the default "build configuration script" (something like an Ant build.xml file) called build.gradle. This same page provides a Hello, World example implementation of such a build configuration script. An adapted version of that example is shown in the next code listing.

build.gradle - Hello Gradle Example

task hello_world {
doLast {
println 'Hello, Gradle!'
}
}

The task (roughly equivalent to an Ant target) is defined above with the name "hello_world" and can be invoked by Gradle the same way an Ant task is invoked by Ant (assuming the default build configuration script file names in both cases): gradle hello_world. The next screen snapshot shows this both with and without the -q (for quiet) option.

An interesting observation I made while playing with even this simple build configuration file is the importance of proper curly brace placement. The initial curly brace on the same line as the task declaration must remain on that line. When I tried to move it down to the next line to line up in the same column as the closing brace, I saw the error in the next screen snapshot and the representative text output that follows the image.

Error Message from Opening Curly Brace on Next Line

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\java\examples\groovyExamples\gradleExample\build.gradle' line: 2

* What went wrong:
Could not compile build file 'C:\java\examples\groovyExamples\gradleExample\build.gradle'.
Cause: startup failed:
build file 'C:\java\examples\groovyExamples\gradleExample\build.gradle': 2: Ambiguous expression could be a parameterless closure expression, an isolated open code block, or it may continue a previous statement;
solution: Add an explicit parameter list, e.g. {it -> ...}, or force it to be treated as an open block by giving it a label, e.g. L:{...}, and also either remove the previous newline, or add an explicit semicolon ';' @ line 2, column 1.
{
^

1 error


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2.636 secs

Fortunately, the above error message is easily avoided by placing the opening curly brace of the Gradle task closure on the same line as the Gradle task's definition.

A default target can be specified in an Ant build.xml via the project element's default attribute. Gradle supports a similar specification of default tasks to be run as shown in the next code snippet which builds upon the previous example. Running this task now does not require specification of the task as shown in the next screen snapshot.

build.gradle - Hello Gradle Example with Defaults

defaultTasks 'hello_world'

task hello_world {
doLast
{
println 'Hello, Gradle!'
}
}

Gradle is intentionally constructed to be flexible and support a wide variety of tasks. For those interested in specific, commonly used tasks, there are Gradle plug-ins available to reduce the need for newly written Grade code. For purposes of this post, the Java plug-in is of particular interest. It is easy to apply this plug-in as shown in the next version of build.gradle which builds upon the previous two examples and adds the application of the Java plug-in.

build.gradle - Hello Gradle Example with Java Plug-in

apply plugin: 'java'

defaultTasks 'hello_world'

task hello_world {
doLast
{
println 'Hello, Gradle!'
}
}

The simple addition of the single line apply plugin: 'java' brings numerous Java-related tasks automatically to this build configuration file. I think that the easiest way to quickly ascertain which tasks are automatically available via the Java plugin is to run gradle tasks against a build configuration file that does not apply the plugin and then run gradle tasks against a build configuration file with the Java plugin applied. Doing just that is shown in the next two screen snapshots. (Note that gradle tasks is similar to Ant's -p option except that Ant requires the target's description attribute to be specified for a target to show up in response to the -p option.)

Comparing these two screen snapshots helps us see which tasks are made available by using the Java plugin in Gradle. Before looking at the Java specific tasks, I think it's also worth noting some other tasks available in Gradle without a plugin (the "Help tasks"). In particular, the images indicate the "tasks" task (one of the "Help tasks") we used to see all available tasks. There are similar built-in "Help tasks" tasks for viewing build properties ("properties"), viewing project dependencies ("dependencies"), viewing sub-projects ("projects"), and viewing help ("help"). Many of these tasks are available via deprecated command-line options as well.

The only other task listed for the build configuration file that did not apply the Java plugin was the custom defined "hello_world" task. However, the build configuration file that added the single line to apply the Java plugin had numerous other tasks besides the custom-provided "hello_world" task and besides the always-available "help tasks." These tasks include the "Build tasks" ("assemble", "build", "buildDependents", "buildNeeded, "classes", "clean", "jar", "testClasses"), "Documentation tasks" ("javadoc"), and the "Verification tasks" ("check" and "test").

It is also interesting to see the color syntax used in the output from running gradle tasks. This is a nice touch that adds to the readability of the output. If for some reason the color syntax is undesirable, the --no-color option can be specified to turn it off.

Convention over Configuration is an increasingly popular software development tenet that tools and frameworks such as Ruby on Rails, Maven, and JPA ("configuration by exception") have all embraced. Gradle similarly adopts conventions with the Java plugin tasks to reduce need for explicit configuration specification.

The Gradle Java Quickstart Page describes the Gradle conventions for the Java plugin (I have added the emphasis):

Gradle expects to find your production source code under src/main/java and your test source code under src/test/java. In addition, any files under src/main/resources will be included in the JAR file as resources, and any files under src/test/resources will be included in the classpath used to run the tests. All output files are created under the build directory, with the JAR file ending up in the build/libs directory.

Gradle's conventions for Java builds may look suspiciously similar to conventions Maven users are already familiar with.

For purposes of this blog post, I have changed my personal NetBeans-inspired directory convention to work with Gradle's expected convention. In other words, instead of using dist for the constructed JAR and using src and test for source and test code respectively, I move the files into src/main/java and test/main/java and plan for the JAR to be assembled into the build directory rather than in the dist directory.

With the source code in the appropriate expected directory, I show (in the next screen snapshot) the building of the Java code with the "build" task and the generation of Javadoc with the "javadoc" task. Again, the color syntax makes the output more readable.

The next screen snapshot shows the generated files under the build directory. None of this was specified as it relied upon Gradle's conventions.

The two folders "blogScriptConfigFiles" and "images" are not part of the Gradle build and are simply folders I created for managing versions of the build.gradle files and screen snapshots for this blog post. The other folders are either source or generated artifacts.

In case it wasn't clear above, I wanted to add a reminder here that to build and document this simple Java application, I only really needed the following Gradle build configuration file:

build.gradle - Minimum Required To Build Simple Java Application

apply plugin: 'java'

As long as the source files are in the appropriate location according to Gradle conventions and the build is not too complex, I don't need to specify any tasks (similar to Ant targets) at all. I included a simple build.xml example in my blog post Learning Java via Simple Tests that I often use as a starting point for building simple Java examples. However, even the simplest Ant build file doesn't get as easy as the one-liner Gradle build configuration file just shown!

Conclusion

Gradle appears to have great potential as a build tool. By combining the power of Groovy with the power of the JVM Ant, and Ivy, Gradle seems poised to provide a winning combination that should be difficult to beat when it comes to building Java applications. I look forward to Gradle 1.0 leaving Milestone status behind, hopefully in the very near future.