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
5
pants/.gitignore
vendored
Normal file
5
pants/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.idea/
|
||||||
|
.pants.d/
|
||||||
|
.pids/
|
||||||
|
dist/
|
||||||
|
pants.toml.bak
|
5
pants/3rdparty/jvm/com/google/guava/BUILD
vendored
Normal file
5
pants/3rdparty/jvm/com/google/guava/BUILD
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
jvm_artifact(
|
||||||
|
group="com.google.guava",
|
||||||
|
artifact="guava",
|
||||||
|
version="18.0",
|
||||||
|
)
|
63
pants/3rdparty/jvm/default.lock
vendored
Normal file
63
pants/3rdparty/jvm/default.lock
vendored
Normal file
@ -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
|
5
pants/3rdparty/jvm/junit/junit/BUILD
vendored
Normal file
5
pants/3rdparty/jvm/junit/junit/BUILD
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
jvm_artifact(
|
||||||
|
group="junit",
|
||||||
|
artifact="junit",
|
||||||
|
version="4.13.2"
|
||||||
|
)
|
7
pants/bsp-groups.toml
Normal file
7
pants/bsp-groups.toml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[groups.default]
|
||||||
|
addresses = [
|
||||||
|
"src/jvm::",
|
||||||
|
"tests/jvm::",
|
||||||
|
]
|
||||||
|
|
||||||
|
resolve = "jvm:jvm-default"
|
22
pants/pants.toml
Normal file
22
pants/pants.toml
Normal file
@ -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"]
|
15
pants/src/com/baeldung/hellopant/BUILD
Normal file
15
pants/src/com/baeldung/hellopant/BUILD
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
java_sources(
|
||||||
|
dependencies=[
|
||||||
|
"src/resources/com/baeldung/hellopant:word",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
deploy_jar(
|
||||||
|
name="HelloPant",
|
||||||
|
main="com.baeldung.hellopant",
|
||||||
|
dependencies=[
|
||||||
|
":hellopant",
|
||||||
|
],
|
||||||
|
)
|
20
pants/src/com/baeldung/hellopant/Hello.java
Normal file
20
pants/src/com/baeldung/hellopant/Hello.java
Normal file
@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
1
pants/src/resources/com/baeldung/hellopant/BUILD
Normal file
1
pants/src/resources/com/baeldung/hellopant/BUILD
Normal file
@ -0,0 +1 @@
|
|||||||
|
resources(name = "word", sources=["word.txt"])
|
1
pants/src/resources/com/baeldung/hellopant/word.txt
Normal file
1
pants/src/resources/com/baeldung/hellopant/word.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
from Us
|
8
pants/test/com/baeldung/hellopant/BUILD
Normal file
8
pants/test/com/baeldung/hellopant/BUILD
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
junit_tests(
|
||||||
|
name="tests",
|
||||||
|
timeout=120,
|
||||||
|
|
||||||
|
dependencies=[
|
||||||
|
"src/resources/com/baeldung/hellopant:word",
|
||||||
|
],
|
||||||
|
)
|
30
pants/test/com/baeldung/hellopant/GuavaUnitTest.java
Normal file
30
pants/test/com/baeldung/hellopant/GuavaUnitTest.java
Normal file
@ -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");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
1
pom.xml
1
pom.xml
@ -355,6 +355,7 @@
|
|||||||
<!-- <module>guest</module> --> <!-- not to be built as its for guest articles -->
|
<!-- <module>guest</module> --> <!-- not to be built as its for guest articles -->
|
||||||
|
|
||||||
<!-- <module>lagom</module> --> <!-- Not a maven project -->
|
<!-- <module>lagom</module> --> <!-- Not a maven project -->
|
||||||
|
<!-- <module>pants</module> --> <!-- Not a maven project -->
|
||||||
|
|
||||||
<module>libraries-jdk8</module>
|
<module>libraries-jdk8</module>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user