Giter VIP home page Giter VIP logo

gradle-examples's Introduction

gradle-examples

This example shows how to use Gradle for dependency management. It contains two small projects: A producer that publishes an artifact to Artifactory and a consumer that depends on and downloads the artifact.

Docker is used to run Artifactory.

The example has three parts:

  • Start an Artifactory server
  • Use Gradle to publish a versioned artifact in the first project
  • Use Gradle to consume the versioned artifact in the second project

The example uses a Gradle plugin called VersionedBinaryArtifacts made by Praqma.

Usage

Prerequisites

Ensure <user home>/.gradle/gradle.properties has Artifactory properties set as required by the VersionedBinaryArtifacts plugin, like this:

$ cat ~/.gradle/gradle.properties
...

repositoryManagerUsername=admin
repositoryManagerPassword=password
repositoryManagerUrl=http://localhost:8081/artifactory

Start Artifactory container

cd infrastructure/artifactory/
./run.sh

Now Artifactory runs in a Docker container available on the URL above. It comes with an example repository called example-repo-local. You need to go to the web UI to go through the setup wizard (you can skip all the steps).

Publish the producer artifact

cd projects/producer/
./gradlew publish

This puts files in Artifactory by a number of steps:

  • Read build.properties to run the build command: copy files from src to out
  • Apply the zip block defined in build.gradle to create a zip archive of the out folder
  • Upload to Artifactory using the repository information in the gradle.properties file mentioned earlier, as well as the publishRepo and version from build.properties

Consume in the consumer project

cd projects/consumer/
./gradlew resolveDep

This reads build.properties to download the producer artifact from Artifactory, along with the gradle.properties file specifying the connection attributes to Artifactory.

The files are downloaded to the build/resolvedDep folder.

Clean up

docker rm -fv artifactory

Links

gradle-examples's People

Watchers

James Cloos avatar Martin Mosegaard Amdisen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.