Sfoglia il codice sorgente

various changes to support email again and fix some formatting

Gary Paduana 5 anni fa
parent
commit
56e484d7ba

+ 30 - 0
dependency-reduced-pom.xml

@@ -78,6 +78,36 @@
       <type>pom</type>
       <scope>compile</scope>
     </dependency>
+    <dependency>
+      <groupId>com.sun.mail</groupId>
+      <artifactId>jakarta.mail</artifactId>
+      <version>1.6.3</version>
+      <scope>provided</scope>
+      <exclusions>
+        <exclusion>
+          <artifactId>jakarta.activation</artifactId>
+          <groupId>com.sun.activation</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.spockframework</groupId>
+      <artifactId>spock-core</artifactId>
+      <version>1.3-groovy-2.5</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.12</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <artifactId>hamcrest-core</artifactId>
+          <groupId>org.hamcrest</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
   </dependencies>
   <properties />
 </project>

+ 26 - 24
pom.xml

@@ -10,7 +10,7 @@
     <packaging>jar</packaging>
 
     <properties>
-        <start-class></start-class>
+        <start-class/>
     </properties>
 
     <dependencies>
@@ -29,8 +29,9 @@
 
         <dependency>
             <groupId>com.sun.mail</groupId>
-            <artifactId>javax.mail</artifactId>
-            <version>1.6.2</version>
+            <artifactId>jakarta.mail</artifactId>
+            <version>1.6.3</version>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
@@ -46,6 +47,7 @@
             <version>4.12</version>
             <scope>test</scope>
         </dependency>
+
     </dependencies>
 
     <build>
@@ -104,27 +106,27 @@
                 </executions>
             </plugin>
 
-<!--            <plugin>-->
-<!--                <groupId>org.apache.maven.plugins</groupId>-->
-<!--                <artifactId>maven-shade-plugin</artifactId>-->
-<!--                <version>3.2.1</version>-->
-<!--                <executions>-->
-<!--                    <execution>-->
-<!--                        <phase>package</phase>-->
-<!--                        <goals>-->
-<!--                            <goal>shade</goal>-->
-<!--                        </goals>-->
-<!--                        <configuration>-->
-<!--                            <transformers>-->
-<!--                                <transformer-->
-<!--                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">-->
-<!--                                    <mainClass>${start-class}</mainClass>-->
-<!--                                </transformer>-->
-<!--                            </transformers>-->
-<!--                        </configuration>-->
-<!--                    </execution>-->
-<!--                </executions>-->
-<!--            </plugin>-->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <version>3.2.1</version>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <transformers>
+                                <transformer
+                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                                    <mainClass>${start-class}</mainClass>
+                                </transformer>
+                            </transformers>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 

+ 6 - 6
src/main/groovy/com/garypaduana/groovytools/algorithm/FermatsLittleTheorem.groovy

@@ -1,15 +1,15 @@
 package com.garypaduana.groovytools.algorithm
 
-class FermatsLittleTheorem{
+class FermatsLittleTheorem {
 
     /**
      * Implementation of Fermat's Little Theorm to determine if a
      * number is probably prime.
      */
-    static def probablyPrime(def p){
-        for(int i = 0; i < 30; i++){
+    static def probablyPrime(def p) {
+        for (int i = 0; i < 30; i++) {
             def a = randomBetween(2, p)
-            if(!congruentModulo(a.pow(p.intValue() - 1), 1, p)){
+            if (!congruentModulo(a.pow(p.intValue() - 1), 1, p)) {
                 return false
             }
         }
@@ -21,7 +21,7 @@ class FermatsLittleTheorem{
      * the first argument and exclusive of the second.  Ordering
      * does not matter.
      */
-    static def randomBetween(def a, def b){
+    static def randomBetween(def a, def b) {
         Random r = new Random()
         return BigInteger.valueOf((long) r.nextDouble() * (b - a) + a)
     }
@@ -29,7 +29,7 @@ class FermatsLittleTheorem{
     /**
      * Determines if arguments a and b are congruent modulo to n.
      */
-    static def congruentModulo(def a, def b, def n){
+    static def congruentModulo(def a, def b, def n) {
         return (a - b) % n == 0
     }
 }

+ 17 - 17
src/main/groovy/com/garypaduana/groovytools/algorithm/Sort.groovy

@@ -3,8 +3,8 @@ package com.garypaduana.groovytools.algorithm
 /**
  * Created by gary on 2/5/17.
  */
-class Sort{
-    static class SortingAlgorithms{
+class Sort {
+    static class SortingAlgorithms {
 
         /**
          * The algorithm starts at the beginning of the data set.
@@ -15,10 +15,10 @@ class Sort{
          * two elements, repeating until no swaps have occurred on
          * the last pass.
          */
-        def static bubbleSort(def array){
-            for(int k = array.size() - 1; k > 0; k--){
-                for(int i = 0; i < k; i++){
-                    if(array[i] > array[i + 1]){
+        def static bubbleSort(def array) {
+            for (int k = array.size() - 1; k > 0; k--) {
+                for (int i = 0; i < k; i++) {
+                    if (array[i] > array[i + 1]) {
                         swap(array, i, i + 1)
                     }
                 }
@@ -32,12 +32,12 @@ class Sort{
          * for the remainder of the list. It does no more than n
          * swaps, and thus is useful where swapping is very expensive.
          */
-        def static selectionSort(def array){
-            for(int k = 0; k < array.size(); k++){
+        def static selectionSort(def array) {
+            for (int k = 0; k < array.size(); k++) {
                 def min = array[k]
                 def minIndex = k
-                for(int i = k; i < array.size(); i++){
-                    if(array[i] < min){
+                for (int i = k; i < array.size(); i++) {
+                    if (array[i] < min) {
                         min = array[i]
                         minIndex = i
                     }
@@ -57,8 +57,8 @@ class Sort{
          * recursively sorted. This yields average time complexity of
          * O(n log n), with low overhead, and thus this is a popular algorithm.
          */
-        def static quickSort(def array, def low, def high){
-            if(low < high){
+        def static quickSort(def array, def low, def high) {
+            if (low < high) {
                 def p = partition(array, low, high)
                 quickSort(array, low, p - 1)
                 quickSort(array, p + 1, high)
@@ -66,9 +66,9 @@ class Sort{
             return array
         }
 
-        def static partition(def array, def low, def high){
+        def static partition(def array, def low, def high) {
             def pivotIndex = (int) ((high - low) / 2 + low)
-            if(pivotIndex == low){
+            if (pivotIndex == low) {
                 pivotIndex++
             }
 
@@ -77,8 +77,8 @@ class Sort{
             swap(array, pivotIndex, high)
             def storeIndex = low
 
-            for(int i = low; i < high; i++){
-                if(array[i] <= pivotValue){
+            for (int i = low; i < high; i++) {
+                if (array[i] <= pivotValue) {
                     swap(array, i, storeIndex)
                     storeIndex++
                 }
@@ -90,7 +90,7 @@ class Sort{
         /**
          * Swaps values found at positions i and j within array.
          */
-        def static swap(def array, int i, int j){
+        def static swap(def array, int i, int j) {
             def temp = array[i]
             array[i] = array[j]
             array[j] = temp

+ 6 - 6
src/main/groovy/com/garypaduana/groovytools/data/structure/Queue.groovy

@@ -1,26 +1,26 @@
 package com.garypaduana.groovytools.data.structure
 
-class Queue{
+class Queue {
 
     def data = []
 
-    def enqueue(def element){
+    def enqueue(def element) {
         // add element just before index 0
         data.add(0, element)
     }
 
-    def dequeue(def element){
-        if(data.size() > 0){
+    def dequeue(def element) {
+        if (data.size() > 0) {
             return data.pop()
         }
         return null
     }
 
-    def size(){
+    def size() {
         return data.size()
     }
 
-    def peek(){
+    def peek() {
         return data.get(data.size() - 1)
     }
 }

+ 6 - 6
src/main/groovy/com/garypaduana/groovytools/data/structure/Stack.groovy

@@ -1,25 +1,25 @@
 package com.garypaduana.groovytools.data.structure
 
-class Stack{
+class Stack {
 
     private def data = []
 
-    def pop(){
-        if(data.size() > 0){
+    def pop() {
+        if (data.size() > 0) {
             return data.pop()
         }
         return null
     }
 
-    def push(def element){
+    def push(def element) {
         data.add(element)
     }
 
-    def peek(){
+    def peek() {
         return data.get(data.size() - 1)
     }
 
-    def size(){
+    def size() {
         return data.size()
     }
 }

+ 0 - 16
src/main/main.iml

@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
-    <exclude-output />
-    <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/groovy" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
-    </content>
-    <orderEntry type="inheritedJdk" />
-    <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="library" name="groovy-2.4.8" level="application" />
-    <orderEntry type="library" name="Gradle: com.sun.mail:javax.mail:1.5.3" level="project" />
-    <orderEntry type="library" name="Gradle: org.spockframework:spock-core:1.0-groovy-2.4" level="project" />
-    <orderEntry type="library" name="Gradle: org.spockframework:spock-core:1.0-groovy-2.4" level="project" />
-  </component>
-</module>

+ 0 - 12
src/main/resources.iml

@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
-    <exclude-output />
-    <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
-    </content>
-    <orderEntry type="inheritedJdk" />
-    <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="library" name="groovy-2.4.8" level="application" />
-  </component>
-</module>

+ 0 - 13
src/main/test.iml

@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
-    <exclude-output />
-    <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
-    </content>
-    <orderEntry type="inheritedJdk" />
-    <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="library" name="groovy-2.4.8" level="application" />
-    <orderEntry type="library" name="groovy-2.4.9" level="application" />
-  </component>
-</module>