I showed how you can use the maven-release-plugin to create a release for your project. Now I would like to explain how to use maven to effectively use SNAPSHOT.
First what do I mean by SNAPSHOT? SNAPSHOT is a special version in maven that indicates the latest code; typically TRUNK or HEAD in your source control. With this version, maven will automatically grab the latest SNAPSHOT every time you build. On the other hand, when you are using 2.0, once maven has downloaded this artifact, it never tries to get a new 2.0.
Why should you use SNAPSHOT? You should use SNAPSHOT for rapidly moving code where bug fixes and enhancements are coming fast. Another reason is you should never require users of your project to checkout and build your code. EVER! I would venture to say that 50% of the open source projects I have had to checkout and build, have not initially built.
How to create a SNAPSHOT?
First you have to find a webserver to host the artifacts. I have typically used apache running on linux. I first create a folder under / called snapshots (owner:group equal to repoman:repoman) and then create a softlink (ln -s) under /var/www/html called snapshots (owner:group being root:root). So now you should have /var/www/html/snapshots --> /snapshots. For some examples of some public SNAPSHOT repositories check out Apache's and Codehaus.
Second you need to update your parent POM in order to properly use the maven-deploy-plugin. First make sure the version you are using includes -SNAPSHOT. For example something like 0.9.2-SNAPSHOT.
Third add the distributionManagement section to your parent POM to look something like this:
<distributionManagement>
<snapshotRepository>
<id>maven2-snapshot-repository</id>
<name>Maven2 Snapshot Repository</name>
<url>scp://host/snapshots/</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
This will use scp to upload the artifacts to the url //host/snapshots. The element that needs to receive the most of your attention is <uniqueVersion>. This value can either be true or false. When it is false the artifacts created will not be unique and will look something like this each time: myproject-0.9.2-SNAPSHOT. Use this to reduce disk usage. When it is set to false a unique version is created everytime. For example myproject-0.9.2-20070922.011633-1.jar and then the next build that day would be myproject-0.9.2-20070922.011633-2.jar.
Finally, the last thing is to set the username and password of the repository in your $USER_HOME/.m2/settings.xml file. This will be used by scp for authentication. To do this add the following in your settings.xml file:
<servers>
<server>
<id>maven2-snapshot-repository</id>
<username>repoman</username>
<password>mypassword</password>
</server>
<servers>
That is it. Now you are ready to run mvn deploy.
分享到:
相关推荐
The purpose of this Communication Handbook is to assist you in communicating effectively. It gives clear practical tips per each topic that might be applicable to your daily communication within the ...
You'll learn about the Maven life cycle and how to effectively leverage and use it. Also, you'll learn the basics of using site plugins and generating Javadocs, test coverage/FindBugs reports, ...
## Course Overview - We will use Handson...- We will learn how to use Maven effectively in combination of an IDE like Eclipse. - We will use - Maven for dependency management, building and running th
appropriate if you have this basic background and want to learn how to use the scientific Python toolchain to investigate these topics. On the other hand, if you are comfortable with Python, perhaps ...
Android Application Development with Maven is intended for Android developers or devops engineers who want to use Maven to effectively develop quality Android applications. Whether you are already ...
Chapter 3, Data Structures in Game Development, introduces all the simple and complex data structures in C++ and shows how to use them effectively in games. Chapter 4, Algorithms for Game Development...
In this paper, we carried out an empirical study to explore the logging practice in open source software projects so as to establish a basic understanding on how logging practice is applied in real ...
Pro Vagrant teaches you how to effectively implement and optimize Vagrant in your everyday work environment. Master the creation and configuration of virtual development environments with an easy-to-...
How to effectively use Apple tools How to build Core Data applications How to use Core Data in advanced settings How to version and migrate data as your applications evolve How to tune and ...
He then shows you how to use Entity Framework Core 2 in your own MVC projects, starting from the nuts-and-bolts and building up to the most advanced and sophisticated features, going in-depth to give...
Learn how to effectively use the latest tools and features of Visual C++ for database programming by following practical, real-world examples. Get expert tips from a leading authority for programming...
You will learn how to effectively use binary serialization to store data permanently in flash memory or exchange data with a PDA or PC. Topics like cryptography and encrypted data exchange with a ...
Learn how to effectively use the latest tools and features of Visual C++ for database programming by following practical, real-world examples. Get expert tips from a leading authority for programming...
Once past the basics, you'll learn why you want to write unit tests and how to effectively use JUnit. But the meaty part of the book is its collected unit testing wisdom from people who've been there,...
how to effectively use them. Chapter 4, Control Flow, shows Julia’s elegant control constructs, how to perform error handling, and how to use coroutines (called Tasks in Julia) to structure the ...