Showing posts with label maven. Show all posts
Showing posts with label maven. Show all posts

03 November 2017

Deploy your maven project to the public repository

1. update your maven to look like https://github.com/mhewedy/sftp-utils/blob/master/pom.xml by adding the following:


<name>sftp-utils</name>
<description>SFTP Utils</description>
<url>https://github.com/mhewedy/sftp-utils</url>

<licenses>
    <license>
        <name>Apache License Version 2.0</name>
        <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
</licenses>

<developers>
    <developer>
        <name>Muhammad Hewedy(mhewedy)</name>
        <email>mhewedy@gmail.com</email>
        <organization>mhewedy</organization>
        <organizationUrl>https://github.com/mhewedy</organizationUrl>
    </developer>
</developers>

<scm>
    <connection>scm:git:git@github.com:mhewedy/sftp-utils.git</connection>
    <developerConnection>scm:git:git@github.com:mhewedy/sftp-utils.git</developerConnection>
    <url>git@github.com:mhewedy/sftp-utils.git</url>
</scm>


And

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <executions>
        <execution>
            <id>attach-javadocs</id>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <executions>
        <execution>
            <id>attach-sources</id>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-gpg-plugin</artifactId>
    <executions>
        <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
                <goal>sign</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.sonatype.plugins</groupId>
    <artifactId>nexus-staging-maven-plugin</artifactId>
    <version>1.6.3</version>
    <extensions>true</extensions>
    <configuration>
        <serverId>ossrh</serverId>
        <nexusUrl>https://oss.sonatype.org/</nexusUrl>
        <autoReleaseAfterClose>true</autoReleaseAfterClose>
    </configuration>
</plugin>

And change the values according to your project

Then create a ticket like this: https://issues.sonatype.org/browse/OSSRH-35670

Then after it is resolved as fixed, then execute from the project directory:

mvn clean deploy

and check https://oss.sonatype.org/content/groups/staging/ and https://oss.sonatype.org/content/groups/public for the artifacts, for example:
https://oss.sonatype.org/content/groups/public/com/github/mhewedy/sftp-utils/


01 November 2014

How easy it is to create a multi module maven project

It is very easy.. no complexity presented here ..

The multi module project is folder with a parent pom file and some sub modules, each is a maven project reside in the directly of the parent project (also can reside in any relative path, not necessary to be in the parent folder).

And the parent project itself is a regular maven project but without src folder and with packaging `pom` instead of  `jar` or `war`...

If you have a shared dependency, as if you work with spring framework, you can put the shared dependencies in the parent pom. and in sub modules pom you can put unique dependencies and also can have one module depend on others (web app module to depend on domain module and repository module)

The following is directory structure using parent module with two sub modules (quick-start and webapp)

pom.xml
my-model-app
|____.classpath
|____.project
|____.settings
| |____org.eclipse.jdt.core.prefs
| |____org.eclipse.m2e.core.prefs
| |____org.eclipse.wst.common.component
| |____org.eclipse.wst.common.project.facet.core.xml
|____pom.xml
|____src
| |____main
| | |____java
| | | |____com
| | | | |____me
| | | | | |____model
| | | | | | |____App.java
| |____test
| | |____java
| | | |____com
| | | | |____me
| | | | | |____AppTest.java
my-web-app
|____.classpath
|____.DS_Store
|____.project
|____.settings
| |____.jsdtscope
| |____org.eclipse.jdt.core.prefs
| |____org.eclipse.m2e.core.prefs
| |____org.eclipse.wst.common.component
| |____org.eclipse.wst.common.project.facet.core.xml
| |____org.eclipse.wst.jsdt.ui.superType.container
| |____org.eclipse.wst.jsdt.ui.superType.name
| |____org.eclipse.wst.validation.prefs
|____pom.xml
|____src
| |____.DS_Store
| |____main
| | |____java
| | |____resources
| | |____webapp
| | | |____index.jsp
| | | |____WEB-INF
| | | | |____web.xml


Note, the .classpath and other eclipse files are added because I've imported the project in eclipse.

Now it is very easy, go ahead and create your multi module maven project.

04 October 2013

SemVer, an Versioning guidelines

http://semver.org/ is very simple, yet powerful versioning specs (guidelines) - you should read the whole page.

Highlights:

Given a version number MAJOR.MINOR.PATCH, increment the:
  1. MAJOR version when you make incompatible API changes,
  2. MINOR version when you add functionality in a backwards-compatible manner, and
  3. PATCH version when you make backwards-compatible bug fixes.

Example:


// suppose I've some software lib with the following code.
// current version 1.0.0
int sum (int x, int y){
    return x;    // note, buggy code
}

// I did a bugfix in backward compatible manner
// Clients Do *not* need to change in thier code to access same API
// version => 1.0.1
int sum (int x, int y){
    return x + y;
}

// I did add a logging feature in a backward compatible manner
// Clients Do *not* need to change in thier code to access same API
// version => 1.1.1
int sum (int x, int y){
    logger.info("client requests addition of " + x " and " + y);
    return x + y;
}

// I did an incompatible API change
// Clients Do needs to change in thier code to access same API
// version 2.0.0
int sum (int x, int y, Caller caller){
    logger.info("caller" + caller + " requests addition of " + x " and " + y);
    return x + y;
}