Archive for the ‘Maven’ Category

maven: Custom Maven Repository Web Applications

Monday, June 10th, 2013

Archiva vs artifactory vs nexus

Setting up Eclipse Classpath for Maven project

Wednesday, November 28th, 2012

So, first, once per workspace, we need to do this. (from any path)

mvn -Declipse.workspace=/path/to/eclipse/workspace eclipse:configure-workspace

This will add the maven repository lib folder as a variable to eclilpse

Then, per project, we do the following in the project file path (where the pom.xml is)

mvn eclipse:eclipse

Source

Maven: Pom.xml and AspectJ

Monday, March 26th, 2012

In the Lib that has the aspect, add this to the pom.xml

<!-- AspecJ Compile -->
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>aspectj-maven-plugin</artifactId>
  <version>1.3</version>
  <configuration>
    <source>1.6</source>
    <target>1.6</target>
    <outxml>true</outxml>
    <showWeaveInfo>true</showWeaveInfo>
    <verbose>true</verbose>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>compile</goal>
        <goal>test-compile</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<!-- /AspecJ Compile -->

.....


<dependency>
  <groupId>org.aspectj</groupId>
  <artifactId>aspectjrt</artifactId>
  <version>1.6.7</version>
</dependency>

<dependency>
  <groupId>org.aspectj</groupId>
  <artifactId>aspectjweaver</artifactId>
  <version>1.6.7</version>
</dependency>

Then, on the application that receive the aspect, need to have the failOnError:false to allow the mvn compiler to continue. Then, we weave the dependency “LibWithSomeAspects” in.

<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <source>1.6</source>
    <target>1.6</target>
    <!-- Temporary fix for supporting aspectJ -->
    <failOnError>false</failOnError>
  </configuration>
</plugin>

<!-- AspecJ Compile -->
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>aspectj-maven-plugin</artifactId>
  <version>1.3</version>
  <configuration>
    <source>1.6</source>
    <target>1.6</target>
    <outxml>true</outxml>
    <showWeaveInfo>true</showWeaveInfo>
    <verbose>true</verbose>
    <weaveDependencies>
      <weaveDependency>
        <groupId>com.example</groupId>
        <artifactId>LibWithSomeAspects</artifactId>
      </weaveDependency>
    </weaveDependencies>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>compile</goal>
        <goal>test-compile</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<!-- /AspecJ Compile -->

Maven: Copy the jar dependencies in a folder

Friday, June 3rd, 2011
	  <!-- Clean & Copy .jar file to /bin/lib -->
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.4</version>
        <executions>
          <execution>
          	<phase>package</phase>
            <configuration>
              <tasks>
                <delete dir="bin/lib">
                </delete>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>bin/lib</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- /Clean & Copy  .jar file to /bin/lib -->

maven: Plugin for building executable jar manifest

Sunday, July 25th, 2010
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <configuration>
    <archive>
      <manifest>
        <addClasspath>true</addClasspath>
        <mainClass>org.example.MyStart</mainClass>
      </manifest>
    </archive>
  </configuration>
 </plugin>

Source: Maven Guide > Guide to Working with Manifests

Maven: Maven Tips & Quick Start & Cheat Sheet

Monday, July 19th, 2010

Skip Test

mvn -Dmaven.test.skip=true package

Official JBoss Repository for Hibernate and more

<repository>
 <id>jboss-repository-group</id>
 <name>jboss-repository-group</name>
 <url>https://repository.jboss.org/nexus/content/groups/public/</url>
 <layout>default</layout>
</repository>

Note: the “http://repository.jboss.org/maven2/” is deprecated. Use the above one (Announcement, Getting Started Doc ).

Generate Source

mvn source:jar

maven source doc

Generate Source

mvn javadoc:jar

maven javadoc doc

Publishing Artifacts to Central Repository

Maven Sonatype/Maven Central commands

Publish Snapshots

mvn clean deploy

Or better with source

mvn clean source:jar javadoc:jar deploy

Stage the release

# prepare it (will create the new tag in sonatype SVN, automatically checking in on your behalf).
mvn release:clean
mvn release:prepare
#stage the release
mvn release:perform

Maven will checkout the tag you just prepared, then build and deploy it into Nexus staging repository.

release it

Other Links