Commit Diff


commit - 03fcc26854c53b9a200e2f532905f4e10c7f82e5
commit + c4e479061eef64135ae09e7ef9ae3db30962f2fe
blob - dd55f1470d8bb4bbce2604f463900b1c65a6e39d
blob + 8f95a50047543a4de0867891cfa4d7e5eefb393e
--- build.gradle
+++ build.gradle
@@ -23,6 +23,7 @@ allprojects {
   //apply from: rootProject.file('gradle/dependency-check.gradle')
   apply from: rootProject.file('gradle/license.gradle')
   apply from: rootProject.file('gradle/shadow.gradle')
+  apply from: rootProject.file('gradle/spotless.gradle')
 }
 
 subprojects {
@@ -37,7 +38,6 @@ subprojects {
   // Run 'createKeyAndTruststore' first and/or customize as needed
   //apply from: rootProject.file('gradle/signjar.gradle')
   apply from: rootProject.file('gradle/spotbugs.gradle')
-  //apply from: rootProject.file('gradle/spotless.gradle')
 }
 
 apply from: rootProject.file('gradle/build-dashboard.gradle')
blob - d0c2ffe7adba1a589f472cedfd993712bd810e9d
blob + 462e994f81aee74ed345ccfc0320a3e48ca3cf04
--- gradle/spotless.gradle
+++ gradle/spotless.gradle
@@ -27,6 +27,10 @@ apply plugin: com.diffplug.gradle.spotless.SpotlessPlu
 spotless {
   java {
     googleJavaFormat()
+    endWithNewline()
     formatAnnotations()
+    importOrder()
+    trimTrailingWhitespace()
+    removeUnusedImports()
   }
 }
blob - 2b786fc8cc083711bd936330879a85cd084bf00c
blob + 2ad55bc4876a592387a2553adda5787e6903a34b
--- template-core/src/main/java/com/pyr3x/template/core/Main.java
+++ template-core/src/main/java/com/pyr3x/template/core/Main.java
@@ -26,30 +26,29 @@ import org.osgi.service.component.annotations.Componen
 import org.osgi.service.component.annotations.Deactivate;
 import org.osgi.service.component.annotations.Modified;
 
-/**
- * Template class.
- */
+/** Template class. */
 @Slf4j
 @Component(immediate = true)
 public class Main {
 
-  /**
-   * Localization for bundle, configuration, log, and other strings.
-   */
+  /** Localization for bundle, configuration, log, and other strings. */
   protected transient ResourceBundle bundle;
 
   /**
    * DS method to activate the component.
    *
    * @param componentContext {@link ComponentContext} for this component.
-   * @param bundleContext    {@link BundleContext} for this bundle.
+   * @param bundleContext {@link BundleContext} for this bundle.
    * @throws Exception If there was an error activating this component.
    */
   @Activate
-  protected void activate(final ComponentContext componentContext,
-      final BundleContext bundleContext) throws Exception {
-    bundle = ResourceBundle.getBundle(Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME,
-        Locale.getDefault(), this.getClass().getClassLoader());
+  protected void activate(
+      final ComponentContext componentContext, final BundleContext bundleContext) throws Exception {
+    bundle =
+        ResourceBundle.getBundle(
+            Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME,
+            Locale.getDefault(),
+            this.getClass().getClassLoader());
     if (log.isInfoEnabled()) {
       log.info(bundle.getString("log.starting"));
     }
@@ -59,12 +58,12 @@ public class Main {
    * DS method to deactivate the component.
    *
    * @param componentContext {@link ComponentContext} for this component.
-   * @param bundleContext    {@link BundleContext} for this bundle.
+   * @param bundleContext {@link BundleContext} for this bundle.
    * @throws Exception If there was an error deactivating this component.
    */
   @Deactivate
-  protected void deactivate(final ComponentContext componentContext,
-      final BundleContext bundleContext) throws Exception {
+  protected void deactivate(
+      final ComponentContext componentContext, final BundleContext bundleContext) throws Exception {
     if (log.isInfoEnabled()) {
       log.info(bundle.getString("log.stopping"));
     }
blob - a73f04ce61b2eb1c16cecf312a778f1aa3a494cb
blob + 8826e60872135a8e1787324b0b1278234cb51e09
--- template-security/src/main/java/com/pyr3x/template/security/Activator.java
+++ template-security/src/main/java/com/pyr3x/template/security/Activator.java
@@ -44,31 +44,26 @@ import org.osgi.service.condpermadmin.ConditionalPermi
 @Header(name = Constants.BUNDLE_ACTIVATOR, value = "${@class}")
 public class Activator implements BundleActivator {
 
-  /**
-   * Property for security policy file path.
-   */
-  protected static final String PROPERTY_POLICY_PATH
-      = Activator.class.getPackageName() + ".policy.path";
+  /** Property for security policy file path. */
+  protected static final String PROPERTY_POLICY_PATH =
+      Activator.class.getPackageName() + ".policy.path";
 
-  /**
-   * Default security policy file path.
-   */
+  /** Default security policy file path. */
   protected static final String DEFAULT_POLICY_PATH = "etc/security.policy";
 
-  /**
-   * Constant for ignoring line of security policy.
-   */
+  /** Constant for ignoring line of security policy. */
   protected static final char HASH = '#';
 
-  /**
-   * Localization for bundle, configuration, log, and other strings.
-   */
+  /** Localization for bundle, configuration, log, and other strings. */
   protected transient ResourceBundle bundle;
 
   @Override
   public void start(final BundleContext bundleContext) throws Exception {
-    bundle = ResourceBundle.getBundle(Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME,
-        Locale.getDefault(), this.getClass().getClassLoader());
+    bundle =
+        ResourceBundle.getBundle(
+            Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME,
+            Locale.getDefault(),
+            this.getClass().getClassLoader());
     if (log.isInfoEnabled()) {
       log.info(bundle.getString("log.starting"));
     }
@@ -85,11 +80,16 @@ public class Activator implements BundleActivator {
     }
     final Path policyFile = getPolicyFile(bundleContext);
     final List<String> encodedInfos = readPolicyFile(policyFile);
-    encodedInfos.add(0, "ALLOW {"
-        + "[org.osgi.service.condpermadmin.BundleLocationCondition \""
-        + bundleContext.getBundle().getLocation() + "\"]"
-        + "(java.security.AllPermission \"*\" \"*\")"
-        + "} \"" + bundle.getString("log.management_agent") + "\"");
+    encodedInfos.add(
+        0,
+        "ALLOW {"
+            + "[org.osgi.service.condpermadmin.BundleLocationCondition \""
+            + bundleContext.getBundle().getLocation()
+            + "\"]"
+            + "(java.security.AllPermission \"*\" \"*\")"
+            + "} \""
+            + bundle.getString("log.management_agent")
+            + "\"");
     final ConditionalPermissionUpdate cpu = cpa.get().newConditionalPermissionUpdate();
     final List<ConditionalPermissionInfo> infos = cpu.getConditionalPermissionInfos();
     infos.clear();
@@ -117,8 +117,9 @@ public class Activator implements BundleActivator {
    * @param bundleContext {@link BundleContext} to get policy path property from (if present).
    * @return {@link Path} to the security policy file.
    */
-  @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification
-      = "Intended behavior to read policy from property if set")
+  @SuppressFBWarnings(
+      value = "PATH_TRAVERSAL_IN",
+      justification = "Intended behavior to read policy from property if set")
   public Path getPolicyFile(final BundleContext bundleContext) {
     String policyFilePath = bundleContext.getProperty(PROPERTY_POLICY_PATH);
     if (policyFilePath == null) {
@@ -161,8 +162,8 @@ public class Activator implements BundleActivator {
    */
   public Optional<ConditionalPermissionAdmin> getConditionalPermissionAdmin(
       final BundleContext bundleContext) {
-    final ServiceReference<ConditionalPermissionAdmin> cpaRef
-        = bundleContext.getServiceReference(ConditionalPermissionAdmin.class);
+    final ServiceReference<ConditionalPermissionAdmin> cpaRef =
+        bundleContext.getServiceReference(ConditionalPermissionAdmin.class);
     if (cpaRef == null) {
       return Optional.empty();
     } else {