diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..097f9f9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# Linux start script should use lf +/gradlew text eol=lf + +# These are Windows script files and should use crlf +*.bat text eol=crlf + diff --git a/.gitignore b/.gitignore index a332fb2..8576f18 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,6 @@ bin/ # End of https://www.gitignore.io/api/c++,java,linux,macos,gradle,windows,visualstudiocode + +# Ignore Gradle build output directory +build diff --git a/ExampleVendorJson.json b/ExampleVendorJson.json deleted file mode 100644 index e5188c9..0000000 --- a/ExampleVendorJson.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "fileName": "ExampleVendorJson.json", - "name": "ExampleVendorDep", - "version": "0.0.1", - "frcYear": "2024", - "uuid": "Generate A Unique GUID https://guidgenerator.com/online-guid-generator.aspx and insert it here", This line is to purposely make this fail to parse - "mavenUrls": [ - "ThisNeedsToBeTheRootMavenUrl" - ], - "jsonUrl": "InsertSomeUrlHere", - "javaDependencies": [ - { - "groupId": "com.vendor.frc", - "artifactId": "Vendor-java", - "version": "0.0.1" - } - ], - "jniDependencies": [ - { - "groupId": "com.vendor.frc", - "artifactId": "Vendor-driver", - "version": "0.0.1", - "skipInvalidPlatforms": true, - "isJar": false, - "validPlatforms": [ - "windowsx86-64", - "windowsx86", - "linuxarm64", - "linuxx86-64", - "linuxathena", - "linuxarm32", - "osxuniversal" - ] - } - ], - "cppDependencies": [ - { - "groupId": "com.vendor.frc", - "artifactId": "Vendor-cpp", - "version": "0.0.1", - "libName": "Vendor", - "headerClassifier": "headers", - "sharedLibrary": false, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "windowsx86", - "linuxarm64", - "linuxx86-64", - "linuxathena", - "linuxarm32", - "osxuniversal" - ] - }, - { - "groupId": "com.vendor.frc", - "artifactId": "Vendor-driver", - "version": "0.0.1", - "libName": "VendorDriver", - "headerClassifier": "headers", - "sharedLibrary": false, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "windowsx86", - "linuxarm64", - "linuxx86-64", - "linuxathena", - "linuxarm32", - "osxuniversal" - ] - } - ] -} diff --git a/README.md b/README.md deleted file mode 100644 index 0ebfba8..0000000 --- a/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# WPILib Vendor Template - -This is the base WPILib vendor template for 2023. - -## Layout - -The build is split into 3 libraries. A java library is built. This has access to all of wpilib, and also can JNI load the driver library. - -A driver library is built. This should contain all low level code you want to access from both C++, Java and any other text based language. This will not work with LabVIEW. This library has access to the WPILib HAL and wpiutil. This library can only export C symbols. It cannot export C++ symbols at all, and all C symbols must be explicitly listed in the symbols.txt file in the driver folder. JNI symbols must be listed in this file as well. This library however can be written in C++. If you attempt to change this library to have access to all of wpilib, you will break JNI access and it will no longer work. - -A native C++ library is built. This has access to all of wpilib, and access to the driver library. This should implment the standard wpilib interfaces. - -## Customizing -For Java, the library name will be the folder name the build is started from, so rename the folder to the name of your choosing. - -For the native impl, you need to change the library name in the exportsConfigs block of build.gradle, the components block of build.gradle, and the taskList input array name in publish.gradle. - -For the driver, change the library name in privateExportsConfigs, the driver name in components, and the driverTaskList input array name. In addition, you'll need to change the `lib library` in the native C++ impl component, and the JNI library name in the JNI java class. - -For the maven artifact names, those are all in publish.gradle about 40 lines down. - -## Building and editing -This uses gradle, and uses the same base setup as a standard GradleRIO robot project. This means you build with `./gradlew build`, and can install the native toolchain with `./gradlew installRoboRIOToolchain`. If you open this project in VS Code with the wpilib extension installed, you will get intellisense set up for both C++ and Java. - -By default, this template builds against the latest WPILib development build. To build against the last WPILib tagged release, build with `./gradlew build -PreleaseMode`. \ No newline at end of file diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 297b35b..0000000 --- a/build.gradle +++ /dev/null @@ -1,130 +0,0 @@ -plugins { - id 'cpp' - id 'java' - id 'google-test' - id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2' - id 'edu.wpi.first.NativeUtils' version '2024.6.1' - id 'edu.wpi.first.GradleJni' version '1.1.0' - id 'edu.wpi.first.GradleVsCode' version '2.1.0' -} - -repositories { - mavenCentral() -} -if (project.hasProperty('releaseMode')) { - wpilibRepositories.addAllReleaseRepositories(project) -} else { - wpilibRepositories.addAllDevelopmentRepositories(project) -} - -// Apply C++ configuration -apply from: 'config.gradle' - -// Apply Java configuration -dependencies { - implementation 'edu.wpi.first.cscore:cscore-java:2024.+' - implementation 'edu.wpi.first.cameraserver:cameraserver-java:2024.+' - implementation 'edu.wpi.first.ntcore:ntcore-java:2024.+' - implementation 'edu.wpi.first.wpilibj:wpilibj-java:2024.+' - implementation 'edu.wpi.first.wpiutil:wpiutil-java:2024.+' - implementation 'edu.wpi.first.wpimath:wpimath-java:2024.+' - implementation 'edu.wpi.first.wpiunits:wpiunits-java:2024.+' - implementation 'edu.wpi.first.hal:hal-java:2024.+' - implementation "org.ejml:ejml-simple:0.43.1" - implementation "com.fasterxml.jackson.core:jackson-annotations:2.12.4" - implementation "com.fasterxml.jackson.core:jackson-core:2.12.4" - implementation "com.fasterxml.jackson.core:jackson-databind:2.12.4" - implementation 'edu.wpi.first.thirdparty.frc2024.opencv:opencv-java:4.8.0-2' -} - -// Set up exports properly -nativeUtils { - exportsConfigs { - // Main library is just default empty. This will export everything - Vendor { - } - } - privateExportsConfigs { - // Only export explicit symbols from driver library - VendorDriver { - exportsFile = project.file("src/main/driver/symbols.txt") - } - } -} - -model { - components { - Vendor(NativeLibrarySpec) { - sources { - cpp { - source { - srcDirs 'src/main/native/cpp' - include '**/*.cpp' - } - exportedHeaders { - srcDirs 'src/main/native/include' - } - } - } - binaries.all { - lib library: 'VendorDriver', linkage: 'shared' - } - nativeUtils.useRequiredLibrary(it, 'wpilib_shared') - } - - VendorDriver(JniNativeLibrarySpec) { - enableCheckTask true - javaCompileTasks << compileJava - jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.roborio) - // Leave these for future proofing - jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm32) - jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm64) - sources { - cpp { - source { - srcDirs 'src/main/driver/cpp' - include '**/*.cpp' - } - exportedHeaders { - srcDirs 'src/main/driver/include' - } - } - } - - nativeUtils.useRequiredLibrary(it, "driver_shared") - } - } - testSuites { - VendorTest { - sources.cpp { - source { - srcDir 'src/test/native/cpp' - include '**/*.cpp' - } - } - - binaries.all { - lib library: 'VendorDriver', linkage: 'shared' - } - - nativeUtils.useRequiredLibrary(it, "wpilib_executable_shared", "googletest_static") - } - - VendorDriverTest { - sources.cpp { - source { - srcDir 'src/test/driver/cpp' - include '**/*.cpp' - } - } - - nativeUtils.useRequiredLibrary(it, "wpilib_executable_shared", "googletest_static") - } - } -} - -apply from: 'publish.gradle' - -wrapper { - gradleVersion '8.4' -} diff --git a/config.gradle b/config.gradle deleted file mode 100644 index 0c88342..0000000 --- a/config.gradle +++ /dev/null @@ -1,177 +0,0 @@ -import org.gradle.internal.os.OperatingSystem - -nativeUtils.addWpiNativeUtils() -nativeUtils.withCrossRoboRIO() - -nativeUtils { - wpi { - configureDependencies { - wpiVersion = "2024.+" - opencvYear = "frc2024" - googleTestYear = "frc2024" - niLibVersion = "2024.2.1" - opencvVersion = "4.8.0-2" - googleTestVersion = "1.14.0-1" - } - } -} - -nativeUtils.wpi.addWarnings() -nativeUtils.wpi.addWarningsAsErrors() - -nativeUtils.setSinglePrintPerPlatform() - -model { - // Uncomment this, and remove lines below it to enable builds for just roborio - // components { - // all { - // targetPlatform nativeUtils.wpi.platforms.roborio - // } - // } - components { - all { - nativeUtils.useAllPlatforms(it) - } - } - binaries { - withType(NativeBinarySpec).all { - nativeUtils.usePlatformArguments(it) - } - } -} - -ext.appendDebugPathToBinaries = { binaries-> - binaries.withType(StaticLibraryBinarySpec) { - if (it.buildType.name.contains('debug')) { - def staticFileDir = it.staticLibraryFile.parentFile - def staticFileName = it.staticLibraryFile.name - def staticFileExtension = staticFileName.substring(staticFileName.lastIndexOf('.')) - staticFileName = staticFileName.substring(0, staticFileName.lastIndexOf('.')) - staticFileName = staticFileName + 'd' + staticFileExtension - def newStaticFile = new File(staticFileDir, staticFileName) - it.staticLibraryFile = newStaticFile - } - } - binaries.withType(SharedLibraryBinarySpec) { - if (it.buildType.name.contains('debug')) { - def sharedFileDir = it.sharedLibraryFile.parentFile - def sharedFileName = it.sharedLibraryFile.name - def sharedFileExtension = sharedFileName.substring(sharedFileName.lastIndexOf('.')) - sharedFileName = sharedFileName.substring(0, sharedFileName.lastIndexOf('.')) - sharedFileName = sharedFileName + 'd' + sharedFileExtension - def newSharedFile = new File(sharedFileDir, sharedFileName) - - def sharedLinkFileDir = it.sharedLibraryLinkFile.parentFile - def sharedLinkFileName = it.sharedLibraryLinkFile.name - def sharedLinkFileExtension = sharedLinkFileName.substring(sharedLinkFileName.lastIndexOf('.')) - sharedLinkFileName = sharedLinkFileName.substring(0, sharedLinkFileName.lastIndexOf('.')) - sharedLinkFileName = sharedLinkFileName + 'd' + sharedLinkFileExtension - def newLinkFile = new File(sharedLinkFileDir, sharedLinkFileName) - - it.sharedLibraryLinkFile = newLinkFile - it.sharedLibraryFile = newSharedFile - } - } -} - -ext.createComponentZipTasks = { components, names, base, type, project, func -> - def stringNames = names.collect {it.toString()} - def configMap = [:] - components.each { - if (it in NativeLibrarySpec && stringNames.contains(it.name)) { - it.binaries.each { - if (!it.buildable) return - def target = nativeUtils.getPublishClassifier(it) - if (configMap.containsKey(target)) { - configMap.get(target).add(it) - } else { - configMap.put(target, []) - configMap.get(target).add(it) - } - } - } - } - def taskList = [] - def outputsFolder = file("$project.buildDir/outputs") - configMap.each { key, value -> - def task = project.tasks.create(base + "-${key}", type) { - description = 'Creates component archive for platform ' + key - destinationDirectory = outputsFolder - archiveClassifier = key - archiveBaseName = '_M_' + base - duplicatesStrategy = 'exclude' - - from(licenseFile) { - into '/' - } - - func(it, value) - } - taskList.add(task) - - project.build.dependsOn task - - project.artifacts { - task - } - addTaskToCopyAllOutputs(task) - } - return taskList -} - -ext.createAllCombined = { list, name, base, type, project -> - def outputsFolder = file("$project.buildDir/outputs") - - def task = project.tasks.create(base + "-all", type) { - description = "Creates component archive for all classifiers" - destinationDirectory = outputsFolder - classifier = "all" - archiveBaseName = base - duplicatesStrategy = 'exclude' - - list.each { - if (it.name.endsWith('debug')) return - from project.zipTree(it.archiveFile) - dependsOn it - } - } - - project.build.dependsOn task - - project.artifacts { - task - } - - return task - -} - -ext.includeStandardZipFormat = { task, value -> - value.each { binary -> - if (binary.buildable) { - if (binary instanceof SharedLibraryBinarySpec) { - task.dependsOn binary.tasks.link - task.from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) { - into nativeUtils.getPlatformPath(binary) + '/shared' - } - def sharedPath = binary.sharedLibraryFile.absolutePath - sharedPath = sharedPath.substring(0, sharedPath.length() - 4) - - task.from(new File(sharedPath + '.pdb')) { - into nativeUtils.getPlatformPath(binary) + '/shared' - } - task.from(binary.sharedLibraryFile) { - into nativeUtils.getPlatformPath(binary) + '/shared' - } - task.from(binary.sharedLibraryLinkFile) { - into nativeUtils.getPlatformPath(binary) + '/shared' - } - } else if (binary instanceof StaticLibraryBinarySpec) { - task.dependsOn binary.tasks.createStaticLib - task.from(binary.staticLibraryFile) { - into nativeUtils.getPlatformPath(binary) + '/static' - } - } - } - } -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..c5919b0 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,12 @@ +# This file was generated by the Gradle 'init' task. +# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format + +[versions] +commons-math3 = "3.6.1" +guava = "32.1.3-jre" +junit-jupiter = "5.10.1" + +[libraries] +commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" } +guava = { module = "com.google.guava:guava", version.ref = "guava" } +junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135..e644113 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3fa8f86..b82aa23 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew.bat b/gradlew.bat index 6689b85..25da30d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,92 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts new file mode 100644 index 0000000..7a236d1 --- /dev/null +++ b/lib/build.gradle.kts @@ -0,0 +1,41 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * This generated file contains a sample Java library project to get you started. + * For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.7/userguide/building_java_projects.html in the Gradle documentation. + */ + +plugins { + // Apply the java-library plugin for API and implementation separation. + `java-library` +} + +repositories { + // Use Maven Central for resolving dependencies. + mavenCentral() +} + +dependencies { + // Use JUnit Jupiter for testing. + testImplementation(libs.junit.jupiter) + + testRuntimeOnly("org.junit.platform:junit-platform-launcher") + + // This dependency is exported to consumers, that is to say found on their compile classpath. + api(libs.commons.math3) + + // This dependency is used internally, and not exposed to consumers on their own compile classpath. + implementation(libs.guava) +} + +// Apply a specific Java toolchain to ease working on different environments. +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} + +tasks.named("test") { + // Use JUnit Platform for unit tests. + useJUnitPlatform() +} diff --git a/lib/src/main/java/org/example/Library.java b/lib/src/main/java/org/example/Library.java new file mode 100644 index 0000000..b98461b --- /dev/null +++ b/lib/src/main/java/org/example/Library.java @@ -0,0 +1,10 @@ +/* + * This source file was generated by the Gradle 'init' task + */ +package org.example; + +public class Library { + public boolean someLibraryMethod() { + return true; + } +} diff --git a/lib/src/test/java/org/example/LibraryTest.java b/lib/src/test/java/org/example/LibraryTest.java new file mode 100644 index 0000000..ef34950 --- /dev/null +++ b/lib/src/test/java/org/example/LibraryTest.java @@ -0,0 +1,14 @@ +/* + * This source file was generated by the Gradle 'init' task + */ +package org.example; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class LibraryTest { + @Test void someLibraryMethodReturnsTrue() { + Library classUnderTest = new Library(); + assertTrue(classUnderTest.someLibraryMethod(), "someLibraryMethod should return 'true'"); + } +} diff --git a/publish.gradle b/publish.gradle deleted file mode 100644 index 477455a..0000000 --- a/publish.gradle +++ /dev/null @@ -1,205 +0,0 @@ -apply plugin: 'maven-publish' - -ext.licenseFile = files("$rootDir/LICENSE.txt") - -def pubVersion = '0.0.1' - -def outputsFolder = file("$buildDir/outputs") - -def versionFile = file("$outputsFolder/version.txt") - -task outputVersions() { - description = 'Prints the versions of wpilib to a file for use by the downstream packaging project' - group = 'Build' - outputs.files(versionFile) - - doFirst { - buildDir.mkdir() - outputsFolder.mkdir() - } - - doLast { - versionFile.write pubVersion - } -} - -task libraryBuild() {} - -build.dependsOn outputVersions - -task copyAllOutputs(type: Copy) { - destinationDir file("$buildDir/allOutputs") - from versionFile - dependsOn outputVersions -} - -build.dependsOn copyAllOutputs -copyAllOutputs.dependsOn outputVersions - -ext.addTaskToCopyAllOutputs = { task -> - copyAllOutputs.dependsOn task - copyAllOutputs.inputs.file task.archiveFile - copyAllOutputs.from task.archiveFile -} - -def artifactGroupId = 'com.vendor.frc' -def baseArtifactId = 'Vendor' -def driverZipBaseName = "_GROUP_com_vendor_frc_ID_${baseArtifactId}-driver_CLS" -def zipBaseName = "_GROUP_com_vendor_frc_ID_${baseArtifactId}-cpp_CLS" -def javaBaseName = "_GROUP_com_vendor_frc_ID_${baseArtifactId}-java_CLS" - -task cppHeadersZip(type: Zip) { - destinationDirectory = outputsFolder - archiveBaseName = zipBaseName - archiveClassifier = "headers" - - from(licenseFile) { - into '/' - } - - from('src/main/native/include') { - into '/' - } -} - -task cppSourceZip(type: Zip) { - destinationDirectory = outputsFolder - archiveBaseName = zipBaseName - archiveClassifier = "sources" - - from(licenseFile) { - into '/' - } - - from('src/main/native/cpp') { - into '/' - } -} - -task cppDriverHeadersZip(type: Zip) { - destinationDirectory = outputsFolder - archiveBaseName = driverZipBaseName - archiveClassifier = "headers" - - from(licenseFile) { - into '/' - } - - from('src/main/driver/include') { - into '/' - } -} - -build.dependsOn cppHeadersZip -addTaskToCopyAllOutputs(cppHeadersZip) -build.dependsOn cppSourceZip -addTaskToCopyAllOutputs(cppSourceZip) -build.dependsOn cppDriverHeadersZip -addTaskToCopyAllOutputs(cppDriverHeadersZip) - -task sourcesJar(type: Jar, dependsOn: classes) { - archiveClassifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - archiveClassifier = 'javadoc' - from javadoc.destinationDir -} - -task outputJar(type: Jar, dependsOn: classes) { - archiveBaseName = javaBaseName - destinationDirectory = outputsFolder - from sourceSets.main.output -} - -task outputSourcesJar(type: Jar, dependsOn: classes) { - archiveBaseName = javaBaseName - destinationDirectory = outputsFolder - archiveClassifier = 'sources' - from sourceSets.main.allSource -} - -task outputJavadocJar(type: Jar, dependsOn: javadoc) { - archiveBaseName = javaBaseName - destinationDirectory = outputsFolder - archiveClassifier = 'javadoc' - from javadoc.destinationDir -} - -artifacts { - archives sourcesJar - archives javadocJar - archives outputJar - archives outputSourcesJar - archives outputJavadocJar -} - -addTaskToCopyAllOutputs(outputSourcesJar) -addTaskToCopyAllOutputs(outputJavadocJar) -addTaskToCopyAllOutputs(outputJar) - -build.dependsOn outputSourcesJar -build.dependsOn outputJavadocJar -build.dependsOn outputJar - -libraryBuild.dependsOn build - -def releasesRepoUrl = "$buildDir/repos/releases" - -publishing { - repositories { - maven { - - url = releasesRepoUrl - } - } -} - -task cleanReleaseRepo(type: Delete) { - delete releasesRepoUrl -} - -tasks.matching {it != cleanReleaseRepo}.all {it.dependsOn cleanReleaseRepo} - -model { - publishing { - def taskList = createComponentZipTasks($.components, ['Vendor'], zipBaseName, Zip, project, includeStandardZipFormat) - - def driverTaskList = createComponentZipTasks($.components, ['VendorDriver'], driverZipBaseName, Zip, project, includeStandardZipFormat) - - publications { - cpp(MavenPublication) { - taskList.each { - artifact it - } - artifact cppHeadersZip - artifact cppSourceZip - - artifactId = "${baseArtifactId}-cpp" - groupId artifactGroupId - version pubVersion - } - driver(MavenPublication) { - driverTaskList.each { - artifact it - } - artifact cppDriverHeadersZip - - artifactId = "${baseArtifactId}-driver" - groupId artifactGroupId - version pubVersion - } - - java(MavenPublication) { - artifact jar - artifact sourcesJar - artifact javadocJar - - artifactId = "${baseArtifactId}-java" - groupId artifactGroupId - version pubVersion - } - } - } -} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 588dcaf..0000000 --- a/settings.gradle +++ /dev/null @@ -1,6 +0,0 @@ -pluginManagement { - repositories { - mavenLocal() - gradlePluginPortal() - } -} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..0bfec0d --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,14 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.7/userguide/multi_project_builds.html in the Gradle documentation. + */ + +plugins { + // Apply the foojay-resolver plugin to allow automatic download of JDKs + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" +} + +rootProject.name = "coppercore" +include("lib") diff --git a/src/main/driver/cpp/VendorJNI.cpp b/src/main/driver/cpp/VendorJNI.cpp deleted file mode 100644 index 0a3ce66..0000000 --- a/src/main/driver/cpp/VendorJNI.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "jni.h" -#include "com_vendor_jni_VendorJNI.h" - -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) { - // Check to ensure the JNI version is valid - - JNIEnv* env; - if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) - return JNI_ERR; - - // In here is also where you store things like class references - // if they are ever needed - - return JNI_VERSION_1_6; -} - -JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved) {} - -JNIEXPORT jint JNICALL Java_com_vendor_jni_VendorJNI_initialize - (JNIEnv *, jclass) { - return 0; -} diff --git a/src/main/driver/cpp/driversource.cpp b/src/main/driver/cpp/driversource.cpp deleted file mode 100644 index 15716a4..0000000 --- a/src/main/driver/cpp/driversource.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "driverheader.h" - -extern "C" { -void c_doThing() { - -} -} diff --git a/src/main/driver/include/driverheader.h b/src/main/driver/include/driverheader.h deleted file mode 100644 index 5aeff00..0000000 --- a/src/main/driver/include/driverheader.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -void c_doThing(); - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/src/main/driver/symbols.txt b/src/main/driver/symbols.txt deleted file mode 100644 index 2f9b641..0000000 --- a/src/main/driver/symbols.txt +++ /dev/null @@ -1,4 +0,0 @@ -JNI_OnLoad -JNI_OnUnload -Java_com_vendor_jni_VendorJNI_initialize -c_doThing diff --git a/src/main/java/com/vendor/jni/VendorJNI.java b/src/main/java/com/vendor/jni/VendorJNI.java deleted file mode 100644 index 3e4e01b..0000000 --- a/src/main/java/com/vendor/jni/VendorJNI.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.vendor.jni; - -import java.io.IOException; -import java.util.concurrent.atomic.AtomicBoolean; - -import edu.wpi.first.util.RuntimeLoader; - -/** - * Demo class for loading the driver via JNI. - */ -public class VendorJNI { - static boolean libraryLoaded = false; - static RuntimeLoader loader = null; - - /** - * Helper class for determining whether or not to load the driver on static initialization. - */ - public static class Helper { - private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true); - - /** - * Get whether to load the driver on static init. - * @return true if the driver will load on static init - */ - public static boolean getExtractOnStaticLoad() { - return extractOnStaticLoad.get(); - } - - /** - * Set whether to load the driver on static init. - * @param load the new value - */ - public static void setExtractOnStaticLoad(boolean load) { - extractOnStaticLoad.set(load); - } - } - - static { - if (Helper.getExtractOnStaticLoad()) { - try { - loader = new RuntimeLoader<>("VendorDriver", RuntimeLoader.getDefaultExtractionRoot(), VendorJNI.class); - loader.loadLibrary(); - } catch (IOException ex) { - ex.printStackTrace(); - System.exit(1); - } - libraryLoaded = true; - } - } - - /** - * Force load the library. - * @throws java.io.IOException thrown if the native library cannot be found - */ - public static synchronized void forceLoad() throws IOException { - if (libraryLoaded) { - return; - } - loader = new RuntimeLoader<>("VendorDriver", RuntimeLoader.getDefaultExtractionRoot(), VendorJNI.class); - loader.loadLibrary(); - libraryLoaded = true; - } - - /** - * Tells the driver to initialize. - * This is a demo of a native JNI method from the driver. - * - * @return the int returned by the driver - * @see "VendorJNI.cpp" - */ - public static native int initialize(); -} diff --git a/src/main/native/cpp/source.cpp b/src/main/native/cpp/source.cpp deleted file mode 100644 index 3990d40..0000000 --- a/src/main/native/cpp/source.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "header.h" -#include "driverheader.h" - -void func() { - c_doThing(); -} diff --git a/src/main/native/include/header.h b/src/main/native/include/header.h deleted file mode 100644 index e69de29..0000000 diff --git a/src/test/driver/cpp/main.cpp b/src/test/driver/cpp/main.cpp deleted file mode 100644 index d0e7d22..0000000 --- a/src/test/driver/cpp/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "gtest/gtest.h" - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/src/test/native/cpp/main.cpp b/src/test/native/cpp/main.cpp deleted file mode 100644 index d0e7d22..0000000 --- a/src/test/native/cpp/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "gtest/gtest.h" - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -}