# Gradle and artifactory for build java project

**URL:** <https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239>\
**Category:** Help/Discuss\
**Created:** [August 18, 2015, 8:02pm UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239 "2015-08-18T20:02:27Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilia1](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@Ilia1](https://discuss.gradle.org/u/Ilia1)\
**Post date:** [August 18, 2015, 8:02pm UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/1 "2015-08-18T20:02:27Z")

</div>

Hi, guys i beginner in java and gradle, but i wanna build my project with gradle and upload/download libraries and project from artifactory. How i can do this.  
1st i wanna download libraries with artifactory for my project fow work  
2st i wanna build my project and upload release project on artifactory.  
my problem: i cant connect for artifactory  
[http://uploads.ru/ZVJak.jpg](http://uploads.ru/ZVJak.jpg)  
[http://uploads.ru/q9McF.jpg](http://uploads.ru/q9McF.jpg)

---

<div class="post-metadata">

**Author:** ![Francois\_Guillot](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/francois_guillot/32/8566_2.png) [@Francois\_Guillot](https://discuss.gradle.org/u/Francois_Guillot)\
**Post date:** [August 18, 2015, 9:39pm UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/2 "2015-08-18T21:39:03Z")

</div>

I think you’re missing the ‘ext-release-local’ part at the end of your repository definition.  
Artifactory contains several repositories, and you can add custom ones.  
You need to tell gradle exactly the path of each repository you want to search into.

---

<div class="post-metadata">

**Author:** ![fafios](https://avatars.discourse-cdn.com/v4/letter/f/ccd318/32.png) [@fafios](https://discuss.gradle.org/u/fafios)\
**Post date:** [August 19, 2015, 8:58am UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/3 "2015-08-19T08:58:07Z")

</div>

Have you applied the Artifactory plugin and done all the required configuration for artifactory?  
here’s an example:

* * *

```
apply plugin: 'artifactory'

buildscript {
  repositories {
    maven {
      url 'http://192.168.1.1:8081/artifactory'
      credentials {
        username = "admin"
	    //to generate encrypted password refer to the links below: 
        password = "AP8S4FpSYps4uNCHXjnBCzpnfBm"
        maven = true
      }
    }
  }
  dependencies {
    classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.12')
    classpath 'mysql:mysql-connector-java:5.1.26'
  }
}

artifactory {
  //The base Artifactory URL if not overridden by the publisher/resolver
  contextUrl ='http://192.168.1.1:8081/artifactory'
  publish {
    repository {
      repoKey = 'ext-release-local'
      username = "admin"
	  //to generate encrypted password refer to the links below: 
      password = "AP8S4FpSYps4uNCHXjnBCzpnfBm"
      maven = true

    }
  }

  resolve {
    repository {
	// create a virtual repository
      repoKey = 'your-repo-name'
      username = "admin"
      //to generate encrypted password refer to the links below: 
	  password = "AP8S4FpSYps4uNCHXjnBCzpnfBm"
	  
      maven = true
    }
  }

}

```

* * *

For more details please refer to the official documentation of artifactory:  
[https://www.jfrog.com/confluence/display/RTF20/Using+Secured+Passwords+in+Settings.xml](https://www.jfrog.com/confluence/display/RTF20/Using+Secured+Passwords+in+Settings.xml)  
[http://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin](http://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin)

---

<div class="post-metadata">

**Author:** ![Ilia1](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@Ilia1](https://discuss.gradle.org/u/Ilia1)\
**Post date:** [August 19, 2015, 1:46pm UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/4 "2015-08-19T13:46:17Z")

</div>

I dont understan how its works look  
i dowload plugin and save her in this:D:\gradle\lib\pluginsbuild-info-extractor-gradle-2.2.4-uber.jar  
and into arrtifactory plugins-release-local directory too  
[http://pixs.ru/showimage/artifactor\_3190560\_18471600.jpg](http://pixs.ru/showimage/artifactor_3190560_18471600.jpg)  
gradle.build

```
apply plugin: 'java'
apply plugin: 'maven'
//apply plugin: 'artifactory'

sourceCompatibility = 1.8
version = '2.0'
buildscript.dependencies.classpath files(new File(gradle.gradleUserHomeDir, 'lib/plugins/build-info-extractor-gradle-2.2.4-uber.jar'))
//apply plugin: 'artifactory'
//apply plugin: "com.jfrog.artifactory"
//

buildscript {
    repositories{
        maven{
            url 'http://10.200.11.39:8080/plugins-release-local'
           /* credentials {
                username="admin"
                password="password"
                maven=true
            }*/
       }
    }
    dependencies {
        classpath(group: 'plugin', name:'artifactory',version:'2.4')
        //classpath 'mysql:mysql-connector-java:5.1.26'
    }
}
all projects{
    apply plugin: 'artifactory'
}
/*
artifactory {
    contexUrl='http://10.200.11.39:8080/artifactory'
    publish{
        repository{
            repoKey='ext-release-local'
            username="admin"
            password="password"
            maven=true
        }
    }
    resolve {
        repository{
            repoKey='your-repo-name'
            username="admin"
            password="password"
            maven=true
        }
    }
}
*/

```

and error with grade biuld

> Could not find plugin:artifactory:2.4.  
> Searched in the following locations:  
> [http://10.200.11.39:8080/plugins-release-local/plugin/artifactory/2.4/artifactory-2.4.pom](http://10.200.11.39:8080/plugins-release-local/plugin/artifactory/2.4/artifactory-2.4.pom)  
> [http://10.200.11.39:8080/plugins-release-local/plugin/artifactory/2.4/artifactory-2.4.jar](http://10.200.11.39:8080/plugins-release-local/plugin/artifactory/2.4/artifactory-2.4.jar)  
> Required by:  
> :21211:unspecified

---

<div class="post-metadata">

**Author:** ![Rene](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/rene/32/8082_2.png) [@Rene](https://discuss.gradle.org/u/Rene)\
**Post date:** [August 19, 2015, 2:05pm UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/5 "2015-08-19T14:05:37Z")

</div>

@Volotov why are you downloading the plugin manually? In the snippet you provided it will use the pluginsbuild jar in the gradle lib folder _AND_ the trying to resolve the plugin from artifactory as the local pluginsbuild jar is just threated as file dependency.

To get this plugin working locally without resolving anything from your artifactory you have to ensure the plugin AND its transitive dependencies are stored in a local folder.

BTW. gradle.gradleUserHomeDir is not pointing to the gradle installation, but to the local gradle userhome (usually ~/.gradle)

---

<div class="post-metadata">

**Author:** ![Ilia1](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@Ilia1](https://discuss.gradle.org/u/Ilia1)\
**Post date:** [August 19, 2015, 8:02pm UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/6 "2015-08-19T20:02:19Z")

</div>

i dont have internet, i wanna store my project and libs on artifactory. How i can do this? what action i must do? donwload plugin for artifactory add him for gradle/plugin/ folder? what i can do?

---

<div class="post-metadata">

**Author:** ![Ilia1](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@Ilia1](https://discuss.gradle.org/u/Ilia1)\
**Post date:** [August 19, 2015, 8:44pm UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/7 "2015-08-19T20:44:41Z")

</div>

whats wrong?  
i dowloaded plugins from [http://repo.jfrog.org/artifactory/libs-releases/org/jfrog/buildinfo/build-info-extractor-gradle/2.2.4/build-info-extractor-gradle-2.2.4-uber.jar](http://repo.jfrog.org/artifactory/libs-releases/org/jfrog/buildinfo/build-info-extractor-gradle/2.2.4/build-info-extractor-gradle-2.2.4-uber.jar)  
and add him into artifactory/ext-release-local how v:v:1.0  
[http://s017.radikal.ru/i431/1508/db/a16e15739c63.jpg](http://s017.radikal.ru/i431/1508/db/a16e15739c63.jpg)

```
group '1'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.5
buildscript {
    repositories {
        maven {
            url 'http://localhost:8080/artifactory/ext-release-local'
            username = "user" // The publisher user name
            password = "user1" // The publisher password
        }
    }
    dependencies {
        classpath 'v:v:1.0'
    }
}

// Plugins
apply plugin: 'java'
apply plugin: 'artifactory'

artifactory {
    contextUrl = 'http://localhost:8080/artifactory/'
        publish {
        repository {
            repoKey = 'ext-release-locall' // The Artifactory repository key to publish to
            username = "user" // The publisher user name
            password = "user1" // The publisher password
        }
    }
    resolve {
        repository {
            repoKey = 'ext-release-local'
            username = "user" // The resolver user name
            password = "user" // The resolver password
        }
    }
}

C:\Users\Илья\IdeaProjects\test>gradle build
                                                                         
FAILURE: Build failed with an exception.
                            
* Where:                    
Build file 'C:\Users\╚ы№ \IdeaProjects\test\build.gradle' line: 9
                            
* What went wrong:          
A problem occurred evaluating root project '1'.
> No such property: username for class: org.gradle.api.internal.artifacts.repositories.DefaultMavenArtifactRepository_Decorated
                            
* Try:                      
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
                            
BUILD FAILED
```

---

<div class="post-metadata">

**Author:** ![Ilia1](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@Ilia1](https://discuss.gradle.org/u/Ilia1)\
**Post date:** [August 20, 2015, 6:29am UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/8 "2015-08-20T06:29:55Z")

</div>

what this error mean?

> No such property: contexUrl for class: org.gradle.api.internal.project.DefaultProject\_Decorated  
> BUILD FAILED

```
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'war'
apply plugin: 'artifactory'

sourceCompatibility = 1.8
version = '2.0'
buildscript {
    repositories{
        maven{
            url 'http://10.200.11.39:8080/artifactory/mylib/'
              }
    }
    dependencies {
        classpath'plugin:artifactory:2.4'
        }
}
artifactory {
    contexUrl='http://10.200.11.39:8080/artifactory/'
    publish{
        repository{
            repoKey='mylib'
        }
    }
    resolve {
        repository{
            repoKey='mylib'
        }
    }
}
jar {
    from sourceSets.main.java
   }

```

---

<div class="post-metadata">

**Author:** ![mark\_vieira](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mark_vieira/32/5396_2.png) [@mark\_vieira](https://discuss.gradle.org/u/mark_vieira)\
**Post date:** [August 20, 2015, 6:39am UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/9 "2015-08-20T06:39:04Z")

</div>

> [@Ilia1](#):
>
> whats wrong?

Username and password need to be inside a `credentials { }` block.

```
buildscript {
    repositories {
        maven {
            url 'http://localhost:8080/artifactory/ext-release-local'
                credentials {
                    username = "user" // The publisher user name
                    password = "user1" // The publisher password
                }
            }
        }
    }
}

```

> [@Ilia1](#):
>
> what this error mean?

This is just a typo. It should be `contextUrl` not `contexUrl`.

---

<div class="post-metadata">

**Author:** ![Ilia1](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@Ilia1](https://discuss.gradle.org/u/Ilia1)\
**Post date:** [August 20, 2015, 8:30am UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/10 "2015-08-20T08:30:43Z")

</div>

its not work, i try add username and password, but its not work

---

<div class="post-metadata">

**Author:** ![Ilia1](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@Ilia1](https://discuss.gradle.org/u/Ilia1)\
**Post date:** [August 20, 2015, 9:15am UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/11 "2015-08-20T09:15:44Z")

</div>

now this code worked  
but when i used gralde artifactoryPublish appears error

Exectution failed for task ‘artifactoryPublish’

> org/apach/ivy/core/ivyPatternHelper

what its mean?

---

<div class="post-metadata">

**Author:** ![prestontim](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/prestontim/32/4354_2.png) [@prestontim](https://discuss.gradle.org/u/prestontim)\
**Post date:** [August 23, 2015, 3:39pm UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/12 "2015-08-23T15:39:40Z")

</div>

Looks like you’re missing the [Apache Ivy](http://ant.apache.org/ivy/) jar from your classpath.

---

<div class="post-metadata">

**Author:** ![Ilia1](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@Ilia1](https://discuss.gradle.org/u/Ilia1)\
**Post date:** [August 24, 2015, 1:03pm UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/13 "2015-08-24T13:03:48Z")

</div>

i wanna dependencies libs from artifactory  
i write

```
repositories {
    maven {
        url 'http://10.200.11.149:8080/artifactorylibs/'
    }
}
dependencies {
    compile 'plugin:artifactory:3.1'
    compile 'text:pdf:5.5.2'
}

```

but my java class dont see libs after compile, why? how i can do this?  
how i can add libs for project from artifactory?

---

<div class="post-metadata">

**Author:** ![Ilia1](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@Ilia1](https://discuss.gradle.org/u/Ilia1)\
**Post date:** [August 24, 2015, 1:54pm UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/14 "2015-08-24T13:54:34Z")

</div>

```
Unknown host 'services.gradle.org'.

```

error

---

<div class="post-metadata">

**Author:** ![Ilia1](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@Ilia1](https://discuss.gradle.org/u/Ilia1)\
**Post date:** [August 24, 2015, 2:31pm UTC](https://discuss.gradle.org/t/gradle-and-artifactory-for-build-java-project/11239/15 "2015-08-24T14:31:03Z")

</div>

i dont have internet
