Thursday, July 24, 2014

How to ban a given class...

This week I came across an odd situation.  I need to make sure nobody was using 'javax.ws.rs.Path' class.

So how can I ban a give class from my project?

It looked like a job for maven enforcer plugin!  Nop, that was no good.  Enforcer has no rule for this. May be extra enforcer rules?  No rule there for that too.

After searching a little bit more I found a plugin to do that!

Restrict-maven-plugin allowed me to do so.


<plugin>
  <groupId>com.yamanyar</groupId>
  <artifactId>restrict-maven-plugin</artifactId>
  <version>0.6</version>
  <executions>
    <execution>
      <phase>process-classes</phase>
      <goals>
        <goal>restrict</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <continueOnError>false</continueOnError>
    <restrictions>
      <restriction>com.contaazul.* to javax.ws.rs.Path</restriction>
    </restrictions>
  </configuration>
</plugin>

Easy no?

Now if someone add this by mistake maven will let us know:
[error] Restricted access from:(com.contaazul.MyClass.class) com.contaazul.MyClass to: javax.ws.rs.Path due to rule [1-1]
[error] Build is broken due to 1 restriction policies!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.133 s (Wall Clock)
[INFO] Finished at: 2014-07-24T10:20:44-03:00
[INFO] Final Memory: 60M/1247M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.yamanyar:restrict-maven-plugin:0.4:restrict (default) on project contaazul-app-business: There are 1 access exceptions! -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Way better then catching a bug latter, no?

Wednesday, June 25, 2014

Maven formatter plugin now supports Java 8

Just release maven-formatter-plugin 1.4.0.

This new version uses Eclipse Luna formatter, which mean Java 8 / Lambdas support.

Here a usage example:

<plugin>
  <groupId>com.marvinformatics.formatter</groupId>
  <artifactId>formatter-maven-plugin</artifactId>
  <version>1.4.0</version>
  <executions>
    <execution>
      <goals>
        <goal>validate</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <excludes>
      <exclude>**/target/**</exclude>
    </excludes>
    <aggregator>true</aggregator>
    <lineEnding>LF</lineEnding>
  </configuration>
</plugin>


Go for it!

Eclipse Luna + AJDT

You may or may not know, but Eclipse Luna is already out on the mirrors.

Still, if you are using AspectJ and wanna add Java 8 / lambdas to the mix there is no public update site for AJDT version compatible with Eclipse Luna.

Poking around I found the dev update site:
http://download.eclipse.org/tools/ajdt/44/dev/update/

Hope it helps!

Saturday, May 24, 2014

Google Could Platform is meant to script...

Impressive!

No, really impressive!


I have being using AWS for 2 years, and still google managed to impress me.

gcutil is really nice, no need to worry with ssh keys, auth details...  gutil just give you a url, just copy it, paste on browser, allow access and enter the authorization key back to command line.  Very similar to Google Authentication 2nd step.

$ gcloud auth login
Go to the following link in your browser:

    https://accounts.google.com/o/oauth2/auth?XXXX


Enter verification code: ***

You are now logged in as [m***@gmail.com].
Your current project is [None].  You can change this setting by running:
  $ gcloud config set project <project>

Easy right?

After that, I wanna install cassandra....  and the script to do so is straight forward (available at: https://github.com/GoogleCloudPlatform/compute-cassandra-python)


Also, $500 bucks starter kick is really nice!

Tuesday, April 1, 2014

Who is dragging my build!

We are a java shop and we use maven to manage our project build, tests, deploy...

But a couple days ago one of our modules build time jump to the roof with no apparent reason.

I knew which module was problematic.
But why?
Where is the problem?

Maven profiler to the rescue: https://github.com/takari/maven-profiler


Once I located the problem I was able to isolate some code on a new module and all was good again.

Cheers!

Thursday, March 27, 2014

Points estimation with beers

This week I made a quick presentation where I work to make us rethink point estimation.



Original presentation in portuguese:

Wednesday, March 26, 2014

maven-formatter-plugin got faster

A week ago (give or take) I post about my maven-formatter-plugin fork here.

Back then, I was trying to get it faster and if possible get it using all power my computer have.

Well, it is faster now!

The eclipse luna M6 contains a formatter way faster, so I decided to make a new release and include it!

I tried it on a big project (about 3K files and 100K lines).

The format validation time drop from 24s to 16s.... 30% faster.

<plugin> <groupId>com.marvinformatics.formatter</groupId> <artifactId>formatter-maven-plugin</artifactId> <version>1.4.0.M6</version> <executions> <execution> <goals> <goal>validate</goal> </goals> </execution> </executions></plugin>

Not bad, not bad at all.