The problem
When running gradle jar, I receive the following error message.
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve javax.units:jsr108:0.01.
Required by:
project : > org.geotools:gt2-metadata:2.5-M1
project : > org.geotools:gt2-metadata:2.5-M1 > org.opengis:geoapi-nogenerics:2.1-M8
> Could not resolve javax.units:jsr108:0.01.
> Could not parse POM http://download.osgeo.org/webdav/geotools/javax/units/jsr108/0.01/jsr108-0.01.pom
> Invalid byte 2 of 3-byte UTF-8 sequence.
I have tested this with Gradle 4.1 (currently latest) and Gradle 3.2.1, which gave the same error.
Indeed, looking at the POM file at the URL in the error, it can be seen that the encoding of that file is Windows-1252, not UTF-8. Why the error occurs is clear, but how can I address it? I cannot control the character encoding of the POM file. How do I tell Gradle about the non-UTF-8 encoding?
Reproducing this problem
Here is a minimal project to reproduce the error with.
build.gradle
apply plugin: 'java'
repositories {
maven {
url 'http://download.osgeo.org/webdav/geotools'
}
}
dependencies {
// https://mvnrepository.com/artifact/org.geotools/gt2-metadata
compile group: 'org.geotools', name: 'gt2-metadata', version: '2.5-M1'
}
src/main/java/HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Miscellaneous information
$ gradle -v
------------------------------------------------------------
Gradle 4.1
------------------------------------------------------------
Build time: 2017-08-07 14:38:48 UTC
Revision: 941559e020f6c357ebb08d5c67acdb858a3defc2
Groovy: 2.4.11
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_141 (Oracle Corporation 25.141-b15)
OS: Linux 4.11.0-2-amd64 amd64
$ java -version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-8u141-b15-3-b15)
OpenJDK 64-Bit Server VM (build 25.141-b15, mixed mode)