What is the best practice in Gradle 2.1 for handling native artifacts and dependencies?

Hello, I am new to Gradle and really trying to understand the capabilities for building native projects.

I am building an embedded project (C++ on arm.) We currently use CMake, but I am looking at Gradle for it’s better dependency managment and repository integration.

I have succeeded in cross compiling one of our libraries using Gradle 1.12 and publishing it to Artifactory using the gradle-native-artifacts-plugin. The plugin works great, but it took me a while to realize that that plugin doesn’t work with Gradle 2.x.

I’d like to be using the current release of Gradle, but I’m not sure how I can publish my native build artifacts. Is there another plugin I should be using, or is there now built in support for publishing native artifacts. Can someone point me at an example of publishing a native artifact on Gradle 2.1?

Thanks, Derek

I’m not familiar with the ‘gradle-native-artifacts’ plugin, but there’s no new built-in support for publishing native libraries in Gradle 2.1. This is something we’re working on, but it’s planned, not completed.

Looking forward to better support for native artifact publishing.

Below is a Hello World c++ example that I put together that compiles a hello world application, puts together a .tgz distribution and publishes it to an Artifactory snapshot repository. It pulls together some of the pieces I have been trying to figure out. Hopefully it will help some other people trying to publish native artifacts to Artifactory.

I’d also be VERY interested in ways to do this more easily or in a more Gradle-like way. I’m still wrapping my head around this stuff. Thx.

apply plugin: 'cpp'
apply plugin: 'maven-publish' //required by artifactory-publish
apply plugin: 'distribution'
  // automatically get the artifactory-publish plugin and it's dependencies
buildscript {
  repositories {
    maven { url 'http://repo.jfrog.org/artifactory/gradle-plugins-snapshots' }
  }
  dependencies {
    classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.1.x-SNAPSHOT')
  }
  configurations.classpath {
    resolutionStrategy {
      failOnVersionConflict()
      cacheDynamicVersionsFor 0, 'seconds'
      cacheChangingModulesFor 0, 'seconds'
    }
  }
}
  apply plugin: 'artifactory-publish'
  //set the default values for the artifactory repository
group = 'org.hw'
version = '0.1-SNAPSHOT'
def artifactId = projectDir.name
def versionNumber = version
    executables {
  hello{}
}
  // define sources
sources {
  hello {
    cpp {
      source {
        srcDir "."
        include "hw.cpp" //hello world c++ source
      }
    }
  }
}
  // create a distribution tarball and add the "hello" binary
// the distribution plugin requires a src/main/dist directory
distributions {
    main {
        baseName = 'gradlehw'
        contents {
          from {'build/binaries/helloExecutable'}
        }
    }
}
  // make sure the distribution tarball is compressed and
 // define a dependency on the helloExecutable task
distTar{
  compression = Compression.GZIP
  dependsOn('helloExecutable')
}
  // configure the artifactory repository.
Username/password values should be moved to gradle.properties
// file and hashed.
artifactory {
    contextUrl = 'http://morph2:8888/artifactory' // base artifactory url
  publish {
    contextUrl = 'http://morph2:8888/artifactory' // base artifactory url
    repository {
      repoKey = 'libs-snapshot-local'
 //The Artifactory repository key to publish to
      username = 'build'
    //The publisher user name
      password = 'Password!'
     //The publisher password
      maven = true
    }
  }
}
  // define the publication and add any files in the
distribution directory
publishing {
    publications {
        mavenStuff(MavenPublication) {
            File distDir
            distDir = file('build/distributions')
            FileCollection collection
            collection = files { distDir.listFiles() }
            collection.each {File thisFile ->
              artifact(file(thisFile))
            }
        }
    }
}
  // configure the artifactoryPublish task
artifactoryPublish {
  publications ('mavenStuff')
  dependsOn('distTar')