Skip to content

Commit

Permalink
build: Prepare codebase for Java modules
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Feb 10, 2023
1 parent bf2677d commit 039fb63
Show file tree
Hide file tree
Showing 28 changed files with 80 additions and 40 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ config {
quality {
checkstyle {
toolVersion = checkstyleVersion
exclude('module-info.*')
aggregate {
enabled = true
}
Expand Down
33 changes: 33 additions & 0 deletions core/jarviz-core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2022-2023 The Jarviz authors.
*
* 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
*
* https://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.
*/

/**
* @author Andres Almiray
* @since 0.3.0
*/
module org.kordamp.jarviz.core {
exports org.kordamp.jarviz.bundle;
exports org.kordamp.jarviz.core;
exports org.kordamp.jarviz.core.bytecode;
exports org.kordamp.jarviz.core.model;
exports org.kordamp.jarviz.core.modules;
exports org.kordamp.jarviz.core.processors;
exports org.kordamp.jarviz.core.services;
exports org.kordamp.jarviz.reporting;
exports org.kordamp.jarviz.util;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kordamp.jarviz.core.resolvers;
package org.kordamp.jarviz.core;

import org.kordamp.jarviz.core.JarFileResolver;
import org.kordamp.jarviz.core.resolvers.GavBasedJarFileResolver;
import org.kordamp.jarviz.core.resolvers.PathBasedJarFileResolver;
import org.kordamp.jarviz.core.resolvers.UrlBasedJarFileResolver;

import java.net.URL;
import java.nio.file.Path;
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jdksPluginVersion = 1.4.0
moditectPluginVersion = 1.0.0-rc3

asmVersion = 9.4
checkstyleVersion = 10.5.0
checkstyleVersion = 10.7.0
hamcrestVersion = 2.2
jipsyVersion = 1.1.1
junitVersion = 4.13.2
Expand Down
5 changes: 4 additions & 1 deletion plugins/jarviz-cli/jarviz-cli.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ application {

jar {
manifest {
attributes('Main-Class': 'org.kordamp.jarviz.cli.Main')
attributes([
'Main-Class': 'org.kordamp.jarviz.cli.Main',
'Automatic-Module-Name': 'org.kordamp.jarviz.cli'
])
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package org.kordamp.jarviz.cli;

import org.kordamp.jarviz.cli.bytecode.Bytecode;
import org.kordamp.jarviz.cli.internal.Banner;
import org.kordamp.jarviz.cli.internal.BaseCommand;
import org.kordamp.jarviz.cli.manifest.Manifest;
import org.kordamp.jarviz.cli.services.Services;
import picocli.AutoComplete;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.bytecode;

import org.kordamp.jarviz.cli.AbstractJarvizCommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizCommand;
import org.kordamp.jarviz.cli.Main;
import picocli.CommandLine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.bytecode;

import org.kordamp.jarviz.cli.AbstractJarvizSubcommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizSubcommand;
import org.kordamp.jarviz.cli.internal.Colorizer;
import org.kordamp.jarviz.core.JarFileResolver;
import org.kordamp.jarviz.core.bytecode.ShowBytecodeJarProcessor;
Expand All @@ -33,7 +33,7 @@
import java.util.Set;

import static java.util.stream.Collectors.joining;
import static org.kordamp.jarviz.core.resolvers.JarFileResolvers.createJarFileResolver;
import static org.kordamp.jarviz.core.JarFileResolvers.createJarFileResolver;

/**
* @author Andres Almiray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.bytecode;

import org.kordamp.jarviz.cli.AbstractJarvizSubcommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizSubcommand;
import picocli.CommandLine;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kordamp.jarviz.cli;
package org.kordamp.jarviz.cli.internal;

import org.kordamp.jarviz.cli.IO;
import picocli.CommandLine;

import java.io.PrintWriter;
Expand All @@ -27,8 +28,7 @@
* @since 0.1.0
*/
@CommandLine.Command(mixinStandardHelpOptions = true,
versionProvider = Versions.class,
resourceBundle = "org.kordamp.jarviz.cli.Messages")
versionProvider = Versions.class)
public abstract class AbstractCommand<C extends IO> extends BaseCommand implements Callable<Integer>, IO {
protected abstract C parent();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kordamp.jarviz.cli;
package org.kordamp.jarviz.cli.internal;

import org.kordamp.jarviz.cli.IO;
import picocli.CommandLine;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kordamp.jarviz.cli;
package org.kordamp.jarviz.cli.internal;

import org.kordamp.jarviz.bundle.RB;
import org.kordamp.jarviz.cli.IO;
import org.kordamp.jarviz.core.JarvizException;
import org.kordamp.jarviz.reporting.Format;
import org.kordamp.jarviz.reporting.Formatter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kordamp.jarviz.cli;
package org.kordamp.jarviz.cli.internal;

import org.kordamp.jarviz.util.JarvizOutput;

Expand All @@ -33,7 +33,7 @@
* @author Andres Almiray
* @since 0.1.0
*/
final class Banner {
public final class Banner {
private static final Banner BANNER = new Banner();
private final ResourceBundle bundle = ResourceBundle.getBundle(Banner.class.getName());
private final String productVersion = bundle.getString("product.version");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kordamp.jarviz.cli;
package org.kordamp.jarviz.cli.internal;

import picocli.CommandLine;

import java.text.MessageFormat;
import java.util.Map;
import java.util.ResourceBundle;

/**
* @author Andres Almiray
* @since 0.1.0
*/
@CommandLine.Command(mixinStandardHelpOptions = true,
versionProvider = Versions.class,
resourceBundle = "org.kordamp.jarviz.cli.Messages")
resourceBundle = "org.kordamp.jarviz.cli.internal.Messages")
public abstract class BaseCommand {
static {
if (System.getenv().containsKey("JARVIZ_NO_COLOR")) {
Expand All @@ -40,8 +39,6 @@ public abstract class BaseCommand {
@CommandLine.Spec
public CommandLine.Model.CommandSpec spec;

public ResourceBundle bundle = ResourceBundle.getBundle("org.kordamp.jarviz.cli.Messages");

@CommandLine.Option(names = "-D",
paramLabel = "<key=value>",
descriptionKey = "system-property",
Expand All @@ -52,8 +49,8 @@ void setProperty(Map<String, String> props) {

protected String $(String key, Object... args) {
if (null == args || args.length == 0) {
return bundle.getString(key);
return spec.resourceBundle().getString(key);
}
return MessageFormat.format(bundle.getString(key), args);
return MessageFormat.format(spec.resourceBundle().getString(key), args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kordamp.jarviz.cli;
package org.kordamp.jarviz.cli.internal;

import org.kordamp.jarviz.util.JarvizVersion;
import picocli.CommandLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.manifest;

import org.kordamp.jarviz.cli.AbstractJarvizCommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizCommand;
import org.kordamp.jarviz.cli.Main;
import picocli.CommandLine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.manifest;

import org.kordamp.jarviz.cli.AbstractJarvizSubcommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizSubcommand;
import org.kordamp.jarviz.core.JarFileResolver;
import org.kordamp.jarviz.core.processors.QueryManifestJarProcessor;
import org.kordamp.jarviz.reporting.Format;
Expand All @@ -28,7 +28,7 @@
import java.nio.file.Paths;
import java.util.Optional;

import static org.kordamp.jarviz.core.resolvers.JarFileResolvers.createJarFileResolver;
import static org.kordamp.jarviz.core.JarFileResolvers.createJarFileResolver;
import static org.kordamp.jarviz.util.StringUtils.isNotBlank;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.kordamp.jarviz.cli.manifest;

import org.kordamp.jarviz.bundle.RB;
import org.kordamp.jarviz.cli.AbstractJarvizSubcommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizSubcommand;
import org.kordamp.jarviz.core.JarFileResolver;
import org.kordamp.jarviz.core.JarvizException;
import org.kordamp.jarviz.core.processors.ShowManifestJarProcessor;
Expand All @@ -32,7 +32,7 @@
import java.nio.file.Paths;
import java.util.Optional;

import static org.kordamp.jarviz.core.resolvers.JarFileResolvers.createJarFileResolver;
import static org.kordamp.jarviz.core.JarFileResolvers.createJarFileResolver;

/**
* @author Andres Almiray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.modules;

import org.kordamp.jarviz.cli.AbstractJarvizCommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizCommand;
import org.kordamp.jarviz.cli.Main;
import picocli.CommandLine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.modules;

import org.kordamp.jarviz.cli.AbstractJarvizSubcommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizSubcommand;
import org.kordamp.jarviz.core.JarFileResolver;
import org.kordamp.jarviz.core.modules.DescriptorModuleJarProcessor;
import org.kordamp.jarviz.reporting.Format;
Expand All @@ -36,7 +36,7 @@
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
import static org.kordamp.jarviz.cli.internal.Colorizer.magenta;
import static org.kordamp.jarviz.core.resolvers.JarFileResolvers.createJarFileResolver;
import static org.kordamp.jarviz.core.JarFileResolvers.createJarFileResolver;

/**
* @author Andres Almiray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.modules;

import org.kordamp.jarviz.cli.AbstractJarvizSubcommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizSubcommand;
import org.kordamp.jarviz.core.JarFileResolver;
import org.kordamp.jarviz.core.modules.NameModuleJarProcessor;
import org.kordamp.jarviz.reporting.Format;
Expand All @@ -27,7 +27,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;

import static org.kordamp.jarviz.core.resolvers.JarFileResolvers.createJarFileResolver;
import static org.kordamp.jarviz.core.JarFileResolvers.createJarFileResolver;

/**
* @author Andres Almiray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.mrjar;

import org.kordamp.jarviz.cli.AbstractJarvizCommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizCommand;
import org.kordamp.jarviz.cli.Main;
import picocli.CommandLine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.mrjar;

import org.kordamp.jarviz.cli.AbstractJarvizSubcommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizSubcommand;
import picocli.CommandLine;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.services;

import org.kordamp.jarviz.cli.AbstractJarvizCommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizCommand;
import org.kordamp.jarviz.cli.Main;
import picocli.CommandLine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.services;

import org.kordamp.jarviz.cli.AbstractJarvizSubcommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizSubcommand;
import org.kordamp.jarviz.core.JarFileResolver;
import org.kordamp.jarviz.core.services.ListServicesJarProcessor;
import org.kordamp.jarviz.reporting.Format;
Expand All @@ -29,7 +29,7 @@
import java.util.List;
import java.util.Optional;

import static org.kordamp.jarviz.core.resolvers.JarFileResolvers.createJarFileResolver;
import static org.kordamp.jarviz.core.JarFileResolvers.createJarFileResolver;

/**
* @author Andres Almiray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.kordamp.jarviz.cli.services;

import org.kordamp.jarviz.cli.AbstractJarvizSubcommand;
import org.kordamp.jarviz.cli.internal.AbstractJarvizSubcommand;
import org.kordamp.jarviz.core.JarFileResolver;
import org.kordamp.jarviz.core.services.ShowServicesJarProcessor;
import org.kordamp.jarviz.reporting.Format;
Expand All @@ -29,7 +29,7 @@
import java.util.List;
import java.util.Optional;

import static org.kordamp.jarviz.core.resolvers.JarFileResolvers.createJarFileResolver;
import static org.kordamp.jarviz.core.JarFileResolvers.createJarFileResolver;

/**
* @author Andres Almiray
Expand Down

0 comments on commit 039fb63

Please sign in to comment.