Skip to content

Commit

Permalink
Adding the maven-shade-plugin to the pom.xml file to create an uber-j…
Browse files Browse the repository at this point in the history
…ar that includes the dependency wihtin the jar, and adding a README file
  • Loading branch information
shaybagants committed Nov 2, 2015
1 parent fa8662d commit 3ac5043
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 19 deletions.
30 changes: 30 additions & 0 deletions build-info-java-example/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# build-info-java-example
This example project demonstrate the ability to create an Artifactory [build-info OSS project](https://github.com/JFrogDev/build-info)
, deploy it to Artifactory and deploy the build artifact from a filesystem directory to Artifactory by using the build-info OSS project, similarly to what the CI/build tools Artifactory plugins does.

### Motivation
JFrog's Artifactory plugins (CI/build tools plugins) are very popular, and most of the people who are using Artifactory to host and manage their binaries with a common CI server/build tool that has a plugin for Artifactory are using it. Still, there are many users which are not using CI server, or using an internal CI server/build tool that has no Artifactory plugin for it which are interested having the build-info benefits and the ability to promote an entire build entity with a single command. These users can use our OSS build-info object to create and deploy their own build info, as we show in this project example

### Notes
This project includes one Java class: 'CreateAndDeploy.java' and uses one dependency: 'build-info-extractor'.
The 'CreateAndDeploy' main method builds an Artifactory build-info object and deploys it to Artifactory. Our example collects the build artifacts information (artifacts name, checksums) from a directory which should be passed to the main method 'String[] args' array. In our example, the build-info object includes one module (but can include more), and the module should have one or more artifacts. Once the information was collected, our script will deploy it to Artifactory (it can also deploy the actual artifact).


## Getting Started
You can either run this from your IDE, or by command line.
In order to run it from your IDE, just import the project, resolve the 'build-info-extractor' dependency with Maven, and run the main method.
Note, you should pass your build artifacts directory path as the first element of the main arguments array ('String[] args'). You will most likely be interested to change the 'buildName', 'buildNumner', 'targetRepository' and 'artifactoryURL' values.

In order to run it from the command line, please follow the below instructions:
First, clone the code:
```
git clone [email protected]:JFrogDev/project-examples.git
```
Once you have the code on your machine, run:
```mvn install```
Maven will create an uber-jar named 'uber-buildCreatorExample-1.0-SNAPSHOT.jar' under the 'target' directory. Go to the 'target' and run:
```java -jar /path/to/buildArtifactsFolder/```




62 changes: 43 additions & 19 deletions build-info-java-example/pom.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>groupId</groupId>
<artifactId>GenerateBuildInfo</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>build-info-extractor</artifactId>
<version>2.5.2</version>
</dependency>

</dependencies>

</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jfrog.example</groupId>
<artifactId>buildCreatorExample</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>CreateAndDeploy</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<finalName>uber-${artifactId}-${version}</finalName>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>build-info-extractor</artifactId>
<version>2.5.2</version>
</dependency>
</dependencies>
</project>

0 comments on commit 3ac5043

Please sign in to comment.