1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-10 14:16:00 +01:00

Merge pull request #460 from Flowdalic/ci-java-15

Run CI also with Java 15
This commit is contained in:
Florian Schmaus 2021-02-15 13:43:48 +01:00 committed by GitHub
commit d881395d05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 66 additions and 30 deletions

View file

@ -14,6 +14,7 @@ jobs:
matrix: matrix:
java: java:
- 11 - 11
- 15
steps: steps:
- name: Checkout - name: Checkout

View file

@ -152,6 +152,7 @@ allprojects {
commonsIoVersion = '2.6' commonsIoVersion = '2.6'
bouncyCastleVersion = '1.68' bouncyCastleVersion = '1.68'
guavaVersion = '30.1-jre' guavaVersion = '30.1-jre'
mockitoVersion = '3.7.7'
if (project.hasProperty("useSonatype")) { if (project.hasProperty("useSonatype")) {
useSonatype = project.getProperty("useSonatype").toBoolean() useSonatype = project.getProperty("useSonatype").toBoolean()
@ -255,7 +256,7 @@ allprojects {
} }
jacoco { jacoco {
toolVersion = "0.8.3" toolVersion = "0.8.6"
} }
jacocoTestReport { jacocoTestReport {
@ -273,7 +274,10 @@ allprojects {
// since the one paramater addStringOption doesn't seem to // since the one paramater addStringOption doesn't seem to
// work, we extra add '-quiet', which is added anyway by // work, we extra add '-quiet', which is added anyway by
// gradle. // gradle.
options.addStringOption('Xdoclint:all', '-quiet') // TODO: This enables all doclint check but
// 'missing'. Re-enable 'missing' once every public API in
// Smack has a javadoc comment.
options.addStringOption('Xdoclint:accessibility,html,reference,syntax', '-quiet')
// Treat warnings as errors. // Treat warnings as errors.
// See also https://bugs.openjdk.java.net/browse/JDK-8200363 // See also https://bugs.openjdk.java.net/browse/JDK-8200363
@ -285,6 +289,9 @@ allprojects {
tasks.withType(Javadoc) { tasks.withType(Javadoc) {
options.addStringOption('-release', javaMajor) options.addStringOption('-release', javaMajor)
// The -no-modules-directories javadoc option was removed in Java 13
// See https://bugs.openjdk.java.net/browse/JDK-8215582
if (JavaVersion.current() < JavaVersion.VERSION_13) {
// Fix for javadoc search. If not set, the search result would direct to // Fix for javadoc search. If not set, the search result would direct to
// javadoc/undefined/org/jivesoftware/smack/altconnections/HttpLookupMethod.html // javadoc/undefined/org/jivesoftware/smack/altconnections/HttpLookupMethod.html
// instead of // instead of
@ -292,6 +299,7 @@ allprojects {
// https://stackoverflow.com/a/53732633/194894 // https://stackoverflow.com/a/53732633/194894
options.addBooleanOption("-no-module-directories", true) options.addBooleanOption("-no-module-directories", true)
} }
}
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
options.compilerArgs.addAll([ options.compilerArgs.addAll([
'--release', javaMajor, '--release', javaMajor,
@ -312,10 +320,10 @@ tasks.withType(Javadoc) {
// The smack-extensions subproject uses mockito in its fest // The smack-extensions subproject uses mockito in its fest
// fixtures, and we want to have mockito also available in // fixtures, and we want to have mockito also available in
// test, so we use API here. // test, so we use API here.
testFixturesApi "org.mockito:mockito-core:3.3.3" testFixturesApi "org.mockito:mockito-core:${mockitoVersion}"
// To mock final classes // To mock final classes
testImplementation 'org.mockito:mockito-inline:3.3.3' testImplementation "org.mockito:mockito-inline:${mockitoVersion}"
testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2' testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2'
errorprone 'com.google.errorprone:error_prone_core:2.5.1' errorprone 'com.google.errorprone:error_prone_core:2.5.1'

View file

@ -79,6 +79,12 @@ public final class ServerPingWithAlarmManager extends Manager {
}); });
} }
/**
* Get the instance of this manager for the given connection.
*
* @param connection the connection.
* @return the instance of this manager for the given connection.
*/
public static synchronized ServerPingWithAlarmManager getInstanceFor(XMPPConnection connection) { public static synchronized ServerPingWithAlarmManager getInstanceFor(XMPPConnection connection) {
ServerPingWithAlarmManager serverPingWithAlarmManager = INSTANCES.get(connection); ServerPingWithAlarmManager serverPingWithAlarmManager = INSTANCES.get(connection);
if (serverPingWithAlarmManager == null) { if (serverPingWithAlarmManager == null) {
@ -104,6 +110,11 @@ public final class ServerPingWithAlarmManager extends Manager {
mEnabled = enabled; mEnabled = enabled;
} }
/**
* Check if this manager is enabled.
*
* @return <code>true</code> if this manager is enabled, <code>false</code> otherwise.
*/
public boolean isEnabled() { public boolean isEnabled() {
return mEnabled; return mEnabled;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2018 Florian Schmaus * Copyright © 2014-2021 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -39,8 +39,8 @@ public class AndroidSmackInitializer implements SmackInitializer {
@Override @Override
public List<Exception> initialize() { public List<Exception> initialize() {
SmackConfiguration.setDefaultHostnameVerifier(new StrictHostnameVerifier()); SmackConfiguration.setDefaultHostnameVerifier(new StrictHostnameVerifier());
Base64.setEncoder(AndroidBase64Encoder.getInstance()); Base64.setEncoder(AndroidBase64Encoder.INSTANCE);
Base64UrlSafeEncoder.setEncoder(AndroidBase64UrlSafeEncoder.getInstance()); Base64UrlSafeEncoder.setEncoder(AndroidBase64UrlSafeEncoder.INSTANCE);
return null; return null;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2019 Florian Schmaus * Copyright © 2014-2021 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,10 @@ import android.util.Base64;
*/ */
public final class AndroidBase64Encoder implements org.jivesoftware.smack.util.stringencoder.Base64.Encoder { public final class AndroidBase64Encoder implements org.jivesoftware.smack.util.stringencoder.Base64.Encoder {
private static AndroidBase64Encoder instance = new AndroidBase64Encoder(); /**
* An instance of this encoder.
*/
public static AndroidBase64Encoder INSTANCE = new AndroidBase64Encoder();
private static final int BASE64_ENCODER_FLAGS = Base64.NO_WRAP; private static final int BASE64_ENCODER_FLAGS = Base64.NO_WRAP;
@ -32,10 +35,6 @@ public final class AndroidBase64Encoder implements org.jivesoftware.smack.util.s
// Use getInstance() // Use getInstance()
} }
public static AndroidBase64Encoder getInstance() {
return instance;
}
@Override @Override
public byte[] decode(String string) { public byte[] decode(String string) {
return Base64.decode(string, Base64.DEFAULT); return Base64.decode(string, Base64.DEFAULT);

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2019 Florian Schmaus * Copyright © 2014-2021 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,9 +22,16 @@ import org.jivesoftware.smack.util.stringencoder.StringEncoder;
import android.util.Base64; import android.util.Base64;
/**
* An URL-safe Base64 encoder.
* @author Florian Schmaus
*/
public final class AndroidBase64UrlSafeEncoder implements StringEncoder<String> { public final class AndroidBase64UrlSafeEncoder implements StringEncoder<String> {
private static AndroidBase64UrlSafeEncoder instance = new AndroidBase64UrlSafeEncoder(); /**
* An instance of this encoder.
*/
public static AndroidBase64UrlSafeEncoder INSTANCE = new AndroidBase64UrlSafeEncoder();
private static final int BASE64_ENCODER_FLAGS = Base64.URL_SAFE | Base64.NO_WRAP; private static final int BASE64_ENCODER_FLAGS = Base64.URL_SAFE | Base64.NO_WRAP;
@ -32,10 +39,6 @@ public final class AndroidBase64UrlSafeEncoder implements StringEncoder<String>
// Use getInstance() // Use getInstance()
} }
public static AndroidBase64UrlSafeEncoder getInstance() {
return instance;
}
@Override @Override
public String encode(String string) { public String encode(String string) {
return Base64.encodeToString(string.getBytes(StandardCharsets.UTF_8), BASE64_ENCODER_FLAGS); return Base64.encodeToString(string.getBytes(StandardCharsets.UTF_8), BASE64_ENCODER_FLAGS);

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2017 Florian Schmaus * Copyright © 2014-2021 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,6 +34,11 @@ import android.util.Log;
*/ */
public class AndroidDebugger extends AbstractDebugger { public class AndroidDebugger extends AbstractDebugger {
/**
* Constructs a new Smack debugger for Android.
*
* @param connection the connection to debug.
*/
public AndroidDebugger(XMPPConnection connection) { public AndroidDebugger(XMPPConnection connection) {
super(connection); super(connection);
} }

View file

@ -27,7 +27,9 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
* PubSub node. An <code>Item</code> has several properties that are dependent * PubSub node. An <code>Item</code> has several properties that are dependent
* on the configuration of the node to which it has been or will be published. * on the configuration of the node to which it has been or will be published.
* *
* <h3>An Item received from a node (via {@link LeafNode#getItems()} or {@link LeafNode#addItemEventListener(org.jivesoftware.smackx.pubsub.listener.ItemEventListener)}</h3> * <p>
* <b>An Item received from a node (via {@link LeafNode#getItems()} or {@link LeafNode#addItemEventListener(org.jivesoftware.smackx.pubsub.listener.ItemEventListener)}</b>
* </p>
* <ul> * <ul>
* <li>Will always have an id (either user or server generated) unless node configuration has both * <li>Will always have an id (either user or server generated) unless node configuration has both
* {@link ConfigureForm#isPersistItems()} and {@link ConfigureForm#isDeliverPayloads()}set to false. * {@link ConfigureForm#isPersistItems()} and {@link ConfigureForm#isDeliverPayloads()}set to false.
@ -35,7 +37,9 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
* to true, otherwise it will be null. * to true, otherwise it will be null.
* </ul> * </ul>
* *
* <h3>An Item created to send to a node (via {@link LeafNode#publish()} or {@link LeafNode#publish()}</h3> * <p>
* <b>An Item created to send to a node (via {@link LeafNode#publish()} or {@link LeafNode#publish()}</b>
* </p>
* <ul> * <ul>
* <li>The id is optional, since the server will generate one if necessary, but should be used if it is * <li>The id is optional, since the server will generate one if necessary, but should be used if it is
* meaningful in the context of the node. This value must be unique within the node that it is sent to, since * meaningful in the context of the node. This value must be unique within the node that it is sent to, since

View file

@ -28,7 +28,9 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
* pubsub node. An <code>Item</code> has several properties that are dependent * pubsub node. An <code>Item</code> has several properties that are dependent
* on the configuration of the node to which it has been or will be published. * on the configuration of the node to which it has been or will be published.
* *
* <h3>An Item received from a node (via {@link LeafNode#getItems()} or {@link LeafNode#addItemEventListener(org.jivesoftware.smackx.pubsub.listener.ItemEventListener)}</h3> * <p>
* <b>An Item received from a node (via {@link LeafNode#getItems()} or {@link LeafNode#addItemEventListener(org.jivesoftware.smackx.pubsub.listener.ItemEventListener)}</b>
* </p>
* <ul> * <ul>
* <li>Will always have an id (either user or server generated) unless node configuration has both * <li>Will always have an id (either user or server generated) unless node configuration has both
* {@link ConfigureForm#isPersistItems()} and {@link ConfigureForm#isDeliverPayloads()}set to false.</li> * {@link ConfigureForm#isPersistItems()} and {@link ConfigureForm#isDeliverPayloads()}set to false.</li>
@ -36,7 +38,9 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
* to true, otherwise it will be null.</li> * to true, otherwise it will be null.</li>
* </ul> * </ul>
* *
* <h3>An Item created to send to a node (via {@link LeafNode#publish()}</h3> * <p>
* <b>An Item created to send to a node (via {@link LeafNode#publish()}</b>
* </p>
* <ul> * <ul>
* <li>The id is optional, since the server will generate one if necessary, but should be used if it is * <li>The id is optional, since the server will generate one if necessary, but should be used if it is
* meaningful in the context of the node. This value must be unique within the node that it is sent to, since * meaningful in the context of the node. This value must be unique within the node that it is sent to, since
@ -45,6 +49,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
* to true.</li> * to true.</li>
* </ul> * </ul>
* *
*
* <p>To customise the payload object being returned from the {@link #getPayload()} method, you can * <p>To customise the payload object being returned from the {@link #getPayload()} method, you can
* add a custom parser as explained in {@link ItemProvider}.</p> * add a custom parser as explained in {@link ItemProvider}.</p>
* *