Skip to content

Commit 762f347

Browse files
authored
Bump to 2.9.0rc4, and demonstrate using resources. (#3)
1 parent 081b2f4 commit 762f347

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

pants.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the Apache License, Version 2.0 (see LICENSE).
33

44
[GLOBAL]
5-
pants_version = "2.9.0rc2"
5+
pants_version = "2.9.0rc5"
66
backend_packages = [
77
# This repository demonstrates a mix of Java and Scala, and so both backends are enabled. But each
88
# backend can be used independently, so there is no need to expose Scala BUILD file
@@ -16,6 +16,14 @@ backend_packages = [
1616
"pants.backend.experimental.scala.lint.scalafmt",
1717
]
1818

19+
[source]
20+
# Pants supports many layouts of sources: from Maven/SBT style project-centric layouts, to
21+
# monorepo layouts. In this case, we have a monorepo layout, with all sources under a `src`
22+
# directory, organized by type.
23+
#
24+
# See https://www.pantsbuild.org/docs/source-roots for more information.
25+
root_patterns = ["/src/*"]
26+
1927
[javac]
2028
args = [
2129
"-deprecation",
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
java_sources()
1+
java_sources(
2+
dependencies=[
3+
# Resource dependencies cannot be inferred, so we must explicitly declare that we
4+
# depend on them.
5+
"src/resources/org/pantsbuild/example/lib",
6+
],
7+
)
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package org.pantsbuild.example.lib;
22

3+
import com.google.common.base.Charsets;
34
import com.google.common.base.Joiner;
5+
import com.google.common.io.Resources;
6+
import java.io.IOException;
47

58
public class ExampleLib {
6-
public static String hello() {
7-
return Joiner.on(" ").join("Hello", "World!");
9+
public static String hello() throws IOException {
10+
String world =
11+
Resources.toString(Resources.getResource(ExampleLib.class, "world.txt"), Charsets.UTF_8)
12+
.strip();
13+
return Joiner.on(" ").join("Hello", world);
814
}
915
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
resources(sources=["*.txt"])
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
World!

0 commit comments

Comments
 (0)