Guard against misconfigured target directory#47
Open
kafji wants to merge 1 commit intomozilla:masterfrom
kafji:kfj/guard-target-dir
Open
Guard against misconfigured target directory#47kafji wants to merge 1 commit intomozilla:masterfrom kafji:kfj/guard-target-dir
kafji wants to merge 1 commit intomozilla:masterfrom
kafji:kfj/guard-target-dir
Conversation
ncalexan
requested changes
Apr 22, 2021
Member
ncalexan
left a comment
There was a problem hiding this comment.
Sorry for the long delay before reviewing. I don't think this is right as written, but I'm happy to help the user do the right thing in this case.
| ?: targetDirectory | ||
| ?: "${module!!}/target" | ||
|
|
||
| if (Files.exists(Paths.get(targetDirectory))) { |
Member
There was a problem hiding this comment.
This conditional looks backwards -- surely you want !Files.exists(...).
| ?: "${module!!}/target" | ||
|
|
||
| if (Files.exists(Paths.get(targetDirectory))) { | ||
| throw GradleException("Cargo target directory (`${targetDirectory}`) is not exists. If you're using Cargo Workspace, you need to specify the target directory in `build.gradle` or `local.properties` (see https://github.com/mozilla/rust-android-gradle#targetdirectory).") |
Member
There was a problem hiding this comment.
nit: s/is not exists/does not exist/. And s/Cargo Workspace/a Cargo workspace/.
When the Rust project is inside a Cargo Workspace this plugin will _fail_ silently because by default it assumes Cargo target directory will be inside the module directory. This patch add a guard against misconfigured target directory. When the target directory not exists, we'll make the build fails and point user to the documentation. ``` Cargo target directory (`../../target`) does not exists. If you're using a Cargo Workspace, you need to specify the target directory in `build.gradle` or `local.properties` (see https://github.com/mozilla/rust-android-gradle#targetdirectory). ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the Rust project is inside a Cargo Workspace this plugin will
fail silently because by default it assumes Cargo target directory
will be inside the module directory.
This patch add a guard against misconfigured target directory. When the
target directory not exists, we'll make the build fails and point user
to the documentation.