Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Gradle Dependency Management

You're reading from  Gradle Dependency Management

Product type Book
Published in Jun 2015
Publisher
ISBN-13 9781784392789
Pages 188 pages
Edition 1st Edition
Languages
Author (1):
Hubert Klein Ikkink Hubert Klein Ikkink
Profile icon Hubert Klein Ikkink

Creating artifacts


We saw how to define artifacts, but we also need to create artifacts in our build files. We can either use an archive task to create the artifact or a file can be an artifact. Most of the time, when we use Gradle in a Java project, we build an archive with compiled classes and resources. Actually, the Java plugin adds a jar task to our project that will just do that. The JAR file created is then added to the archives configuration.

In the next example build file, we will use the Java plugin and simply rely on the default artifact configuration and tasks. The following code shows this:

apply plugin: 'java'

// Define project properties.
group = 'com.mrhaki.sample'
version = '2.1'
archivesBaseName = 'sample'

// Extra task to check the artifacts.
task artifactsInfo << {
  configurations
    .findByName('archives')
    .allArtifacts
    .each { artifact ->
      println artifact.file.name
    }
}

We can now run the buildArchives task and check the artifacts with the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}