File tree 8 files changed +235
-0
lines changed
java/gr/codelearn/core/showcase/maven/input
calculator-operations-provider
main/java/gr/codelearn/core/showcase/provider
test/java/gr/codelearn/core/showcase/provider
8 files changed +235
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5
+ <!-- Packaging -->
6
+ <modelVersion >4.0.0</modelVersion >
7
+ <packaging >jar</packaging >
8
+
9
+ <!-- Versioning -->
10
+ <artifactId >calculator-input-handler</artifactId >
11
+ <parent >
12
+ <artifactId >java-path-core-maven</artifactId >
13
+ <groupId >gr.codelearn</groupId >
14
+ <version >2021.1.0</version >
15
+ </parent >
16
+
17
+ <!-- Meta-data -->
18
+ <name >[${project.artifactId} ]</name >
19
+ <description >Java Learning @ Development Path, Maven module, module depending on another dependency</description >
20
+
21
+ <properties >
22
+ <maven .compiler.source>11</maven .compiler.source>
23
+ <maven .compiler.target>11</maven .compiler.target>
24
+ </properties >
25
+
26
+ <!-- Dependencies -->
27
+ <dependencies >
28
+ <dependency >
29
+ <groupId >gr.codelearn</groupId >
30
+ <artifactId >calculator-operations-provider</artifactId >
31
+ <version >2021.2.0</version >
32
+ </dependency >
33
+ </dependencies >
34
+
35
+
36
+ </project >
Original file line number Diff line number Diff line change
1
+ package gr .codelearn .core .showcase .maven .input ;
2
+
3
+ import gr .codelearn .core .showcase .provider .MathOperationsProvider ;
4
+ import org .slf4j .Logger ;
5
+ import org .slf4j .LoggerFactory ;
6
+
7
+ import java .util .Scanner ;
8
+
9
+ public class CalculatorInputHandler {
10
+ private static final Logger logger = LoggerFactory .getLogger (CalculatorInputHandler .class );
11
+
12
+ public static void main (String [] args ) {
13
+
14
+ logger .info ("Waiting for user's input: " );
15
+ Scanner input = new Scanner (System .in );
16
+
17
+ System .out .println ("Enter first number " );
18
+ Integer firstArgument = input .nextInt ();
19
+ System .out .println (firstArgument );
20
+
21
+ System .out .println ("Enter second number " );
22
+ Integer secondArgument = input .nextInt ();
23
+ System .out .println (secondArgument );
24
+
25
+ logger .info (String .format ("Provided numbers are %s and %s" , firstArgument , secondArgument ));
26
+ logger .info ("Calculated sum of provided arguments is: " + MathOperationsProvider .add (firstArgument ,
27
+ secondArgument ));
28
+ logger .info ("Calculated product of provided arguments is: " + MathOperationsProvider .multiply (firstArgument ,
29
+ secondArgument ));
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <Configuration status =" WARN" monitorInterval =" 30" >
3
+ <Properties >
4
+ <Property name =" LOG_PATTERN" >
5
+ %d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${hostName} - [%15.15t] %-30.30c{1.} : %m%n%ex
6
+ </Property >
7
+ </Properties >
8
+
9
+ <Appenders >
10
+ <Console name =" ConsoleAppender" target =" SYSTEM_OUT" follow =" true" >
11
+ <PatternLayout pattern =" ${LOG_PATTERN}" />
12
+ </Console >
13
+
14
+ <!-- Rolling Random Access File Appender with a default buffer of 256 * 1024 bytes -->
15
+ <RollingRandomAccessFile name =" RollingRandomAccessFileAppender"
16
+ fileName =" logs/java-path-core-datetime.log"
17
+ filePattern =" logs/java-path-core-datetime-%d{yyyy-MM-dd}.zip" >
18
+ <PatternLayout >
19
+ <Pattern >${LOG_PATTERN}</Pattern >
20
+ </PatternLayout >
21
+ <Policies >
22
+ <TimeBasedTriggeringPolicy />
23
+ </Policies >
24
+ <DefaultRolloverStrategy >
25
+ <Delete basePath =" logs" >
26
+ <IfLastModified age =" 30d" />
27
+ </Delete >
28
+ </DefaultRolloverStrategy >
29
+ </RollingRandomAccessFile >
30
+ </Appenders >
31
+
32
+ <Loggers >
33
+ <AsyncLogger name =" gr.codelearn" level =" debug" additivity =" false" >
34
+ <AppenderRef ref =" ConsoleAppender" />
35
+ <AppenderRef ref =" RollingRandomAccessFileAppender" />
36
+ </AsyncLogger >
37
+
38
+ <Root level =" info" >
39
+ <AppenderRef ref =" ConsoleAppender" />
40
+ <AppenderRef ref =" RollingRandomAccessFileAppender" />
41
+ </Root >
42
+ </Loggers >
43
+ </Configuration >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5
+ <!-- Packaging -->
6
+ <modelVersion >4.0.0</modelVersion >
7
+ <packaging >jar</packaging >
8
+
9
+ <!-- Versioning -->
10
+ <artifactId >calculator-operations-provider</artifactId >
11
+ <version >2021.2.0</version >
12
+ <parent >
13
+ <groupId >gr.codelearn</groupId >
14
+ <artifactId >java-path-core-maven</artifactId >
15
+ <version >2021.1.0</version >
16
+ </parent >
17
+
18
+ <!-- Meta-data -->
19
+ <name >[${project.artifactId} ]</name >
20
+ <description >Java Learning @ Development Path, Maven, sub module representing dependency</description >
21
+
22
+ <properties >
23
+ <maven .compiler.source>11</maven .compiler.source>
24
+ <maven .compiler.target>11</maven .compiler.target>
25
+ </properties >
26
+
27
+ <!-- Dependencies -->
28
+ <dependencies >
29
+ <dependency >
30
+ <groupId >org.junit.jupiter</groupId >
31
+ <artifactId >junit-jupiter</artifactId >
32
+ <version >5.7.1</version >
33
+ <scope >test</scope >
34
+ </dependency >
35
+ <dependency >
36
+ <groupId >org.junit.jupiter</groupId >
37
+ <artifactId >junit-jupiter-engine</artifactId >
38
+ <version >5.7.1</version >
39
+ <scope >test</scope >
40
+ </dependency >
41
+ </dependencies >
42
+
43
+ </project >
Original file line number Diff line number Diff line change
1
+ package gr .codelearn .core .showcase .provider ;
2
+
3
+ public class MathOperationsProvider {
4
+ public static int add (int a , int b ) {
5
+ return a + b ;
6
+ }
7
+
8
+ //provided in version 2021.2.0 as maven installed dependency
9
+ public static int multiply (int a , int b ) {
10
+ return a * b ;
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ package gr .codelearn .core .showcase .provider ;
2
+
3
+ import org .junit .jupiter .api .Assertions ;
4
+ import org .junit .jupiter .api .Test ;
5
+
6
+ class MathOperationsProviderTest {
7
+
8
+ @ Test
9
+ void testAdd () {
10
+ Assertions .assertEquals (3 , MathOperationsProvider .add (2 , 1 ));
11
+ }
12
+
13
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5
+ <parent >
6
+ <artifactId >java-path-core</artifactId >
7
+ <groupId >gr.codelearn</groupId >
8
+ <version >2021.1.0</version >
9
+ </parent >
10
+ <modelVersion >4.0.0</modelVersion >
11
+ <packaging >pom</packaging >
12
+
13
+ <artifactId >java-path-core-maven</artifactId >
14
+
15
+ <modules >
16
+ <module >calculator-input-handler</module >
17
+ <module >calculator-operations-provider</module >
18
+ </modules >
19
+
20
+ <properties >
21
+ <maven .compiler.source>11</maven .compiler.source>
22
+ <maven .compiler.target>11</maven .compiler.target>
23
+ </properties >
24
+
25
+ <build >
26
+ <!-- Plugins and corresponding configuration used by all sub modules -->
27
+ <plugins >
28
+ <plugin >
29
+ <groupId >org.apache.maven.plugins</groupId >
30
+ <artifactId >maven-shade-plugin</artifactId >
31
+ <version >3.2.4</version >
32
+ <executions >
33
+ <execution >
34
+ <phase >package</phase >
35
+ <goals >
36
+ <goal >shade</goal >
37
+ </goals >
38
+ <configuration >
39
+ <shadedArtifactAttached >true</shadedArtifactAttached >
40
+ <transformers >
41
+ <transformer implementation =
42
+ " org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" >
43
+ <mainClass >gr.codelearn.core.showcase.maven.input.CalculatorInputHandler</mainClass >
44
+ <manifestEntries >
45
+ <Multi-Release >true</Multi-Release >
46
+ </manifestEntries >
47
+ </transformer >
48
+ </transformers >
49
+ </configuration >
50
+ </execution >
51
+ </executions >
52
+ </plugin >
53
+ </plugins >
54
+ </build >
55
+
56
+ </project >
Original file line number Diff line number Diff line change 24
24
<!-- Modules -->
25
25
<modules >
26
26
<module >java-path-core-basic</module >
27
+ <module >java-path-core-maven</module >
27
28
</modules >
28
29
29
30
<!-- Properties/Variables -->
You can’t perform that action at this time.
0 commit comments