I'm trying to use the Spire Free PDF library from the E-Iceblue repository and it just takes too long for the dependency to be downloaded on my computer. The big problem is that I use Jenkins for CI/CD and it gives me a timeout error:
What went wrong:
Execution failed for task ':compileJava'.
> Could not download spire.doc.free-3.9.0.jar (e-iceblue:spire.doc.free:3.9.0)
> Could not get resource 'http://repo.e-iceblue.com/nexus/content/groups/public/e-iceblue/spire.doc.free/3.9.0/spire.doc.free-3.9.0.jar'.
> Read timed out
I tried to increase the timeout using these two properties in the Gradle Wrapper, but without success:
/gradlew build -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.http.connectionTimeout=60000 jacocoTestReport
On my personal computer, it takes around 5 minutes to download the dependency. On my work computer, where I have the VPN provided by my company, the download time is the same: 4-5 minutes. The Jenkins that I'm using is hosted by my company to manage different projects and the Gradle file looks like this:
repositories {
mavenCentral()
maven {
url "http://repo.e-iceblue.com/nexus/content/groups/public/"
}
}
dependencies {
implementation group: 'e-iceblue', name: 'spire.doc.free', version: '3.9.0'
}
Is there something I can do to fix this issue? Or maybe there is a problem with the repository itself?
You should use "https" instead of "http":
repositories {
mavenCentral()
maven {
url "https://repo.e-iceblue.com/nexus/content/groups/public/"
}
}
Related
Trying to push the Gradle project to Github package registry, but not working as expected.
Using io.freefair.github.package-registry-maven-publish plugin for Gradle.
Configure GitHub in build.gradle with data needed to publish - code below. And run the publishing task publishAllPublicationsToGutHub. Getting no error but I can't see my package in GitHub package registry.
github {
slug
username = "myGitUserName"
token = "myTokenWithRightAccess"
tag = "HEAD"
travis = true
}
Expecting some examples of how to publish to Github package registry with Gradle or what I'm doing wrong when publishing
New answer:
GitHub has published the official guide: Configuring Gradle for use with GitHub Packages.
Old answer:
It seems like the plugin is not very stable yet. Take a look at the repository I've created that has everything set up. I managed to publish a few packages with that plugin here.
Even the packages are published, Gradle shows task as failed, due to some issues with maven-metadata.xml:
> Task :publishMainPublicationToGitHub madhead Maven PackagesRepository FAILED
Could not transfer metadata so57323260:test/maven-metadata.xml from/to remote (https://maven.pkg.github.com/madhead): Could not get resource 'so57323260/test/maven-metadata.xml'
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':publishMainPublicationToGitHub madhead Maven PackagesRepository'.
> Failed to publish publication 'main' to repository 'GitHub madhead Maven Packages'
> Could not GET 'https://maven.pkg.github.com/madhead/so57323260/test/maven-metadata.xml'. Received status code 422 from server: Unprocessable Entity
But that's ok, probably will be fixed one day.
I've noticed, that the packages might not be published (see the linked issue) because of the incorrect groupId of a Maven publication. It seems like right now it should be equal to the Github's project name. So, in my case, I had to use so57323260 as a groupId for a madhead/so57323260 project. That's not how packages work in Maven generally, so that might be your issue.
I was able to publish to the Github Package Registry using the maven-publish plugin. It seems to work just fine now.
My build.gradle file looks like this:
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id 'java'
id 'maven-publish'
}
group 'com.company.project'
archivesBaseName = 'library-name'
version '0.1.0'
repositories {
mavenCentral()
}
dependencies {
// java dependencies
}
publishing {
repositories {
maven {
name = "Github"
url = uri("https://maven.pkg.github.com/<OWNER>/<REPO>")
credentials {
username = findProperty("github.username")
password = findProperty("github.token")
}
}
}
publications {
register("jar", MavenPublication) {
from(components["java"])
pom {
url.set("https://github.com/<OWNER>/<REPO>.git")
}
}
}
}
Put your github username and token into the gradle.properties file.
Also worth setting up a github action to publish to the github package repo:
name: Publish package to GitHub Packages
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Publish package
run: gradle -Pversion=${{ github.event.release.tag_name }} build publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
This publishes a package every time we create a release tag with that tag as the version.
GitHub has published the official document for How to use Gradle with GitHub packager
https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages#authenticating-to-github-packages
Complete those properties correctly
OWNER
REPOSITORY
USERNAME (or gradle property gpr.user)
PASSWORD (or gradle property gpr.key)
#See demo
https://github.com/youngerier/packagesdemo
https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages
I am new to gradle and sonar qube. I have locally installed the sonarqube but i need to make the gradle build fail locally if the number of major issues are greater than 50.
/*
build.gradle:
Please note that this file should not be changed except for local build and deployments.
Glpdependencies.gradle and build.gradle will be overwritten from glp-core repo. However, they can be modified
for local testing purposes.
*/
buildscript {
ext {
springBootVersion = '2.0.4.RELEASE'
}
repositories {
mavenLocal()
maven { url "https://plugins.gradle.org/m2/" }
mavenCentral()
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2"
}
}
// These are gradle build dependencies and not application requirements
dependencies {
classpath 'de.undercouch.download:de.undercouch.download.gradle.plugin:3.4.3'
classpath "net.linguica.gradle:maven-settings-plugin:0.5"
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.14.0"
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:2.0.0.RELEASE"
//classpath 'io.spring.gradle:dependency-management-plugin:1.0.6.RELEASE'
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: "org.sonarqube"
sonarqube {
properties {
property "sonar.projectKey", "sum"
property "sonar.buildbreaker.skip" , "false"
}
}
group = 'com.test.sonarqube.gradle'
apply from: 'glpdependencies.gradle'
apply from: 'version.gradle'
Below is my gradle.properties:
//org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_144.
systemProp.sonar.host.url=http://localhost:9000
systemProp.sonar.sourceEncoding=UTF-8
systemProp.sonar.forceAuthentication=true
If we need to configure somewhere else then please let me know. As this is a gradle project and sonar qube server is also installed in my local system.
I am getting the type of issues etc in sonar qube server but I need to fail the build locally if the number of major issues are greater than 50.
I tried many things but it didnt worked even i added property
property "sonar.buildbreaker.skip" , "false" in build.gradle but its still not working
You're not going to be able to make the Gradle build fail* because it is a synchronous process, and what you're talking about is the application of a Quality Gate, which is an asynchronous process.
It is easy enough to set up a Quality Gate with an Error condition of Major Issues > 50, but Quality Gate status is not calculated until the end of the background task processing.
Once analysis runs locally, an analysis report is bundled and submitted to the server, where is it queued and then processed asynchronously. You can set up a webhook to notify another system when processing is complete. The webhook notification payload includes the Quality Gate stats, but that's not going to help you fail a Gradle build.
OTOH, the procedure for failing a CI build is well-established
*without great difficulty
I am getting error while building the gradle (IDE tool version 3.1.3 android)
android version : 3.1.3
gradle version : 4.4
Not able to download files below when gradle sync
Download https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom 21s 215ms
Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom 1m 24s 138ms
Download http://maven.google.com/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom 21s 84ms
Error : Connection timed out: connect
Please help me to solve this problem
Are you working behind a proxy?
try to run
./gradlew assemble --debug --info --stacktrace
And share your log information please.
Besides that, check your gradle.properties to see if you have any proxy configured? If you are not behind any proxy, please remove those settings.
Also, please be sure that "google()" repo is added and put as the first inside your buildscripts block. E.g.
buildscript {
repositories {
//jcenter() //Should remove this repository for Android Gradle Plugin 3.0+, and use google() repository as shown below
google()
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
After running gradle build in the root directory of my web app, the spring security dependency declared in build.gradle does not get downloaded.
here is my build.gradle
/*
* This build file was auto generated by running the Gradle 'init' task
* by 'hombod' at '7/19/16 4:19 PM' with Gradle 2.14.1
*
* This generated file contains a commented-out sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at https://docs.gradle.org/2.14.1/userguide/tutorial_java_projects.html
*/
// Apply the java plugin to add support for Java
apply plugin: 'java'
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
mavenCentral()
}
// In this section you declare the dependencies for your production and test code
dependencies {
// The production code uses the SLF4J logging API at compile time
compile 'org.slf4j:slf4j-api:1.7.21'
// Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
// 'test.useTestNG()' to your build script.
testCompile 'junit:junit:4.12'
compile 'org.springframework.security:spring-security-web:4.1.1.RELEASE'
}
instead, I just get this message
:compileJava UP-TO-DAT
:processResources UP-T
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava UP-TO
:processTestResources
:testClasses UP-TO-DAT
:test UP-TO-DATE
:check UP-TO-DATE
:build UP-TO-DATE
This is a spring mvc web app that I ran the gradle init command in
System caches the dependent jars so it won't be downloaded again and again.
If your goal is to just see the downloads of the dependencies then you can force it to redownload.
Remove any dependency caches stored locally [1]
$ rm -rf ~/.gradle/caches/
Then restart your build
$ gradlew clean build
You could also force a dependency update with [2]
$ gradlew --refresh-dependencies
[1]https://docs.gradle.org/current/userguide/dependency_management.html#sec:dependency_cache
[2]https://docs.gradle.org/current/userguide/dependency_management.html#sub:cache_refresh
The solution that helped in my case:
File -> Invalidate Caches/Restart...
I'm using IntelliJ 2018.2.3 and Gradle was not downloading dependencies for me.
I found that I had to uncheck the 'Offline work' box in the Gradle settings to get it to download them. I'm not sure how this box became checked because I didn't check it (honest).
EDIT: In IntelliJ 2021.2.1 Offline Mode can now be toggled in the Gradle tool window, as shown below:
If your project builds successfully some time it may be gradle download problem with a current proxy.
Gradle has it's own dependency management system similar to maven. I think parts of the gradle publish plugin are backed by maven in some way (not verified). Regardless you shouldn't have to worry about that level of depth, gradle will handle it. Your problem is setting up the proxy. You just need to set some variables in $projectDir/gradle.properties, for example:
#http proxy setup
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
This can be used to download dependencies without proxy. If you want to use a proxy for you can use the code as below instead of above code.
systemProp.https.proxyPort=3128
systemProp.http.proxyHost=192.168.16.2
systemProp.https.proxyHost=192.168.16.2
systemProp.http.proxyPort=3128
Proxy port and host can be changed as you want.
had something like this problem while was building older react-native project.
the react-native run-android command just did print:
Could not find com.android.tools.build:gradle:2.3.3
after lot of changes to the build.gradle file noticed that it was okay and
just opened the android directory of my react-native project in Android-Studio and all dependencies was downloaded.
but to prevent download of files again and again used GradleCopy to make them available offline and changed the build.gradle file like below:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
//kotlin_version = '1.2.40'
offline = 'D:/android/sdk/extras/m2repository'
}
repositories {
try { maven { url uri(offline) } } catch (Throwable e) {}
try { maven { url uri('C:/Program Files/Android/Android Studio/gradle/m2repository') } } catch (Throwable e) {}
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3' //was "2.3.3" with "gradle-3.4.1-all.zip" got "3.1.3" with "gradle-4.4-all.zip"
////below "kotlin" is required in root "build.gradle" else the "offline" repo will not get searched
//classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
try { maven { url uri(offline) } } catch (Throwable e) {}
jcenter()
mavenLocal()
maven {
url 'https://maven.google.com/'
name 'Google'
}
mavenCentral()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
(i.e. did set offline variable to my m2repository path and used it like: maven { url uri(offline) })
Choosing a right log level [1] will allow you to see what is happening behind.
-i/--info will show you whether gradle has used the cached dependency or the dependency downloaded.
gradle clean build -i
https://docs.gradle.org/current/userguide/logging.html#sec:choosing_a_log_level
I just switched from Eclipse and Maven to Android Studio and Gradle for my Android projects.
Now I would like my Jenkins server to build and upload release versions to my self hosted Nexus server.
For this I added those lines to my build.gradle
apply plugin: 'maven'
group = "de.myapp"
version = '2.2.0'
android {
...
}
uploadArchives {
repositories {
mavenDeployer {
maven {
name "snapshot_repo"
url "http://192.168.178.85:8081/nexus/content/repositories/myapp_snapshots"
credentials {
username "admin"
password "admin123"
}
}
}
}
}
The building process works fine but I can't upload any project to the Nexus server without getting this strange message:
:myapp_testname:assembleDebug
:myapp_testname:uploadArchives
Upload http://192.168.178.85:8081/nexus/content/repositories/myapp_snapshots/de/myapp/myapp_testname/2.2.0/ivy-2.2.0.xml
Upload http://192.168.178.85:8081/nexus/content/repositories/myapp_snapshots/de/myapp/myapp_testname/2.2.0/ivy-2.2.0.xml.sha1
[ant:null] Error reading settings file '/tmp/gradle_empty_settings56173630026020664.xml' - ignoring. Error was: /tmp/gradle_empty_settings56173630026020664.xml (No such file or directory)
BUILD SUCCESSFUL
Total time: 3 mins 31.555 secs
Build step 'Invoke Gradle script' changed build result to SUCCESS
Archiving artifacts
Finished: SUCCESS
I will get two ivy files on the repository but nothing more.
It seems like gradle cannot create the tmp file. But I don't know why.
When I execute this on my local windows machine I will get the same error (just with another tmp folder)
Does anyone know how to solve this issue?
Well, I just found the problem and the solution:
I'm using several flavors and buildTypes (free/premium and debug/release) in my app.
This means there is no real "default" variant.
In this case you need this line in your module's build.gradle to publish your different build types
android {
...
publishNonDefault true
...
}