diff --git a/Jenkinsfile b/Jenkinsfile index 163b3ff9..3446eb97 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,8 +3,8 @@ * easy Linux/Windows testing and produces incrementals. The only feature that relates to plugins is * allowing one to test against multiple Jenkins versions. */ -buildPlugin(useContainerAgent: true, configurations: [ - [platform: 'linux', jdk: 21], - [platform: 'linux', jdk: 17], +buildPlugin(useContainerAgent: false, configurations: [ + [platform: 'windows', jdk: 17], + [platform: 'windows', jdk: 21] ]) diff --git a/build.cmd b/build.cmd index 47881dc2..028ce730 100644 --- a/build.cmd +++ b/build.cmd @@ -1,12 +1,16 @@ @echo off -setlocal -set PATH=%PATH%;%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\amd64 -set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140 +setlocal enabledelayedexpansion set BUIDROOT=%cd% +for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products * -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do ( + set MSBUILD="%%i" +) + +echo "MSBUILD=%MSBUILD%" + :getopts if "%2"=="" ( - set configuration="Release" + set configuration="Debug" ) else ( set configuration=%2% ) @@ -14,7 +18,7 @@ if "%2"=="" ( if "%3"=="" ( echo No target version specified, will determine it from POM REM TODO: Apply some MADSKILLZ to do it without the temporary file? - call mvn -q -Dexec.executable="cmd.exe" -Dexec.args="/c echo ${project.version}" --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec > version.txt + call mvn -q -Dexec.executable="cmd.exe" -Dexec.args="/c echo ${project.version}" --non-recursive org.codehaus.mojo:exec-maven-plugin:3.5.0:exec > version.txt for /f "delims=" %%x in (version.txt) do set version=%%x ) else ( echo Setting MVN project version to the externally defined %3% @@ -26,46 +30,47 @@ if "%1"=="" (goto :default) else (goto :%1) goto :exit :default -goto :cleanbuild +goto :build -:cleanbuild +:clean echo ### Cleaning the %configuration% build directory cd %BUIDROOT%\native -msbuild winp.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="Win32" +%MSBUILD% winp.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="Win32" if %errorlevel% neq 0 exit /b %errorlevel% -msbuild winp.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="x64" +%MSBUILD% winp.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="x64" if %errorlevel% neq 0 exit /b %errorlevel% -msbuild sendctrlc\sendctrlc.vcxproj /t:Clean /p:Configuration=Release /verbosity:minimal /nologo /p:Platform="Win32" +%MSBUILD% sendctrlc\sendctrlc.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="Win32" if %errorlevel% neq 0 exit /b %errorlevel% -msbuild sendctrlc\sendctrlc.vcxproj /t:Clean /p:Configuration=Release /verbosity:minimal /nologo /p:Platform="x64" +%MSBUILD% sendctrlc\sendctrlc.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="x64" if %errorlevel% neq 0 exit /b %errorlevel% -msbuild ..\native_test\testapp\testapp.vcxproj /t:Clean /p:Configuration=Release /verbosity:minimal /nologo /p:Platform="Win32" +%MSBUILD% ..\native_test\testapp\testapp.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="Win32" if %errorlevel% neq 0 exit /b %errorlevel% -msbuild ..\native_test\testapp\testapp.vcxproj /t:Clean /p:Configuration=Release /verbosity:minimal /nologo /p:Platform="x64" +%MSBUILD% ..\native_test\testapp\testapp.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="x64" if %errorlevel% neq 0 exit /b %errorlevel% -goto :build +goto :exit :build echo ### Building the %configuration% configuration cd %BUIDROOT%\native REM /verbosity:minimal -msbuild winp.vcxproj /p:Configuration=%configuration% /nologo /p:Platform="Win32" +%MSBUILD% winp.vcxproj /p:Configuration=%configuration% /nologo /p:Platform="Win32" if %errorlevel% neq 0 exit /b %errorlevel% -msbuild winp.vcxproj /p:Configuration=%configuration% /nologo /p:Platform="x64" +%MSBUILD% winp.vcxproj /p:Configuration=%configuration% /nologo /p:Platform="x64" if %errorlevel% neq 0 exit /b %errorlevel% -msbuild sendctrlc\sendctrlc.vcxproj /p:Configuration=%configuration% /nologo /p:Platform="Win32" +%MSBUILD% sendctrlc\sendctrlc.vcxproj /p:Configuration=%configuration% /nologo /p:Platform="Win32" if %errorlevel% neq 0 exit /b %errorlevel% -msbuild sendctrlc\sendctrlc.vcxproj /p:Configuration=%configuration% /nologo /p:Platform="x64" +%MSBUILD% sendctrlc\sendctrlc.vcxproj /p:Configuration=%configuration% /nologo /p:Platform="x64" if %errorlevel% neq 0 exit /b %errorlevel% echo ### Building test applications -msbuild ..\native_test\testapp\testapp.vcxproj /verbosity:minimal /p:Configuration=Release /nologo /p:Platform="Win32" +%MSBUILD% ..\native_test\testapp\testapp.vcxproj /verbosity:minimal /p:Configuration=%configuration% /nologo /p:Platform="Win32" if %errorlevel% neq 0 exit /b %errorlevel% -msbuild ..\native_test\testapp\testapp.vcxproj /verbosity:minimal /p:Configuration=Release /nologo /p:Platform="x64" +%MSBUILD% ..\native_test\testapp\testapp.vcxproj /verbosity:minimal /p:Configuration=%configuration% /nologo /p:Platform="x64" if %errorlevel% neq 0 exit /b %errorlevel% echo ### Updating WinP resource files for the %configuration% build cd %BUIDROOT% +mkdir src\main\resources COPY native\%configuration%\winp.dll src\main\resources\winp.dll if %errorlevel% neq 0 exit /b %errorlevel% COPY native\x64\%configuration%\winp.dll src\main\resources\winp.x64.dll @@ -75,13 +80,5 @@ if %errorlevel% neq 0 exit /b %errorlevel% COPY native\sendctrlc\x64\%configuration%\sendctrlc.exe src\main\resources\sendctrlc.x64.exe if %errorlevel% neq 0 exit /b %errorlevel% -echo ### Build and Test winp.jar for %version% -cd %BUIDROOT% -call mvn -q --batch-mode versions:set -DnewVersion=%version% -if %errorlevel% neq 0 exit /b %errorlevel% -call mvn --batch-mode clean package verify -if %errorlevel% neq 0 exit /b %errorlevel% -goto :exit - :exit endlocal diff --git a/native/sendctrlc/sendctrlc.vcxproj b/native/sendctrlc/sendctrlc.vcxproj index 7c84891a..3f8eba7a 100644 --- a/native/sendctrlc/sendctrlc.vcxproj +++ b/native/sendctrlc/sendctrlc.vcxproj @@ -28,26 +28,26 @@ Application true - v140 + v142 Unicode Application true - v140 + v142 Unicode Application false - v140 + v142 true Unicode Application false - v140 + v142 true Unicode diff --git a/native/winp.vcxproj b/native/winp.vcxproj index 8227e80d..8c852d6d 100644 --- a/native/winp.vcxproj +++ b/native/winp.vcxproj @@ -26,24 +26,24 @@ DynamicLibrary - v140 + v142 Unicode true DynamicLibrary - v140 + v142 Unicode DynamicLibrary - v140 + v142 Unicode true DynamicLibrary - v140 + v142 Unicode diff --git a/native_test/testapp/testapp.vcxproj b/native_test/testapp/testapp.vcxproj index ecd78a78..8095a7f5 100644 --- a/native_test/testapp/testapp.vcxproj +++ b/native_test/testapp/testapp.vcxproj @@ -28,26 +28,26 @@ Application true - v140 + v142 Unicode Application true - v140 + v142 Unicode Application false - v140 + v142 true Unicode Application false - v140 + v142 true Unicode diff --git a/pom.xml b/pom.xml index a414abcb..c6ea5dbb 100644 --- a/pom.xml +++ b/pom.xml @@ -114,4 +114,50 @@ https://repo.jenkins-ci.org/public/ + + + + build-native + + + Windows + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.5.0 + + + build-native + + exec + + process-resources + + build.cmd + + + + clean-native + + exec + + clean + + build.cmd + + clean + + + + + + + + + + diff --git a/src/main/resources/sendctrlc.exe b/src/main/resources/sendctrlc.exe deleted file mode 100644 index 5e9cc652..00000000 Binary files a/src/main/resources/sendctrlc.exe and /dev/null differ diff --git a/src/main/resources/sendctrlc.x64.exe b/src/main/resources/sendctrlc.x64.exe deleted file mode 100644 index 91a4b7ff..00000000 Binary files a/src/main/resources/sendctrlc.x64.exe and /dev/null differ diff --git a/src/main/resources/winp.dll b/src/main/resources/winp.dll deleted file mode 100644 index 967e1633..00000000 Binary files a/src/main/resources/winp.dll and /dev/null differ diff --git a/src/main/resources/winp.x64.dll b/src/main/resources/winp.x64.dll deleted file mode 100755 index c3e63391..00000000 Binary files a/src/main/resources/winp.x64.dll and /dev/null differ diff --git a/src/test/java/org/jvnet/winp/util/NativeWinpTest.java b/src/test/java/org/jvnet/winp/util/NativeWinpTest.java index 49b35684..00a89083 100644 --- a/src/test/java/org/jvnet/winp/util/NativeWinpTest.java +++ b/src/test/java/org/jvnet/winp/util/NativeWinpTest.java @@ -34,9 +34,13 @@ public class NativeWinpTest { @BeforeClass - public static void enableDebug() { + public static void enableDebug() throws Exception { TestHelper.assumeIsWindows(); - WinProcess.enableDebugPrivilege(); + try { + WinProcess.enableDebugPrivilege(); + } catch(UnsatisfiedLinkError e) { + throw new Exception("Could not enable debug privilege: " + e.getMessage()); + } } @Before