In this task you are going to create the same application as in Maven module, but with Gradle build tool.
- After Gradle installation make sure that you have 'gradle' package with wrapper inside;
- Open root settings.gradle file and add two modules: utils, demo.
Custom jar utils-1.3.5.jar
will be created with the following instructions:
- The jar should contain class
StringUtils
with methodboolean isPositiveNumber(String str)
. Apache Commons Lang 3.10
library is used to implement this method.
- Open build.gradle in 'utils' and fill it with proper group, version and delete comments with proper implementation
plugins {
// id for library
// id for maven to publish jar to local repository
}
java {
// provide sourceCompatibility
}
repositories {
// provide repository, where required dependencies are located
}
publishing {
publications {
maven(MavenPublication) {
// provide groupId
// provide artifactId
// provide version
from components.java
}
}
}
//add Apache Apache Commons Lang 3.10 (or higher) dependency
jar {
manifest {
//provide manifest with such attributes as 'Implementation-Title', 'Implementation-Version'
}
}
- Implement method in StringUtils.class:
public class StringUtils {
public static boolean isPositiveNumber(String str) {
//here magic will happen
}
}
Now we will use the created util class:
-
Open build.gradle in 'demo' and fill in group, version, repositories and required dependency;
-
Provide required implementation:
public class Utils {
public static boolean isAllPositiveNumbers(List<String> args) {
//magic happens here
}
}
Make sure that application passes all test suits.