Arquivo da tag: Maven

What is the JAXB2 Maven Plugin?

This plugin uses the Java API for XML Binding (JAXB), version 2+, to generate Java classes from XML Schemas (and optionally binding files) and to create XML Schemas from annotated Java classes. The plugin delegates most of its work to either of the two JDK-supplied tools XJC and Schemagen, through its JAXB implementation dependencies.


How to Set Up a Private Maven Repository in Amazon S3

Amazon S3 is a perfect place for keeping private Maven artifacts. I assume you keep public artifacts in Maven Central because you want them to be available to everybody. Private artifacts are those you don’t want visible to anyone except members of your team. Thus, you want to deploy your .jarfiles there and make sure they are visible only by your team. Here is how we do this in all our Java projects.

Create an S3 Bucket

First, you create a new S3 bucket. I would recommend you name it using your project domain and a prefix. For example, with repo.teamed.iorepo is a prefix and is the domain.

There’s no need to configure any permissions for this bucket. Just create it through the Amazon S3 console.

Create an IAM User

Create a new IAM user. I recommend you name it like teamed-maven if your project name is teamed.

Add a new “inline policy” to the user:

<code class="language-text" data-lang="text">{
  "Statement": [
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": [

Here, is the name of the S3 bucket you created a minute ago.

Make sure you have an “access key” for this new user. It must look similar to this:

<code class="language-text" data-lang="text">key: AKIAI9NNNJD5D7X4TUVA
secret: t5tZQCwuaRhmlOXfbGE5aTBMFw34iFyxfCEr32av</code>

The key is 20 characters (all caps), and the secret is 40 characters.

Extend settings.xml

Add this configuration to your ~/.m2/settings.xml file:

<code class="language-xml" data-lang="xml"><span class="nt"><settings></span>
  <span class="nt"><servers></span>
    <span class="nt"><server></span>
      <span class="nt"><id></span><span class="nt"></id></span>
      <span class="nt"><username></span>AKIAI9NNNJD5D7X4TUVA<span class="nt"></username></span>
      <span class="nt"><password></span>t5tZQCwuaRhmlOXfbGE5aTBMFw34iFyxfCEr32av<span class="nt"></password></span>
    <span class="nt"></server></span>
  <span class="nt"></servers></span>
<span class="nt"></settings></span></code>

Configure pom.xml

Add this configuration to pom.xml:

<code class="language-xml" data-lang="xml"><span class="nt"><project></span>
  <span class="nt"><distributionManagement></span>
    <span class="nt"><snapshotRepository></span>
      <span class="nt"><id></span><span class="nt"></id></span>
      <span class="nt"><url></span>s3://<span class="nt"></url></span>
    <span class="nt"></snapshotRepository></span>
    <span class="nt"><repository></span>
      <span class="nt"><id></span><span class="nt"></id></span>
      <span class="nt"><url></span>s3://<span class="nt"></url></span>
    <span class="nt"></repository></span>
  <span class="nt"></distributionManagement></span>
  <span class="nt"><repositories></span>
    <span class="nt"><repository></span>
      <span class="nt"><id></span><span class="nt"></id></span>
      <span class="nt"><url></span>s3://<span class="nt"></url></span>
    <span class="nt"></repository></span>
  <span class="nt"></repositories></span>
<span class="nt"></project></span></code>

Then, configure S3 Wagon, also in pom.xml:

<code class="language-xml" data-lang="xml"><span class="nt"><project></span>
  <span class="nt"><build></span>
    <span class="nt"><extensions></span>
      <span class="nt"><extension></span>
        <span class="nt"><groupId></span>org.kuali.maven.wagons<span class="nt"></groupId></span>
        <span class="nt"><artifactId></span>maven-s3-wagon<span class="nt"></artifactId></span>
        <span class="nt"><version></span>1.2.1<span class="nt"></version></span>
      <span class="nt"></extension></span>
    <span class="nt"></extensions></span>
  <span class="nt"></build></span>
<span class="nt"></project></span></code>

You’re ready to go. You can deploy your artifacts just by running Maven from the command line:

<code class="language-text" data-lang="text">$ mvn clean deploy</code>


Now you want to see these artifacts in your browser, in a secure mode, by providing secure credentials. I recommend you use, as explained in Basic HTTP Auth for S3 Buckets.

Configure Rultor


Another recommendation is to configure for deployment of your artifacts to S3 automatically.

First, encrypt your settings.xml with this Rultor remote:

<code class="language-xml" data-lang="xml">$ gem install rultor
$ rultor encrypt -p me/test settings.xml</code>

Instead of me/test, you should use the name of your GitHub project.

As a result, you will get a new file named settings.xml.asc. Add it to the root directory of your project, then commit and push. The file contains your secret information, but only the Rultor server can decrypt it.

Create a .rultor.yml file in the root directory of your project (The Rultor reference page explains this format in greater detail):

<code class="language-text" data-lang="text">decrypt:
  settings.xml: "repo/settings.xml.asc"
  script: |
    mvn clean deploy --settings ../settings.xml</code>

Now it’s time to see how it all works together. Create a new ticket in the GitHub issue tracker and post something like this into it (read more about Rultor commands):

<code class="language-text" data-lang="text">@rultor deploy</code>

You will get a response in a few seconds. The rest will be done by Rultor.

That’s it.

How can I create an executable JAR with dependencies using Maven?



mvn clean compile assembly:single


Plugin “maven-artun-plugin”

Com esse plugin quando formos gerar o build do projeto com o comando “mvn install”, ele vai pegar o *.war no final e cola na pasta do tomcat que eu especifiquei.

               <copy file="${}/projeto.war" todir="C:\TomCat7\webapps" />

Configurar o Archetype do VRaptor com Hibernate no Eclipse

Resumo sobre archetypes: 

– Maven instalado
– Jar do archetype no M2_REPO (ver link no final para mais detalhes sobre repositórios)
Quando for criar o projeto selecione o archetype “vraptor-hibernate-archetype”, caso não exista ainda crie clicando no botão “Add Archetype”, então preencher os seguintes campos:
Archetype Group Id :
Archetype Artifact Id: vraptor-hibernate-archetype
Archetype Version: 0.0.1

Repository URL: //

Quando clicar em “OK” irá aparecer o seu novo archetype.

Gerar build com o Maven, sem os testes

Para gerar o build com o maven, sem ignorar os testes, seria:

mvn clean install

Para você ignorar os testes unitários precisa colocar “-DskipTests”, então ficaria.

mvn clean install -DskipTests

Para você ignorar os testes de integração precisa colocar “-DskipITs”, então ficaria.

mvn clean install -DskipITs

Mas se você quiser ignorar tanto os teste unitários como de integração, ficará assim.

mvn clean install -Dmaven.test.skip=true

Observação: Para que funcione o “-Dmaven.test.skip=true”, você deve ter este profile no pom.xml: