1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-21 22:02:06 +01:00

gradle: Remove archives configuration

and FileTestUtil in favor of commons-io. This is required because
Eclipse won't put src/test code into the classpath of src/main
code (even though gradle was configured with an according
dependency).
This commit is contained in:
Florian Schmaus 2019-09-15 23:51:26 +02:00
parent 89cb3f679b
commit 2f667f95a8
18 changed files with 30 additions and 114 deletions

View file

@ -131,6 +131,7 @@ allprojects {
].collect { project(it) } ].collect { project(it) }
junitVersion = '5.4.2' junitVersion = '5.4.2'
powerMockVersion = '2.0.2' powerMockVersion = '2.0.2'
commonsIoVersion = '2.6'
} }
group = 'org.igniterealtime.smack' group = 'org.igniterealtime.smack'
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
@ -408,10 +409,6 @@ subprojects {
} }
artifacts { artifacts {
// TODO delete those?
archives sourcesJar
archives javadocJar
archives testsJar
// See http://stackoverflow.com/a/21946676/194894 // See http://stackoverflow.com/a/21946676/194894
testRuntime testsJar testRuntime testsJar
} }

View file

@ -1,72 +0,0 @@
/**
*
* Copyright © 2018 Paul Schaub
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack.test.util;
import java.io.File;
import java.util.Stack;
public class FileTestUtil {
/**
* Returns a {@link File} pointing to a temporary directory. On unix like systems this might be {@code /tmp}
* for example.
* If {@code suffix} is not null, the returned file points to {@code <temp>/suffix}.
*
* @param suffix optional path suffix
* @return temp directory
*/
public static File getTempDir(String suffix) {
String temp = System.getProperty("java.io.tmpdir");
if (temp == null) {
temp = "tmp";
}
if (suffix == null) {
return new File(temp);
} else {
return new File(temp, suffix);
}
}
/**
* Recursively delete a directory and its contents.
*
* @param root root directory
*/
public static void deleteDirectory(File root) {
if (!root.exists()) {
return;
}
File[] currList;
Stack<File> stack = new Stack<>();
stack.push(root);
while (!stack.isEmpty()) {
if (stack.lastElement().isDirectory()) {
currList = stack.lastElement().listFiles();
if (currList != null && currList.length > 0) {
for (File curr : currList) {
stack.push(curr);
}
} else {
stack.pop().delete();
}
} else {
stack.pop().delete();
}
}
}
}

View file

@ -8,7 +8,6 @@ dependencies {
compile project(':smack-core') compile project(':smack-core')
compile project(':smack-extensions') compile project(':smack-extensions')
testCompile project(path: ":smack-core", configuration: "testRuntime") testCompile project(path: ":smack-core", configuration: "testRuntime")
testCompile project(path: ":smack-core", configuration: "archives")
testCompile project(path: ":smack-extensions", configuration: "testRuntime") testCompile project(path: ":smack-extensions", configuration: "testRuntime")
compile "org.bouncycastle:bcprov-jdk15on:$bouncyCastleVersion" compile "org.bouncycastle:bcprov-jdk15on:$bouncyCastleVersion"

View file

@ -11,5 +11,4 @@ dependencies {
// e.g. message delivery receipts the roster // e.g. message delivery receipts the roster
compile project(':smack-im') compile project(':smack-im')
testCompile project(path: ":smack-core", configuration: "testRuntime") testCompile project(path: ":smack-core", configuration: "testRuntime")
testCompile project(path: ":smack-core", configuration: "archives")
} }

View file

@ -8,5 +8,4 @@ Roster, Chat and other functionality."""
dependencies { dependencies {
compile project(':smack-core') compile project(':smack-core')
testCompile project(path: ":smack-core", configuration: "testRuntime") testCompile project(path: ":smack-core", configuration: "testRuntime")
testCompile project(path: ":smack-core", configuration: "archives")
} }

View file

@ -14,9 +14,9 @@ dependencies {
compile project(':smack-omemo') compile project(':smack-omemo')
compile project(':smack-openpgp') compile project(':smack-openpgp')
compile project(':smack-debug') compile project(':smack-debug')
compile project(path: ":smack-omemo", configuration: "testRuntime")
compile 'org.reflections:reflections:0.9.11' compile 'org.reflections:reflections:0.9.11'
compile 'eu.geekplace.javapinning:java-pinning-java7:1.1.0-alpha1' compile 'eu.geekplace.javapinning:java-pinning-java7:1.1.0-alpha1'
compile group: 'commons-io', name: 'commons-io', version: "$commonsIoVersion"
// Note that the junit-vintage-engine runtime dependency is not // Note that the junit-vintage-engine runtime dependency is not
// directly required, but it declares a dependency to // directly required, but it declares a dependency to
// junit:junit:4.12, which we currently need in sinttest, since it // junit:junit:4.12, which we currently need in sinttest, since it
@ -25,6 +25,7 @@ dependencies {
compile 'junit:junit:4.12' compile 'junit:junit:4.12'
// Add Junit 5 API for e.g. assertThrows() // Add Junit 5 API for e.g. assertThrows()
implementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" implementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testCompile project(path: ":smack-core", configuration: "testRuntime")
testCompile "org.jxmpp:jxmpp-jid:$jxmppVersion:tests" testCompile "org.jxmpp:jxmpp-jid:$jxmppVersion:tests"
} }

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jivesoftware.smackx.omemo.util; package org.jivesoftware.smackx.omemo;
import java.util.HashMap; import java.util.HashMap;

View file

@ -33,7 +33,6 @@ import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
import org.jivesoftware.smackx.omemo.internal.OmemoCachedDeviceList; import org.jivesoftware.smackx.omemo.internal.OmemoCachedDeviceList;
import org.jivesoftware.smackx.omemo.internal.OmemoDevice; import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint; import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
import org.jivesoftware.smackx.omemo.util.EphemeralTrustCallback;
import org.jivesoftware.smackx.omemo.util.OmemoConstants; import org.jivesoftware.smackx.omemo.util.OmemoConstants;
import org.jivesoftware.smackx.pubsub.PubSubException; import org.jivesoftware.smackx.pubsub.PubSubException;
import org.jivesoftware.smackx.pubsub.PubSubManager; import org.jivesoftware.smackx.pubsub.PubSubManager;

View file

@ -32,7 +32,6 @@ import java.util.logging.Level;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.test.util.FileTestUtil;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.ox.callback.backup.AskForBackupCodeCallback; import org.jivesoftware.smackx.ox.callback.backup.AskForBackupCodeCallback;
import org.jivesoftware.smackx.ox.callback.backup.DisplayBackupCodeCallback; import org.jivesoftware.smackx.ox.callback.backup.DisplayBackupCodeCallback;
@ -63,8 +62,9 @@ import org.pgpainless.key.protection.UnprotectedKeysProtector;
public class OXSecretKeyBackupIntegrationTest extends AbstractOpenPgpIntegrationTest { public class OXSecretKeyBackupIntegrationTest extends AbstractOpenPgpIntegrationTest {
private static final String sessionId = StringUtils.randomString(10); private static final String sessionId = StringUtils.randomString(10);
private static final File beforePath = FileTestUtil.getTempDir("ox_backup_" + sessionId); private static final File tempDir = org.apache.commons.io.FileUtils.getTempDirectory();
private static final File afterPath = FileTestUtil.getTempDir("ox_restore_" + sessionId); private static final File beforePath = new File(tempDir, "ox_backup_" + sessionId);
private static final File afterPath = new File(tempDir, "ox_restore_" + sessionId);
private String backupCode = null; private String backupCode = null;
@ -108,10 +108,10 @@ public class OXSecretKeyBackupIntegrationTest extends AbstractOpenPgpIntegration
@AfterClass @AfterClass
@BeforeClass @BeforeClass
public static void cleanStore() { public static void cleanStore() throws IOException {
LOGGER.log(Level.INFO, "Delete store directories..."); LOGGER.log(Level.INFO, "Delete store directories...");
FileTestUtil.deleteDirectory(afterPath); org.apache.commons.io.FileUtils.deleteDirectory(afterPath);
FileTestUtil.deleteDirectory(beforePath); org.apache.commons.io.FileUtils.deleteDirectory(beforePath);
} }
@After @After

View file

@ -20,12 +20,12 @@ import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.assertTrue;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.test.util.FileTestUtil;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.ox.AbstractOpenPgpIntegrationTest; import org.jivesoftware.smackx.ox.AbstractOpenPgpIntegrationTest;
import org.jivesoftware.smackx.ox.OpenPgpContact; import org.jivesoftware.smackx.ox.OpenPgpContact;
@ -49,8 +49,9 @@ import org.pgpainless.key.protection.UnprotectedKeysProtector;
public class OXInstantMessagingIntegrationTest extends AbstractOpenPgpIntegrationTest { public class OXInstantMessagingIntegrationTest extends AbstractOpenPgpIntegrationTest {
private static final String sessionId = StringUtils.randomString(10); private static final String sessionId = StringUtils.randomString(10);
private static final File aliceStorePath = FileTestUtil.getTempDir("basic_ox_messaging_test_alice_" + sessionId); private static final File tempDir = org.apache.commons.io.FileUtils.getTempDirectory();
private static final File bobStorePath = FileTestUtil.getTempDir("basic_ox_messaging_test_bob_" + sessionId); private static final File aliceStorePath = new File(tempDir, "basic_ox_messaging_test_alice_" + sessionId);
private static final File bobStorePath = new File(tempDir, "basic_ox_messaging_test_bob_" + sessionId);
private OpenPgpV4Fingerprint aliceFingerprint = null; private OpenPgpV4Fingerprint aliceFingerprint = null;
private OpenPgpV4Fingerprint bobFingerprint = null; private OpenPgpV4Fingerprint bobFingerprint = null;
@ -95,10 +96,10 @@ public class OXInstantMessagingIntegrationTest extends AbstractOpenPgpIntegratio
@BeforeClass @BeforeClass
@AfterClass @AfterClass
public static void deleteStore() { public static void deleteStore() throws IOException {
LOGGER.log(Level.INFO, "Deleting storage directories..."); LOGGER.log(Level.INFO, "Deleting storage directories...");
FileTestUtil.deleteDirectory(aliceStorePath); org.apache.commons.io.FileUtils.deleteDirectory(aliceStorePath);
FileTestUtil.deleteDirectory(bobStorePath); org.apache.commons.io.FileUtils.deleteDirectory(bobStorePath);
} }
@SmackIntegrationTest @SmackIntegrationTest

View file

@ -15,5 +15,5 @@ dependencies {
compile 'org.pgpainless:pgpainless-core:0.0.1-alpha7' compile 'org.pgpainless:pgpainless-core:0.0.1-alpha7'
testCompile project(path: ":smack-core", configuration: "testRuntime") testCompile project(path: ":smack-core", configuration: "testRuntime")
testCompile project(path: ":smack-core", configuration: "archives") testCompile group: 'commons-io', name: 'commons-io', version: "$commonsIoVersion"
} }

View file

@ -35,7 +35,6 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.jivesoftware.smack.test.util.FileTestUtil;
import org.jivesoftware.smack.test.util.SmackTestSuite; import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.ox.callback.SecretKeyPassphraseCallback; import org.jivesoftware.smackx.ox.callback.SecretKeyPassphraseCallback;
@ -78,7 +77,7 @@ public class OpenPgpStoreTest extends SmackTestSuite {
private final OpenPgpStore openPgpStoreInstance2; private final OpenPgpStore openPgpStoreInstance2;
static { static {
storagePath = FileTestUtil.getTempDir("storeTest"); storagePath = new File(org.apache.commons.io.FileUtils.getTempDirectory(), "storeTest");
} }
@Parameterized.Parameters @Parameterized.Parameters
@ -99,8 +98,8 @@ public class OpenPgpStoreTest extends SmackTestSuite {
@Before @Before
@After @After
public void deletePath() { public void deletePath() throws IOException {
FileTestUtil.deleteDirectory(storagePath); org.apache.commons.io.FileUtils.deleteDirectory(storagePath);
} }
/* /*

View file

@ -32,7 +32,6 @@ import java.util.List;
import org.jivesoftware.smack.DummyConnection; import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.test.util.FileTestUtil;
import org.jivesoftware.smack.test.util.SmackTestSuite; import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.xml.XmlPullParserException; import org.jivesoftware.smack.xml.XmlPullParserException;
@ -63,13 +62,13 @@ public class PainlessOpenPgpProviderTest extends SmackTestSuite {
private static final BareJid bob = JidTestUtil.BARE_JID_2; private static final BareJid bob = JidTestUtil.BARE_JID_2;
static { static {
storagePath = FileTestUtil.getTempDir("smack-painlessprovidertest"); storagePath = new File(org.apache.commons.io.FileUtils.getTempDirectory(), "smack-painlessprovidertest");
} }
@BeforeClass @BeforeClass
@AfterClass @AfterClass
public static void deletePath() { public static void deletePath() throws IOException {
FileTestUtil.deleteDirectory(storagePath); org.apache.commons.io.FileUtils.deleteDirectory(storagePath);
} }
@Test @Test

View file

@ -28,7 +28,6 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import org.jivesoftware.smack.DummyConnection; import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.test.util.FileTestUtil;
import org.jivesoftware.smack.test.util.SmackTestSuite; import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.ox.crypto.PainlessOpenPgpProvider; import org.jivesoftware.smackx.ox.crypto.PainlessOpenPgpProvider;
@ -55,7 +54,7 @@ public class SecretKeyBackupHelperTest extends SmackTestSuite {
private static final File basePath; private static final File basePath;
static { static {
basePath = FileTestUtil.getTempDir("ox_secret_keys"); basePath = new File(org.apache.commons.io.FileUtils.getTempDirectory(), "ox_secret_keys");
} }
@Test @Test
@ -98,7 +97,7 @@ public class SecretKeyBackupHelperTest extends SmackTestSuite {
@AfterClass @AfterClass
@BeforeClass @BeforeClass
public static void deleteDirs() { public static void deleteDirs() throws IOException {
FileTestUtil.deleteDirectory(basePath); org.apache.commons.io.FileUtils.deleteDirectory(basePath);
} }
} }

View file

@ -34,7 +34,6 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.test.util.FileTestUtil;
import org.jivesoftware.smack.test.util.SmackTestSuite; import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.xml.XmlPullParserException; import org.jivesoftware.smack.xml.XmlPullParserException;
@ -63,7 +62,7 @@ public class OXInstantMessagingManagerTest extends SmackTestSuite {
private static final File basePath; private static final File basePath;
static { static {
basePath = FileTestUtil.getTempDir("ox_im_test_" + StringUtils.randomString(10)); basePath = new File(org.apache.commons.io.FileUtils.getTempDirectory(), "ox_im_test_" + StringUtils.randomString(10));
} }
@Test @Test
@ -169,7 +168,7 @@ public class OXInstantMessagingManagerTest extends SmackTestSuite {
@AfterClass @AfterClass
@BeforeClass @BeforeClass
public static void deleteDirs() { public static void deleteDirs() throws IOException {
FileTestUtil.deleteDirectory(basePath); org.apache.commons.io.FileUtils.deleteDirectory(basePath);
} }
} }

View file

@ -23,7 +23,6 @@ dependencies {
compile "org.scala-lang:scala-library:$scalaVersion" compile "org.scala-lang:scala-library:$scalaVersion"
compile "com.lihaoyi:ammonite_$scalaVersion:1.3.2" compile "com.lihaoyi:ammonite_$scalaVersion:1.3.2"
testCompile project(path: ":smack-core", configuration: "testRuntime") testCompile project(path: ":smack-core", configuration: "testRuntime")
testCompile project(path: ":smack-core", configuration: "archives")
} }
scalaStyle { scalaStyle {

View file

@ -5,5 +5,4 @@ Use javax.security.sasl for SASL."""
dependencies { dependencies {
compile project(':smack-core') compile project(':smack-core')
testCompile project(path: ":smack-core", configuration: "testRuntime") testCompile project(path: ":smack-core", configuration: "testRuntime")
testCompile project(path: ":smack-core", configuration: "archives")
} }

View file

@ -5,5 +5,4 @@ Use Smack provided code for SASL."""
dependencies { dependencies {
compile project(':smack-core') compile project(':smack-core')
testCompile project(path: ":smack-core", configuration: "testRuntime") testCompile project(path: ":smack-core", configuration: "testRuntime")
testCompile project(path: ":smack-core", configuration: "archives")
} }