Skip to content

Commit

Permalink
Update to gradle 8.11 (#761)
Browse files Browse the repository at this point in the history
Includes much nicer warning APIs.

Update native utils.
  • Loading branch information
ThadHouse authored Nov 18, 2024
1 parent c2f5e86 commit 2872267
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 16 deletions.
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
dependencies {
api 'com.google.code.gson:gson:2.8.6'

api 'edu.wpi.first:native-utils:2025.4.0'
api 'edu.wpi.first:native-utils:2025.6.0'

api 'de.undercouch:gradle-download-task:4.1.2'

Expand Down Expand Up @@ -52,6 +52,10 @@ allprojects {
tasks.withType(Javadoc) {
options.addBooleanOption('Xdoclint:all,-missing', true)
}

tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}

gradlePlugin {
Expand Down Expand Up @@ -109,6 +113,6 @@ examplesFolder.eachFile { File file ->
jar.finalizedBy zipExamples

wrapper {
gradleVersion = '8.10.2'
gradleVersion = '8.11'
distributionType = Wrapper.DistributionType.BIN
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void deploy(DeployContext arg0) {
}

public FileCollection computeFiles() {
Set<File> configFileCaches = configuration.get().getResolvedConfiguration().getFiles();
Set<File> configFileCaches = configuration.get().getIncoming().getFiles().getFiles();
if (zipped) {
Optional<FileTree> allFiles = configFileCaches.stream().map(file -> getTarget().getProject().zipTree(file).matching(filter)).filter(x -> x != null).reduce((a, b) -> a.plus(b));
if (allFiles.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private Set<File> getFiles() {
for (Configuration cfg : configs) {
if (cfg.isCanBeResolved()) {
logger.info("Resolving Deps Configuration: " + cfg.getName());
files.addAll(cfg.getResolvedConfiguration().getFiles());
files.addAll(cfg.getIncoming().getFiles().getFiles());
} else {
logger.info("Can't resolve: " + cfg.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.TaskAction;
import org.gradle.internal.os.OperatingSystem;
import org.gradle.process.ExecOperations;

import edu.wpi.first.gradlerio.SingletonTask;

public class CppToolRunTask extends DefaultTask implements SingletonTask {
private final Property<String> toolName;
private final DirectoryProperty toolsFolder;
private final ExecOperations operations;

@Internal
public Property<String> getToolName() {
Expand All @@ -33,11 +35,12 @@ public DirectoryProperty getToolsFolder() {
}

@Inject
public CppToolRunTask(ObjectFactory objects) {
public CppToolRunTask(ObjectFactory objects, ExecOperations execOperations) {
setGroup("GradleRIO");

this.toolName = objects.property(String.class);
toolsFolder = objects.directoryProperty();
operations = execOperations;
}

@TaskAction
Expand Down Expand Up @@ -78,7 +81,7 @@ private void runToolUnix() {
Directory toolsFolder = this.toolsFolder.get();
String toolName = this.toolName.get();
File outputFile = toolsFolder.file(toolName + ".sh").getAsFile();
getProject().exec(spec -> {
operations.exec(spec -> {
spec.setExecutable(outputFile.getAbsolutePath());
spec.args(getArgumentPath(toolName.toLowerCase()));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
import org.gradle.api.file.CopySpec;
import org.gradle.api.file.Directory;
import org.gradle.api.file.DirectoryProperty;
Expand All @@ -30,6 +31,7 @@
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.TaskAction;
import org.gradle.internal.os.OperatingSystem;
import org.gradle.process.ExecOperations;
import org.gradle.process.ExecSpec;

public class ToolInstallTask extends DefaultTask {
Expand All @@ -41,6 +43,7 @@ public class ToolInstallTask extends DefaultTask {
private final Property<Configuration> configuration;
private final Property<String> toolName;
private final Property<String> artifactName;
private final ExecOperations operations;

@Internal
public DirectoryProperty getToolsFolder() {
Expand Down Expand Up @@ -80,13 +83,14 @@ private static class ToolConfig {
}

@Inject
public ToolInstallTask(ObjectFactory objects) {
public ToolInstallTask(ObjectFactory objects, ExecOperations execOperations) {
setGroup("GradleRIO");

toolsFolder = objects.directoryProperty();
configuration = objects.property(Configuration.class);
toolName = objects.property(String.class);
artifactName = objects.property(String.class);
operations = execOperations;
}

private static synchronized Optional<ToolConfig> getExistingToolVersion(Directory toolsFolder, String toolName) {
Expand Down Expand Up @@ -178,9 +182,19 @@ public void installTool() {
}
}

private static void extractAndInstall(Project project, String toolName, Directory toolsFolder,
private void extractAndInstall(Project project, String toolName, Directory toolsFolder,
Dependency dependency, Configuration configuration) {
File jarfile = configuration.files(dependency).iterator().next();

File jarfile = configuration.getIncoming().artifactView(viewCfg -> {
viewCfg.componentFilter(filter -> {
if (filter instanceof ModuleComponentIdentifier idf) {
return idf.getGroup().equals(dependency.getGroup()) && idf.getModule().equals(dependency.getName())
&& idf.getVersion().equals(dependency.getVersion());
}
return false;
});
}).getFiles().iterator().next();

File of = toolsFolder.getAsFile();
of.mkdirs();
project.copy(new Action<CopySpec>() {
Expand Down Expand Up @@ -212,14 +226,15 @@ private static void extractScriptWindows(Directory toolsFolder, String toolName)
}
}

private static void extractScriptUnix(Project project, Directory toolsFolder, String toolName) {
private void extractScriptUnix(Project project, Directory toolsFolder, String toolName) {
File outputFile = toolsFolder.file(toolName + ".sh").getAsFile();
try (InputStream it = ToolInstallTask.class.getResourceAsStream("/ScriptBase.sh")) {
ResourceGroovyMethods.setText(outputFile, IOGroovyMethods.getText(it));
} catch (IOException e) {
throw new RuntimeException(e);
}
project.exec(new Action<ExecSpec>() {

operations.exec(new Action<ExecSpec>() {

@Override
public void execute(ExecSpec spec) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.TaskAction;
import org.gradle.internal.os.OperatingSystem;
import org.gradle.process.ExecOperations;

import edu.wpi.first.gradlerio.SingletonTask;
import groovy.transform.CompileStatic;
Expand All @@ -24,6 +25,7 @@ public class ToolRunTask extends DefaultTask implements SingletonTask {

private final Property<String> toolName;
private final DirectoryProperty toolsFolder;
private final ExecOperations operations;

@Internal
public Property<String> getToolName() {
Expand All @@ -36,11 +38,12 @@ public DirectoryProperty getToolsFolder() {
}

@Inject
public ToolRunTask(ObjectFactory objects) {
public ToolRunTask(ObjectFactory objects, ExecOperations execOperations) {
setGroup("GradleRIO");

toolName = objects.property(String.class);
toolsFolder = objects.directoryProperty();
operations = execOperations;
}

@TaskAction
Expand Down Expand Up @@ -77,7 +80,7 @@ private void runToolUnix() {
Directory toolsFolder = this.toolsFolder.get();
String toolName = this.toolName.get();
File outputFile = toolsFolder.file(toolName + ".sh").getAsFile();
getProject().exec(spec -> {
operations.exec(spec -> {
spec.setExecutable(outputFile.getAbsolutePath());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.gradle.api.Named;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.file.Directory;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.TaskProvider;
Expand All @@ -18,7 +17,7 @@ public class WPICppTool implements Named {
private final Provider<String> version;

public WPICppTool(Project project, String name, Provider<String> version, String artifactId, Provider<Directory> toolsFolder) {
Configuration config = project.getConfigurations().getByName("wpiCppTools");
//Configuration config = project.getConfigurations().getByName("wpiCppTools");
String toolsClassifier = project.getExtensions().getByType(WPIExtension.class).getCppToolsClassifier();
Provider<String> fullId = project.getProviders().provider(() -> {
String id = artifactId;
Expand Down

0 comments on commit 2872267

Please sign in to comment.