Configuration for Offline Jenkins Android Gradle Build Server - maven

I have been trying to maintain a build server for my team (Android development) with the following setup:
Windows Server 2008
Jenkins
Gradle plugin for Jenkins
Due to forces out of my control, the server has to be offline. It connects to an offline git repo to fetch our source code. We can get temporary internet access if needed to install updates, but otherwise the machine is offline.
However, it has been working fine for a long time (over a year). The pattern we have been using is that if we change dependencies (such as the SDK, or libraries from jcenter such as 'org.greenrobot:greendao:2.2.1') then we get temporary internet access so Gradle will download the dependencies, and then for future offline builds it uses the cache.
Recently we added a new dependency ('com.commonsware.cwac:merge:1.1.+'), which is not in jcenter, but a maven repo at https://s3.amazonaws.com/repo.commonsware.com.
There seems to be an issue with or config, or with Jenkins that prevents the new repo from being cached.
Here is the relevant snip from our root build.gradle:
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
}
}
Here is a snip from our app build.gradle:
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'org.greenrobot:greendao:2.2.1'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services-location:9.0.0'
compile 'com.commonsware.cwac:merge:1.1.+'
}
When building on Jenkins, if there is internet access the build goes fine.
However, without internet access, it will fail due to the maven repo:
java.net.ConnectException: Connection refused: connect
File C:\Users\ciandroid\.android\repositories.cfg could not be loaded.
Failed to download any source lists!
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
> Could not resolve com.commonsware.cwac:merge:1.1.+.
Required by:
My-App:app:unspecified
> Could not resolve com.commonsware.cwac:merge:1.1.+.
> Failed to list versions for com.commonsware.cwac:merge.
> Unable to load Maven meta-data from https://s3.amazonaws.com/repo.commonsware.com/com/commonsware/cwac/merge/maven-metadata.xml.
> Could not GET 'https://s3.amazonaws.com/repo.commonsware.com/com/commonsware/cwac/merge/maven-metadata.xml'.
> Connect to s3.amazonaws.com:443 [s3.amazonaws.com/52.216.0.27] failed: Connection refused: connect
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
How can I configure it to cache this other repo? What am I missing?

Related

Switch a Gradle-based Vaadin 22 app to Vaadin 23 beta

I am a Gradle newbie, having used Maven in the past.
I successfully established a Vaadin 22.0.5 project using the Vaadin Latest - Gradle starter project downloaded from Hello World Starters page. The project successfully builds and runs using gretty > apprun in IntelliJ 2021.1 EAP Ultimate edition.
👉 How do I alter the project to use the current beta version of the next version, Vaadin 23.0.0.beta2, as listed on the Vaadin releases page?
First attempt
I changed the gradle.properties file which consists of this single line:
vaadinVersion=22.0.5
… to this:
vaadinVersion=23.0.0.beta2
I clicked the floating windoid, Load Gradle Changes.
I immediately see this error appear in the IDE’s Build pane:
Build file '/Users/my_user/IdeaProjects/GetJava/build.gradle' line: 11
Plugin [id: 'com.vaadin', version: '23.0.0.beta2'] was not found in any of the following sources:
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
Second attempt
After receiving Answer by cfrick, I did the following.
If found this at the top of the build.gradle file:
buildscript {
repositories {
maven { setUrl("https://maven.vaadin.com/vaadin-prereleases") }
maven { url "https://plugins.gradle.org/m2/" }
}
}
So I made no edits there, as seemed to be accomplishing the same thing as the first part of the Answer.
I changed the entirety of the settings.gradle file from this:
pluginManagement {
plugins {
id 'com.vaadin' version "${vaadinVersion}"
}
}
… to this:
pluginManagement {
repositories {
gradlePluginPortal()
maven {
url = "https://maven.vaadin.com/vaadin-prereleases"
}
}
plugins {
id 'com.vaadin' version "${vaadinVersion}"
}
}
I changed the gradle.properties file which consists of this single line:
vaadinVersion=22.0.5
… to this, using beta1 rather than beta2 seen above.
vaadinVersion=23.0.0.beta1
After executing Tasks > build > clean, I get a BUILD SUCCESSFUL message.
But when I execute Gretty > apprun, I get the following error message.
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find com.vaadin:vaadin-bom:23.0.0.beta1.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/vaadin/vaadin-bom/23.0.0.beta1/vaadin-bom-23.0.0.beta1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :
> Could not find com.vaadin:vaadin-core:.
Required by:
project :
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Pre-release versions are released first in Vaadins own pre-release
repository. You would have to add the repository if you need access to
releases, that have not yet hit the public repos:
In build.gradle expand repositories by:
repositories {
// ...
maven {
url = "https://maven.vaadin.com/vaadin-prereleases"
}
}
In the settings.gradle add a repositories block too:
pluginManagement {
repositories {
gradlePluginPortal()
maven {
url = "https://maven.vaadin.com/vaadin-prereleases"
}
}
plugins {
id 'com.vaadin' version "${vaadinVersion}"
}
}

gradle can't download ua-parser file

I'm trying to test some jenkins job seed dsls and for that I needed to download in gradle all plugins jenkins had, one of them was blueocean and in my build.gradle I've got this line
testPlugins 'io.jenkins.blueocean:blueocean:1.23.2'
and I get thrown this exception
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find ua_parser:ua-parser:1.3.0.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.pom
- https://repo.maven.apache.org/maven2/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.jar
- http://repo.jenkins-ci.org/releases/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.pom
- http://repo.jenkins-ci.org/releases/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.jar
- https://jcenter.bintray.com/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.pom
- https://jcenter.bintray.com/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.jar
Required by:
project : > io.jenkins.blueocean:blueocean:1.23.2 > io.jenkins.blueocean:blueocean-rest-impl:1.23.2
I tried running with gradlew 4.8.1 and 6.0.1
I tried addint the ua-parser to build.gradle
compile group: 'ua_parser', name: 'ua-parser', version: '1.3.0'
I tried removing all gradle cache and refresh dependencies
rm -rf ~/.gradle/cache
./gradlew test --refresh-dependencies # or ./gradlew build ..
I disabled the vpn so it wasn't some firewall not allowing me to connect to the site, maybe I have some outdated gradle repository stored ? (I'm not familiar with gradle yet, so maybe something simple is escaping my sight)
EDIT 1:
I think this might be related to missing repository so tried adding new one by hand I found the https://github.com/jenkinsci/blueocean-plugin and tried add it to settings.gradle
sourceControl {
gitRepository("https://github.com/jenkinsci/blueocean-plugin.git") {
producesModule("org.gradle.blueocean:utilities")
}
}
and then referencing in build.gradle
dependencies {
...
implementation 'org.gradle.blueocean:utilities'
but doesn't seem to work, does anyone know how to add/where to search for gradle repositories (specifically with blueocean poms)
had to add those lines in repositories in build.gradle
repositories {
mavenCentral()
maven { url 'http://repo.jenkins-ci.org/releases/' }
maven { url 'https://mvnrepository.com/artifact/io.jenkins.blueocean' }
maven { url 'https://mvnrepository.com/artifact/ua_parser/ua-parser' }
maven { url 'https://mvnrepository.com/artifact' }
maven { url 'https://maven.twttr.com/' }

WildFly 18.0.1.Final - Error fetching WildFly component 'org.picketlink:picketlink-api:::2.5.5.SP12-redhat-00006'

Provision worked fine with WildFly: 16.0.x - 17.0.1.
Upgraded provision.gradle to upgrade to use wildFly 18.0.1.
plugins {
id "org.wildfly.build.provision" version '0.0.11'
}
repositories {
mavenLocal()
mavenCentral()
maven {
name 'jboss-nexus'
url "http://repository.jboss.org/nexus/content/groups/public/"
}
}
provision {
// Optional destination directory:
destinationDir = file("wildfly-as/18.0.1.Final")
configuration = file('wildfly-server-provisioning.xml')
// Define variables which need replacing in the provisioning configuration!
variables['wildfly.version'] = '18.0.1.Final'
variables['hibernate-orm.version'] = '5.3.7.Final'
variables['hibernate-search.version'] = '5.11.0.Final'
variables['hibernate-ogm.version'] = '5.4.1.Final'
}
Causes in:
MacBook-Pro:GoStopHandle NOTiFY$ gradle provision -b provision.gradle
Configure project :
Task :provision FAILED Error fetching WildFly component 'org.picketlink:picketlink-api:::2.5.5.SP12-redhat-00006' from
configured repositories; check your repository configurations to
prevent this problem. Attempting to resolve this by enabling
additional repositories automatically! Adding: [mavenLocal(),
mavenCentral() and
http://repository.jboss.org/nexus/content/groups/public/]
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':provision'.
Could not resolve all dependencies for configuration ':detachedConfiguration67'.
Could not find org.picketlink:picketlink-api:2.5.5.SP12-redhat-00006.
Required by:
project :
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it
incompatible with Gradle 7.0. Use '--warning-mode all' to show the
individual deprecation warnings. See
https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2s 1 actionable task: 1 executed
Any suggestions?
Deleted SDK 14 and 'export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/'.
You need to add http://maven.repository.redhat.com/ga/ as repository.

Firebase admin sdk dependency on gradle causing boot layer error

I'm trying to build a desktop app using javafx for extracting data from pdf and save the content as json in firebase. Adding the firebase admin sdk dependency on gradle causes build error. But it is working with maven projects.
I've created the gradle project using this guide- https://openjfx.io/openjfx-docs/#IDE-Intellij and for firebase admin sdk I've followed the official docs.But it keeps creating ResolutionException and mentions some modules.Adding dependencies or jars for those modules causes more module exceptions. I'm trying to avoid maven as it causes some conflicts with javafx which I also couldn't solve.
This is my current build.gradle file:
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.5'
}
group 'com.tiptoptips'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.google.firebase:firebase-admin:6.7.0'
}
javafx {
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
mainClassName = 'com.tiptoptips.MainApp'
and here is the error I get while running or building this project-
> Task :run FAILED
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules proto.google.common.protos
and gax.grpc export package com.google.longrunning to module
javafx.graphicsEmpty
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':run'.
> Process 'command '/usr/lib/jvm/java-11-openjdk-amd64/bin/java'' finished with non-zero exit value 1
Is there anything I'm doing wrong?
After about 4 days research, I found a way to solve it. I had to download the javafx-11 libs manually and add it to the project using vm options. I had to add javafx.controls and javafx.fxml manually. Then re-adding the firebase admin sdk into the gradle worked fine. I still couldn't get why intellij was showing firebase is missing module instead of locating the javafx files. Complete details can be found here- https://openjfx.io/openjfx-docs/#install-javafx

gradle build does not include jars in classpath

everyone
here is the build script
apply{
plugin 'java'
}
sourceCompatibility=1.5
List spring = ["org.springframework:spring-webmvc:$springVersion#jar",
"org.springframework:spring-orm:$springVersion#jar",
"org.springframework:spring-context-support:$springVersion#jar"]
List spring_js = [ "org.springframework.webflow:spring-js:2.0.7.RELEASE#jar",
"org.apache.ibatis:com.springsource.com.ibatis:2.3.4.726#jar",
"com.caucho:com.springsource.com.caucho:3.2.1#jar",
"org.apache.axis:com.springsource.org.apache.axis:1.4.0#jar",
"javax.wsdl:com.springsource.javax.wsdl:1.6.1#jar"]
configurations {
compile {
description = 'compile classpath'
transitive = true
}
runtime {
extendsFrom compile
}
}
def localMavenRepo = 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
repositories{
mavenCentral()
maven{
url localMavenRepo
}
}
dependencies{
compile spring, spring_js, 'commons-fileupload:commons-fileupload:1.2.1','org.apache.struts:com.springsource.org.apache.struts:1.2.9',
'javax.xml.rpc:com.springsource.javax.xml.rpc:1.1.0','org.apache.commons:com.springsource.org.apache.commons.dbcp:1.2.2.osgi',
'commons-io:commons-io:1.3.2','hsqldb:hsqldb:1.8.0.7','org.apache.tiles:tiles-jsp:2.2.0','org.tuckey:urlrewritefilter:3.1.0',
'org.apache.tiles:tiles-core:2.2.0'
runtime 'javax.servlet:jstl:1.2','org.aspectj:aspectjweaver:1.6.5','javax.servlet:servlet-api:2.5','javax.servlet.jsp:jsp-api:2.1'
testCompile 'junit:junit:4.6'
}
The jars are present in local maven repo but when I run gradle --info clean build the build fails with errors such as
/home/anadi/Code/gradle-samples/java-proj/gradleSpringJpetStore/src/main/java/org/springframework/samples/jpetstore/web/spring/SignonInterceptor.java:17: cannot find symbol
symbol : class HttpServletResponse
location: class org.springframework.samples.jpetstore.web.spring.SignonInterceptor
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
^
/home/anadi/Code/gradle-samples/java-proj/gradleSpringJpetStore/src/main/java/org/springframework/samples/jpetstore/web/spring/RemoveItemFromCartController.java:9: package org.springframework.web.util does not exist
import org.springframework.web.util.WebUtils;
^
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
Total time: 4.969 secs
If I run the same build with maven it picks up all dependencies from the local repo and does a compile successfully. I also tried the --refresh-dependencies switch but no help.
As Benjamin said, you are probably missing a dependency declaration. Note that your use of #jar disables transitive dependency resolution. #jar means " I want just this Jar, not any of the dependencies declared in its POM".
The preferred way to declare the local Maven repo is repositories { mavenLocal() }. Unless you have some other build installing into the local Maven repository and this build pulling from it, it is neither recommended nor necessary to declare mavenLocal() though. Gradle is smart enough to automatically steal Jars from the local Maven repo (to avoid downloading them) if their checksum matches.
Your configurations block can be removed completely. All of that is already configured by the java plugin.

Resources