Introduction to Pants Build Tool (#14517)
* Introduction to Pants Build Tool * Introduction to Pants Build Tool * Introduction to Pants Build Tool * Introduction to Pants Build Tool * Introduction to Pants Build Tool
This commit is contained in:
parent
4945be2fd6
commit
4b99565de3
|
@ -0,0 +1,5 @@
|
|||
.idea/
|
||||
.pants.d/
|
||||
.pids/
|
||||
dist/
|
||||
pants.toml.bak
|
|
@ -0,0 +1,5 @@
|
|||
jvm_artifact(
|
||||
group="com.google.guava",
|
||||
artifact="guava",
|
||||
version="18.0",
|
||||
)
|
|
@ -0,0 +1,63 @@
|
|||
# This lockfile was autogenerated by Pants. To regenerate, run:
|
||||
#
|
||||
# pants generate-lockfiles
|
||||
#
|
||||
# --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE ---
|
||||
# {
|
||||
# "version": 1,
|
||||
# "generated_with_requirements": [
|
||||
# "com.google.guava:guava:18.0,url=not_provided,jar=not_provided",
|
||||
# "junit:junit:4.13.2,url=not_provided,jar=not_provided"
|
||||
# ]
|
||||
# }
|
||||
# --- END PANTS LOCKFILE METADATA ---
|
||||
|
||||
[[entries]]
|
||||
directDependencies = []
|
||||
dependencies = []
|
||||
file_name = "com.google.guava_guava_18.0.jar"
|
||||
|
||||
[entries.coord]
|
||||
group = "com.google.guava"
|
||||
artifact = "guava"
|
||||
version = "18.0"
|
||||
packaging = "jar"
|
||||
[entries.file_digest]
|
||||
fingerprint = "d664fbfc03d2e5ce9cab2a44fb01f1d0bf9dfebeccc1a473b1f9ea31f79f6f99"
|
||||
serialized_bytes_length = 2256213
|
||||
[[entries]]
|
||||
file_name = "junit_junit_4.13.2.jar"
|
||||
[[entries.directDependencies]]
|
||||
group = "org.hamcrest"
|
||||
artifact = "hamcrest-core"
|
||||
version = "1.3"
|
||||
packaging = "jar"
|
||||
|
||||
[[entries.dependencies]]
|
||||
group = "org.hamcrest"
|
||||
artifact = "hamcrest-core"
|
||||
version = "1.3"
|
||||
packaging = "jar"
|
||||
|
||||
|
||||
[entries.coord]
|
||||
group = "junit"
|
||||
artifact = "junit"
|
||||
version = "4.13.2"
|
||||
packaging = "jar"
|
||||
[entries.file_digest]
|
||||
fingerprint = "8e495b634469d64fb8acfa3495a065cbacc8a0fff55ce1e31007be4c16dc57d3"
|
||||
serialized_bytes_length = 384581
|
||||
[[entries]]
|
||||
directDependencies = []
|
||||
dependencies = []
|
||||
file_name = "org.hamcrest_hamcrest-core_1.3.jar"
|
||||
|
||||
[entries.coord]
|
||||
group = "org.hamcrest"
|
||||
artifact = "hamcrest-core"
|
||||
version = "1.3"
|
||||
packaging = "jar"
|
||||
[entries.file_digest]
|
||||
fingerprint = "66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9"
|
||||
serialized_bytes_length = 45024
|
|
@ -0,0 +1,5 @@
|
|||
jvm_artifact(
|
||||
group="junit",
|
||||
artifact="junit",
|
||||
version="4.13.2"
|
||||
)
|
|
@ -0,0 +1,7 @@
|
|||
[groups.default]
|
||||
addresses = [
|
||||
"src/jvm::",
|
||||
"tests/jvm::",
|
||||
]
|
||||
|
||||
resolve = "jvm:jvm-default"
|
|
@ -0,0 +1,22 @@
|
|||
[GLOBAL]
|
||||
backend_packages = [
|
||||
"pants.backend.experimental.java",
|
||||
"pants.backend.experimental.java.lint.google_java_format"
|
||||
]
|
||||
pants_version = "2.16.0"
|
||||
|
||||
[source]
|
||||
root_patterns = [
|
||||
"/src/*",
|
||||
"/tests/*",
|
||||
]
|
||||
|
||||
[jvm]
|
||||
jdk = 1.8
|
||||
|
||||
[test]
|
||||
timeout_default = 60
|
||||
timeout_maximum = 120
|
||||
|
||||
[experimental-bsp]
|
||||
groups_config_files = ["bsp-groups.toml"]
|
|
@ -0,0 +1,15 @@
|
|||
java_sources(
|
||||
dependencies=[
|
||||
"src/resources/com/baeldung/hellopant:word",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
|
||||
deploy_jar(
|
||||
name="HelloPant",
|
||||
main="com.baeldung.hellopant",
|
||||
dependencies=[
|
||||
":hellopant",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,20 @@
|
|||
package com.baeldung.hellopant;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.Resources;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class Hello {
|
||||
public static void main(String[] args) throws IOException {
|
||||
System.out.println("Hello World!");
|
||||
|
||||
final List<String> names = Lists.newArrayList("John", null, "Jane", "Adam", "Tom");
|
||||
final String result = Joiner.on(",").skipNulls().join(names);
|
||||
|
||||
System.out.println(result);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
resources(name = "word", sources=["word.txt"])
|
|
@ -0,0 +1 @@
|
|||
from Us
|
|
@ -0,0 +1,8 @@
|
|||
junit_tests(
|
||||
name="tests",
|
||||
timeout=120,
|
||||
|
||||
dependencies=[
|
||||
"src/resources/com/baeldung/hellopant:word",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,30 @@
|
|||
package com.baeldung.hellopant;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.Resources;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GuavaUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenConvertListToStringAndSkipNull_thenConverted() {
|
||||
final List<String> names = Lists.newArrayList("John", null, "Jane", "Adam", "Tom");
|
||||
final String result = Joiner.on(",").skipNulls().join(names);
|
||||
|
||||
assertEquals(result, "John,Jane,Adam,Tom");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGettingTextFromAResourceFile_thenJoined() throws IOException {
|
||||
String world = Resources.toString(Resources.getResource(GuavaUnitTest.class, "word.txt"), Charsets.UTF_8).strip();
|
||||
String result = Joiner.on(" ").join("Hello", world);
|
||||
assertEquals(result, "Hello from Us");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue