Hi, here’s an example for a build.gradle that should work for resolving and
deploying artifacts with Artifactory, Cheers!

Gal.

buildscript {

           repositories {

  jcenter()

 }

           dependencies {

               classpath(group: 'org.jfrog.buildinfo', name:
'build-info-extractor-gradle', version: '3.0.1')

           }

}

import java.text.DateFormat

import java.text.SimpleDateFormat

def globalVersion = new Version(currentVersion)

allprojects {

apply plugin: 'java'

apply plugin: 'com.jfrog.artifactory'

apply plugin: 'maven-publish'

 group = 'org.jfrog.example.gradle'

 version = globalVersion

 status = version.status

publishing {

 publications {

 mavenJava(MavenPublication) {

  from components.java

  artifact(file("$rootDir/gradle.properties")) // deploy arbitrary file

 }

 }

}



}

artifactoryPublish.skip = true

subprojects {

 apply plugin: 'maven'

 if (project.plugins.hasPlugin('java')) {

   //manifest.mainAttributes(provider: 'gradle')

manifest {

 attributes 'provider': 'gradle'

}

   configurations {

     published

   }

   dependencies {

     testCompile 'junit:junit:4.7'

   }

   task sourceJar(type: Jar) {

     from sourceSets.main.allSource

     classifier = 'sources'

   }

   task javadocJar(type: Jar, dependsOn: javadoc) {

     classifier = 'javadoc'

     from javadoc.destinationDir

   }

   artifactoryPublish {

     dependsOn sourceJar, javadocJar

   }

 }


}

configurations {

 published

}


artifactory {

//The base Artifactory URL if not overridden by the publisher/resolver

contextUrl = "http://localhost:8081/artifactory";

publish {

 repository {

 repoKey = 'libs-release-local'

 username = "${artifactory_user}"

 password = "${artifactory_password}"

 maven = true

 }

       defaults {

           //publishIvy & publishPom are true by default

           publishArtifacts = true

           publications('mavenJava')

       }

}

resolve {

 repository {

 repoKey = 'remote-repos'

 username = "${artifactory_user}"

 password = "${artifactory_password}"

 maven = true

 }

}

}

dependencies {

testCompile "org.mockito:mockito-core:1.9.5"

testCompile "junit:junit:4.11"

}

task wrapper(type: Wrapper) {

gradleVersion = '2.0'

}

class Version {

 String originalVersion

 String thisVersion

 String status

 Date buildTime

 Version(String versionValue) {

   buildTime = new Date()

   originalVersion = versionValue

   if (originalVersion.endsWith('-SNAPSHOT')) {

     status = 'integration'

     thisVersion = originalVersion.substring(0, originalVersion.length() -
'SNAPSHOT'.length()) + getTimestamp()

   } else {

     status = 'release'

     thisVersion = versionValue

   }

 }

 String getTimestamp() {

   // Convert local file timestamp to UTC

   def format = new SimpleDateFormat('yyyyMMddHHmmss')

   format.setCalendar(Calendar.getInstance(TimeZone.getTimeZone('UTC')));

   return format.format(buildTime)

 }

 String toString() {

   thisVersion

 }

}


On Fri, Jan 16, 2015 at 12:18 AM, Whgibbo <[email protected]> wrote:

> Hi,
> So from reading the documentation this seems possible :)
>
> However I'm having problems with gradle 2.2 communicating with my
> artifactory version 2.4.
> So was wondering if somebody had a sample init gradle, that I compare it
> against.
>
> Thanks
>
>
>
>
> --
> View this message in context:
> http://forums.jfrog.org/How-to-use-artifactory-to-cache-gradle-repository-requests-tp7580127p7580137.html
> Sent from the Artifactory - Users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
> GigeNET is offering a free month of service with a new server in Ashburn.
> Choose from 2 high performing configs, both with 100TB of bandwidth.
> Higher redundancy.Lower latency.Increased capacity.Completely compliant.
> http://p.sf.net/sfu/gigenet
> _______________________________________________
> Artifactory-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/artifactory-users
>
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Artifactory-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/artifactory-users

Reply via email to