Skip to content

Fix #677 Error if project is in OneDrive #680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/main/java/edu/wpi/first/gradlerio/GradleRIOPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import edu.wpi.first.gradlerio.deploy.FRCDeployPlugin;
import edu.wpi.first.gradlerio.deploy.roborio.RoboRIO;
import edu.wpi.first.gradlerio.wpi.WPIPlugin;
import edu.wpi.first.gradlerio.OneDriveException;

public abstract class GradleRIOPlugin implements Plugin<Project> {

Expand Down Expand Up @@ -77,6 +78,18 @@ public void execute(Parameters parameters) {

@Override
public void apply(Project project) {
boolean onedrive = false;
try {
if (project.getRootDir().toString().toUpperCase().contains("ONEDRIVE")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the if here. You can just assign onedrive straight to the whole result of the contains statement.

onedrive = true;
}
} catch(Exception e) {
System.out.println(e.toString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't print anything here. We just want to ignore any issue completely.

}

if (onedrive == true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just if (onedrive) {, don't need the == true.

throw new OneDriveException(project);
}

project.getPluginManager().apply(DeployUtils.class);
project.getPluginManager().apply(FRCDeployPlugin.class);
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/edu/wpi/first/gradlerio/OneDriveException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package edu.wpi.first.gradlerio;

import org.gradle.api.Project;

public class OneDriveException extends java.lang.RuntimeException {
public OneDriveException(Project project) {
super(String.format("Error cannot create project inside OneDrive. Project Directory = %S", project.getRootDir().toString()));
System.out.println(String.format("Error cannot create project inside OneDrive. Project Directory = %S", project.getRootDir().toString()));
_project = project;
}

public void printError() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need the printError function, or to store the project variable.

System.out.println(String.format("Error cannot create project inside OneDrive. Project Directory = %S", _project.getRootDir().toString()));
}

private Project _project;
}