Skip to content

Commit e05c24f

Browse files
authored
Fix #677 Error if project is in OneDrive (#680)
* search project initialised directory for onedrive in execute function * apply changes from review * fix error being supressed * use runtime exception in onedrive error * add print in error and make check case insensitive * use Paths.get instead of user.dir * move check to apply method and use gradle method instead of java method * remove unnecessary imports from previous commit * remove another unnecessary import * fix printed directory * catch and print error instead of throwing it * try catch check only throw if try catch succeeds * fix items from review
1 parent 98c2d57 commit e05c24f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/main/java/edu/wpi/first/gradlerio/GradleRIOPlugin.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import edu.wpi.first.gradlerio.deploy.FRCDeployPlugin;
4545
import edu.wpi.first.gradlerio.deploy.roborio.RoboRIO;
4646
import edu.wpi.first.gradlerio.wpi.WPIPlugin;
47+
import edu.wpi.first.gradlerio.OneDriveException;
4748

4849
public abstract class GradleRIOPlugin implements Plugin<Project> {
4950

@@ -77,6 +78,14 @@ public void execute(Parameters parameters) {
7778

7879
@Override
7980
public void apply(Project project) {
81+
boolean onedrive = false;
82+
try {
83+
onedrive = (project.getRootDir().toString().toUpperCase().contains("ONEDRIVE"));
84+
} catch (Exception e) {}
85+
86+
if (onedrive) {
87+
throw new OneDriveException(project);
88+
}
8089

8190
project.getPluginManager().apply(DeployUtils.class);
8291
project.getPluginManager().apply(FRCDeployPlugin.class);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package edu.wpi.first.gradlerio;
2+
3+
import org.gradle.api.Project;
4+
5+
public class OneDriveException extends java.lang.RuntimeException {
6+
public OneDriveException(Project project) {
7+
super(String.format("Error cannot create project inside OneDrive. Project Directory = %S", project.getRootDir().toString()));
8+
System.out.println(String.format("Error cannot create project inside OneDrive. Project Directory = %S", project.getRootDir().toString()));
9+
}
10+
}

0 commit comments

Comments
 (0)