Comments (9)
I want to provide a few details. The issue that I face that led to this report is a maven project with a second maven project nested beneath it.
/foo/pom.XML
/foo/BUILD
/foo/src/main/java
/foo/src/main/proto/
/foo/src/test/java
/foo/bar/pom.XML
/foo/bar/BUILD
/foo/bar/src/main/java
/foo/bar/src/main/proto
/foo/bar/src/test/java
The source roots are not really nested, but the project BUILD files where I defined java_library and java_protobuf_library are nested. The logic in sources.py assumes that given a target, you can find a single source root from it (before analyzing the source file list.) I took a quick stab at trying to infer the correct source root from the list of source files but hit a chicken and egg issue in some constructor calling SourceRoot.find()
from pants.
I think that patrick's currently in-flight refactor of BUILD file parsing
and the target hierarchy also re-does source roots. For example, it gets
rid of the shady logic we currently have where if it can't find an
appropriate source root when it parses a target it lazily evaluates BUILD
files by climbing up the directory ancestry until it finds a source_root()
that works.
After his refactor the source_roots won't be lazily discovered, they'll
have to be declared up front in BUILD.bootstrap or wherever.
So I expect that he'll be able to support this kind of thing pretty easily,
basically your source root will be whichever one is "closest" to you in the
ancestry. I think this is what you'd expect, and also supports your use
case?
On Thu, Apr 3, 2014 at 6:01 AM, Eric Ayers [email protected] wrote:
I want to provide a few details. The issue that I face that led to this
report is a maven project with a second maven project nested beneath it./foo/pom.XML
/foo/BUILD
/foo/src/main/java
/foo/src/main/proto/
/foo/src/test/java/foo/bar/pom.XML
/foo/bar/BUILD
/foo/bar/src/main/java
/foo/bar/src/main/proto
/foo/bar/src/test/javaThe source roots are not really nested, but the project BUILD files where
I defined java_library and java_protobuf_library are nested. The logic in
sources.py assumes that given a target, you can find a single source root
from it (before analyzing the source file list.) I took a quick stab at
trying to infer the correct source root from the list of source files but
hit a chicken and egg issue in some constructor calling SourceRoot.find()—
Reply to this email directly or view it on GitHubhttps://github.com//issues/11#issuecomment-39447696
.
from pants.
I'll have to look at the code. The problem as I saw it was not from the lazy evaluation when the BUILD file is underneath two prospective source roots.
source_root('/foo/src/main/proto/src', java_protobuf_library)
source_root('/foo/bar/src/main/proto/src', java_protobuf_library)
If you had a target foo/BUILD that contained a java_protobuf_library(name="proto", ...), how would it choose between foo/src/main/proto/src and foo/bar/src/main/proto/src as the "source root" for the target?
This is currently important for figuring out the appropriate --proto-path arguments to protoc.
from pants.
Where are the sources of that java_protobuf_library?
On Thu, Apr 3, 2014 at 11:54 AM, Eric Ayers [email protected]:
I'll have to look at the code. The problem as I saw it was not from the
lazy evaluation when the BUILD file is underneath two prospective source
roots.source_root('/foo/src/main/proto/src', java_protobuf_library)
source_root('/foo/bar/src/main/proto/src', java_protobuf_library)If you had a target foo/BUILD that contained a
java_protobuf_library(name="proto", ...), how would it choose between
foo/src/main/proto/src and foo/bar/src/main/proto/src as the "source root"
for the target?This is currently important for figuring out the appropriate --proto-path
arguments to protoc.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/11#issuecomment-39490411
.
from pants.
The sources would be where ever you defined them to be in sources[], but in maven, they would be under src/main/proto beneath the pom.xml file:
foo/src/main/proto/com/squareup/foo/foo.proto contains
import "squareup/com/foo/bar/bar.proto"
...
foo/pom.xml # contains maven deps for the foo/ project
foo/BUILD:
java_protobuf_library(
name = 'proto',
sources = [
'./src/main/proto/com/squareup/foo/foo.proto',
],
dependencies = [
'foo/bar:proto',
],
)
/foo/bar/src/main/proto/com/squareup/foo/bar/bar.proto
foo/bar/pom.xml # contains maven deps for the foo/bar project
foo/bar/BUILD:
java_protobuf_library(
name = 'proto',
sources = [
'./src/main/proto/com/squareup/foo/bar/bar.proto',
],
)
from pants.
What I mean is, the answer to your question "how would it choose between
foo/src/main/proto/src and foo/bar/src/main/proto/src" should be that it'll
take whichever one is the closest ancestor to all of the sources.
Technically source_root should be a property of the payload, not of the
target.
On Thu, Apr 3, 2014 at 11:54 AM, Eric Ayers [email protected]:
I'll have to look at the code. The problem as I saw it was not from the
lazy evaluation when the BUILD file is underneath two prospective source
roots.source_root('/foo/src/main/proto/src', java_protobuf_library)
source_root('/foo/bar/src/main/proto/src', java_protobuf_library)If you had a target foo/BUILD that contained a
java_protobuf_library(name="proto", ...), how would it choose between
foo/src/main/proto/src and foo/bar/src/main/proto/src as the "source root"
for the target?This is currently important for figuring out the appropriate --proto-path
arguments to protoc.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/11#issuecomment-39490411
.
from pants.
Assigning to @benjyw to close, but I think this can now be closed. Source roots are discovered unambiguously in overlapping cases now IIUC.
from pants.
Yes, source roots are discovered unambiguously, and the way they do so is configured via options. Bootstrap BUILD files are gone, as is the problematic logic in SourceRoots.find().
from pants.
Hooray!
from pants.
Related Issues (20)
- Add `fields`-like option to peek to filter JSON and to reduce number associated commands
- Using complete_platforms that loads a resource (instead of file) should show an error
- Ambiguous pex_binary entry_point fields get ambiguous dep inference warnings that cannot be disambiguated in 2.20 HOT 4
- [v2.20.0] Lockfile generation with multiple indexes fails due to mismatching hashes HOT 4
- BoolOption does not allow default=None HOT 2
- pyright not able to discover pyproject.toml in source root
- pants help-all errors on missing help text, but help text is not a required field. HOT 1
- "big" docker inputs slows pants to a crawl; hangs/freezes(?) UI HOT 1
- faas pex should allow users to change default platform HOT 13
- Add support for buildifier style in BUILD files, or support running an auto-format binary after `pants tailor` HOT 7
- pants `dependencies` and `dependents` goals with `--format=json` don't respect `--output-file`
- BUILD couldn't be created in a directory which contains a directory called build HOT 1
- 2.21 release preparation
- Built-in lockfiles won't work with Python 3.13, due to pip version
- Publish SchemaStore schema for Pants 2.20.0 HOT 1
- Tool boilerplate reduction HOT 6
- Cryptic error when `package.json` is missing a name HOT 1
- Lint using code_quality_tool fails
- Can't export virtualenv HOT 1
- allow configuration to disable generation of shunit2_tests targets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pants.