File tree Expand file tree Collapse file tree 5 files changed +26
-4
lines changed
jvm/org/pantsbuild/example/lib
resources/org/pantsbuild/example/lib Expand file tree Collapse file tree 5 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 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 "
66backend_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 ]
2028args = [
2129 " -deprecation" ,
Original file line number Diff line number Diff line change 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+ )
Original file line number Diff line number Diff line change 11package org .pantsbuild .example .lib ;
22
3+ import com .google .common .base .Charsets ;
34import com .google .common .base .Joiner ;
5+ import com .google .common .io .Resources ;
6+ import java .io .IOException ;
47
58public 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}
Original file line number Diff line number Diff line change 1+ resources (sources = ["*.txt" ])
Original file line number Diff line number Diff line change 1+ World!
You can’t perform that action at this time.
0 commit comments