Skip to content

Commit

Permalink
Convert OLCUT to JPMS modules (#59)
Browse files Browse the repository at this point in the history
* Updating pom files.

* Switching to oracle-actions/setup-java.

* Adding Java 19 to CI.

* Adding missing copyright statements.

* Adding module-info.

* Moving test configurables into a separate package.

* Fixing MBTest.

* Further rearranging of test classes. Adding module-info to all projects.

* Repackaging test classes into separate maven module.

* Making the core tests pass.

* Making the json tests pass.

* Fixing edn tests.

* Fixing protobuf tests.

* Re-enabling subprocess tests.

* Patching getURLForLocation on Windows in an exploded module.

* Update pom.xml

Bumping the version of maven-enforcer-plugin.

* Updating to Java 20.

* Moving over to a static method for module path munging.

* Other small cleanups.
  • Loading branch information
Craigacp authored Aug 28, 2023
1 parent 1ecbcd0 commit 36c30c6
Show file tree
Hide file tree
Showing 354 changed files with 4,267 additions and 2,333 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/maven-macos.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: OLCUT CI (macOS x86_64, OpenJDK 8, 11, 17)
name: OLCUT CI (macOS x86_64, Java SE 17, 20)

on:
push:
Expand All @@ -15,13 +15,13 @@ jobs:
strategy:
matrix:
# test against supported LTS versions and latest
java: [ 8, 11, 17 ]
name: OLCUT - macOS OpenJDK ${{ matrix.java }}
java: [ 17, 20 ]
name: OLCUT - macOS Java SE ${{ matrix.java }}
steps:
- uses: actions/checkout@v2
- name: Setup OpenJDK
uses: actions/setup-java@v1
- name: Setup Java Development Kits built by Oracle
uses: oracle-actions/setup-java@v1.3.1
with:
java-version: ${{ matrix.java }}
release: ${{ matrix.java }}
- name: Build with Maven
run: mvn -B package --file pom.xml
12 changes: 6 additions & 6 deletions .github/workflows/maven-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: OLCUT CI (Ubuntu x86_64, OpenJDK 8, 11, 17)
name: OLCUT CI (Ubuntu x86_64, Java SE 17, 20)

on:
push:
Expand All @@ -15,13 +15,13 @@ jobs:
strategy:
matrix:
# test against supported LTS versions and latest
java: [ 8, 11, 17 ]
name: OLCUT - Ubuntu OpenJDK ${{ matrix.java }}
java: [ 17, 20 ]
name: OLCUT - Ubuntu Java SE ${{ matrix.java }}
steps:
- uses: actions/checkout@v2
- name: Setup OpenJDK
uses: actions/setup-java@v1
- name: Setup Java Development Kits built by Oracle
uses: oracle-actions/setup-java@v1.3.1
with:
java-version: ${{ matrix.java }}
release: ${{ matrix.java }}
- name: Build with Maven
run: mvn -B package --file pom.xml
12 changes: 6 additions & 6 deletions .github/workflows/maven-windows.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: OLCUT CI (Windows x86_64, OpenJDK 8, 11, 17)
name: OLCUT CI (Windows x86_64, Java SE 17, 20)

on:
push:
Expand All @@ -15,13 +15,13 @@ jobs:
strategy:
matrix:
# test against supported LTS versions and latest
java: [ 8, 11, 17 ]
name: OLCUT - Windows OpenJDK ${{ matrix.java }}
java: [ 17, 20 ]
name: OLCUT - Windows Java SE ${{ matrix.java }}
steps:
- uses: actions/checkout@v2
- name: Setup OpenJDK
uses: actions/setup-java@v1
- name: Setup Java Development Kits built by Oracle
uses: oracle-actions/setup-java@v1.3.1
with:
java-version: ${{ matrix.java }}
release: ${{ matrix.java }}
- name: Build with Maven
run: mvn -B package --file pom.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ manifest.mf

# Subproject files
olcut-core/target
olcut-core-test/target
olcut-config-json/target
olcut-config-edn/target
olcut-config-protobuf/target
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ In no particular order, they are as follows:
Utility | Description
------- | -----------
Channel, File, & IO Utils | `ChannelUtil` has helpers for interacting with `java.nio.channels`. `FileUtil` has methods for operating on directories. `IOUtil` has many many functions for building Input and OutputStreams of various kinds. These are particularly helpful for finding resources that might be in your jar, on your filesystem, or at a particular URL. Many of these methods automatically un-gzip input streams if they are gzipped.
Log Formatter | There are two `java.util.logging log formatters` (`LabsLogFormatter` and `SimpleLabsLogFormatter` that have a nice single line logging output. They also have a static method that sets all the loggers to use the appropriate formatter, which makes integrating them simpler.
Log Formatter | There are two `java.util.logging` log formatters (`LabsLogFormatter` and `SimpleLabsLogFormatter` that have a nice single line logging output. They also have a static method that sets all the loggers to use the appropriate formatter, which makes integrating them simpler.
LRA Cache | An extension of a LinkedHashMap that acts as a least recently accessed cache.
Date Parser | The CDateParser can parse dates in almost 90 different formats that we've seen, returning a Java Date object without complaining.
Getopt | Getopt is now deprecated. Use [Options Processing](README-Options.md) instead. This is still here if you need something small and simple.
Expand Down
3 changes: 1 addition & 2 deletions olcut-config-edn/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>olcut-core</artifactId>
<artifactId>olcut-core-test</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
40 changes: 40 additions & 0 deletions olcut-config-edn/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates.
*
* Licensed under the 2-clause BSD license.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

module com.oracle.labs.mlrg.olcut.config.edn {
requires java.base;
requires java.logging;

requires edn.java;

requires com.oracle.labs.mlrg.olcut.core;

exports com.oracle.labs.mlrg.olcut.config.edn;

opens com.oracle.labs.mlrg.olcut.config.edn to com.oracle.labs.mlrg.olcut.core;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2020, Oracle and/or its affiliates.
* Copyright (c) 2004, 2023, Oracle and/or its affiliates.
*
* Licensed under the 2-clause BSD license.
*
Expand All @@ -26,9 +26,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

package com.oracle.labs.mlrg.olcut.config.edn;
package com.oracle.labs.mlrg.olcut.config.edn.test;

import com.oracle.labs.mlrg.olcut.config.AllFieldsConfigurable;
import com.oracle.labs.mlrg.olcut.config.edn.EdnConfigFactory;
import com.oracle.labs.mlrg.olcut.test.config.AllFieldsConfigurable;
import com.oracle.labs.mlrg.olcut.config.ConfigurationManager;

import java.io.File;
Expand All @@ -51,6 +52,8 @@
*/
public class AllFieldsConfiguredTest {

private static final String path = ConfigurationManager.createModuleResourceString(AllFieldsConfiguredTest.class, "allConfig.edn");

private File f;

@BeforeAll
Expand All @@ -68,14 +71,14 @@ public void setUp() throws IOException {

@Test
public void loadConfig() throws IOException {
ConfigurationManager cm = new ConfigurationManager("allConfig.edn");
ConfigurationManager cm = new ConfigurationManager(path);
AllFieldsConfigurable ac = (AllFieldsConfigurable) cm.lookup("all-config");
assertNotNull(ac, "Failed to load all-config");
}

@Test
public void saveConfig() throws IOException {
ConfigurationManager cm1 = new ConfigurationManager("allConfig.edn");
ConfigurationManager cm1 = new ConfigurationManager(path);
AllFieldsConfigurable ac1 = (AllFieldsConfigurable) cm1.lookup("all-config");
cm1.save(f, true);
ConfigurationManager cm2 = new ConfigurationManager(replaceBackSlashes(f.toString()));
Expand All @@ -85,7 +88,7 @@ public void saveConfig() throws IOException {

@Test
public void generateConfig() throws IOException {
AllFieldsConfigurable ac = com.oracle.labs.mlrg.olcut.config.AllFieldsConfiguredTest.generateConfigurable();
AllFieldsConfigurable ac = AllFieldsConfigurable.generateConfigurable();
ConfigurationManager cm1 = new ConfigurationManager();
cm1.importConfigurable(ac,"all-config");
cm1.save(f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

package com.oracle.labs.mlrg.olcut.config.edn;
package com.oracle.labs.mlrg.olcut.config.edn.test;

import com.oracle.labs.mlrg.olcut.config.ConfigurationManager;
import com.oracle.labs.mlrg.olcut.config.Option;
import com.oracle.labs.mlrg.olcut.config.Options;
import com.oracle.labs.mlrg.olcut.config.StringListConfigurable;
import com.oracle.labs.mlrg.olcut.test.config.StringListConfigurable;

import java.io.IOException;
import org.junit.jupiter.api.Test;
Expand All @@ -43,13 +43,14 @@ public class ArgumentParsingTest {

@Test
public void testConfigLoading() throws IOException {
String[] args = new String[]{"-c","stringListConfig.edn","--other-arguments","that-get-in-the-way", "--config-file-formats", "com.oracle.labs.mlrg.olcut.config.edn.EdnConfigFactory"};
String moduleStub = this.getClass().getName() + "|";
String[] args = new String[]{"-c", moduleStub + "stringListConfig.edn","--other-arguments","that-get-in-the-way", "--config-file-formats", "com.oracle.labs.mlrg.olcut.config.edn.EdnConfigFactory"};
loadFromArgs("-c",args);
args = new String[]{"--config-file-formats", "com.oracle.labs.mlrg.olcut.config.edn.EdnConfigFactory", "--config-file","stringListConfig.edn","--other-arguments","that-get-in-the-way"};
args = new String[]{"--config-file-formats", "com.oracle.labs.mlrg.olcut.config.edn.EdnConfigFactory", "--config-file", moduleStub + "stringListConfig.edn","--other-arguments","that-get-in-the-way"};
loadFromArgs("--config-file",args);
args = new String[]{"-o","--config-file","stringListConfig.edn,componentListConfig.edn", "--config-file-formats", "com.oracle.labs.mlrg.olcut.config.edn.EdnConfigFactory","-s"};
args = new String[]{"-o","--config-file", moduleStub + "stringListConfig.edn," + moduleStub + "componentListConfig.edn", "--config-file-formats", "com.oracle.labs.mlrg.olcut.config.edn.EdnConfigFactory","-s"};
loadFromArgs("--config-file with multiple files",args);
args = new String[]{"-o","--config-file","componentListConfig.edn","-s", "--config-file-formats", "com.oracle.labs.mlrg.olcut.config.edn.EdnConfigFactory","-c","stringListConfig.edn"};
args = new String[]{"-o","--config-file", moduleStub + "componentListConfig.edn","-s", "--config-file-formats", "com.oracle.labs.mlrg.olcut.config.edn.EdnConfigFactory","-c", moduleStub + "stringListConfig.edn"};
loadFromArgs("overriding --config-file with -c",args);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2020, Oracle and/or its affiliates.
* Copyright (c) 2004, 2023, Oracle and/or its affiliates.
*
* Licensed under the 2-clause BSD license.
*
Expand All @@ -26,15 +26,16 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

package com.oracle.labs.mlrg.olcut.config.edn;
package com.oracle.labs.mlrg.olcut.config.edn.test;

import com.oracle.labs.mlrg.olcut.config.ArrayStringConfigurable;
import com.oracle.labs.mlrg.olcut.config.edn.EdnConfigFactory;
import com.oracle.labs.mlrg.olcut.test.config.ArrayStringConfigurable;
import com.oracle.labs.mlrg.olcut.config.Configurable;
import com.oracle.labs.mlrg.olcut.config.ConfigurationManager;
import com.oracle.labs.mlrg.olcut.config.ListConfigurable;
import com.oracle.labs.mlrg.olcut.test.config.ListConfigurable;
import com.oracle.labs.mlrg.olcut.config.PropertyException;
import com.oracle.labs.mlrg.olcut.config.SimpleConfigurable;
import com.oracle.labs.mlrg.olcut.config.StringConfigurable;
import com.oracle.labs.mlrg.olcut.test.config.SimpleConfigurable;
import com.oracle.labs.mlrg.olcut.test.config.StringConfigurable;

import java.io.IOException;
import java.util.List;
Expand All @@ -52,6 +53,7 @@
* A set of tests for component lists.
*/
public class ComponentListTest {
private static final String path = ConfigurationManager.createModuleResourceString(ComponentListTest.class, "componentListConfig.edn");

@BeforeAll
public static void setUpClass() throws Exception {
Expand All @@ -60,7 +62,7 @@ public static void setUpClass() throws Exception {

@Test
public void componentListTest() throws IOException {
ConfigurationManager cm = new ConfigurationManager("componentListConfig.edn");
ConfigurationManager cm = new ConfigurationManager(path);
ListConfigurable lc = (ListConfigurable) cm.lookup("simple");
List<Configurable> l = lc.getList();
assertEquals(2, l.size());
Expand All @@ -72,7 +74,7 @@ public void componentListTest() throws IOException {
@Test
public void badComponentListTest() throws IOException {
assertThrows(PropertyException.class, () -> {
ConfigurationManager cm = new ConfigurationManager("componentListConfig.edn");
ConfigurationManager cm = new ConfigurationManager(path);
ListConfigurable lc = (ListConfigurable) cm.lookup("bad");
for (Configurable c : lc.getList()) {
assertNotNull(c);
Expand All @@ -82,7 +84,7 @@ public void badComponentListTest() throws IOException {

@Test
public void simpleTypedTest() throws IOException {
ConfigurationManager cm = new ConfigurationManager("componentListConfig.edn");
ConfigurationManager cm = new ConfigurationManager(path);
ListConfigurable lc = (ListConfigurable) cm.lookup("typed");
List<Configurable> l = lc.getList();
assertTrue(l.size() == 3);
Expand All @@ -94,7 +96,7 @@ public void simpleTypedTest() throws IOException {

@Test
public void dualTypedTest() throws IOException {
ConfigurationManager cm = new ConfigurationManager("componentListConfig.edn");
ConfigurationManager cm = new ConfigurationManager(path);
ListConfigurable lc = (ListConfigurable) cm.lookup("dualtyped");
List<Configurable> l = lc.getList();
assertTrue(l.size() == 5);
Expand All @@ -117,7 +119,7 @@ public void dualTypedTest() throws IOException {

@Test
public void comboTypedTest() throws IOException {
ConfigurationManager cm = new ConfigurationManager("componentListConfig.edn");
ConfigurationManager cm = new ConfigurationManager(path);
ListConfigurable lc = (ListConfigurable) cm.lookup("combotyped");
List<Configurable> l = lc.getList();
assertTrue(l.size() == 4);
Expand All @@ -139,7 +141,7 @@ public void comboTypedTest() throws IOException {

@Test
public void stringConfigurableArrayTest() throws IOException {
ConfigurationManager cm = new ConfigurationManager("componentListConfig.edn");
ConfigurationManager cm = new ConfigurationManager(path);
ArrayStringConfigurable lc = (ArrayStringConfigurable) cm.lookup("stringconfigurablearray");
StringConfigurable[] l = lc.getArray();
assertTrue(l.length == 3);
Expand All @@ -154,7 +156,7 @@ public void stringConfigurableArrayTest() throws IOException {
@Test
public void stringConfigurableBrokenArrayTest() throws IOException {
assertThrows(PropertyException.class, () -> {
ConfigurationManager cm = new ConfigurationManager("componentListConfig.edn");
ConfigurationManager cm = new ConfigurationManager(path);
ArrayStringConfigurable lc = (ArrayStringConfigurable) cm.lookup("stringconfigurablearraybroken");
}, "Did not throw PropertyException when asking for unknown element in configurable array.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2020, Oracle and/or its affiliates.
* Copyright (c) 2004, 2023, Oracle and/or its affiliates.
*
* Licensed under the 2-clause BSD license.
*
Expand All @@ -26,10 +26,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

package com.oracle.labs.mlrg.olcut.config.edn;
package com.oracle.labs.mlrg.olcut.config.edn.test;

import com.oracle.labs.mlrg.olcut.config.ConfigurationManager;
import com.oracle.labs.mlrg.olcut.config.FooMapConfigurable;
import com.oracle.labs.mlrg.olcut.config.edn.EdnConfigFactory;
import com.oracle.labs.mlrg.olcut.test.config.FooMapConfigurable;

import java.io.File;
import java.io.IOException;
Expand All @@ -44,6 +45,7 @@
*
*/
public class ConfigurablePropertyMapTest {
private static final String path = ConfigurationManager.createModuleResourceString(ConfigurablePropertyMapTest.class, "configurablePropMap.edn");

public File f;

Expand All @@ -60,7 +62,7 @@ public void setUp() throws IOException {

@Test
public void configurablePropMap() throws IOException {
ConfigurationManager cm = new ConfigurationManager("configurablePropMap.edn");
ConfigurationManager cm = new ConfigurationManager(path);

FooMapConfigurable fm = (FooMapConfigurable) cm.lookup("fooMap");

Expand All @@ -73,7 +75,7 @@ public void configurablePropMap() throws IOException {

@Test
public void saveAllWithInstantiationGeneric() throws IOException {
ConfigurationManager cm1 = new ConfigurationManager("configurablePropMap.edn");
ConfigurationManager cm1 = new ConfigurationManager(path);
FooMapConfigurable s1 = (FooMapConfigurable) cm1.lookup("fooMap");
cm1.save(f, true);
assertEquals(3, cm1.getNumInstantiated());
Expand All @@ -84,7 +86,7 @@ public void saveAllWithInstantiationGeneric() throws IOException {

@Test
public void saveAllWithNoInstantiationGeneric() throws IOException {
ConfigurationManager cm1 = new ConfigurationManager("configurablePropMap.edn");
ConfigurationManager cm1 = new ConfigurationManager(path);
cm1.save(f, true);
assertEquals(0, cm1.getNumInstantiated());
ConfigurationManager cm2 = new ConfigurationManager(replaceBackSlashes(f.toString()));
Expand Down
Loading

0 comments on commit 36c30c6

Please sign in to comment.