diff --git a/DEVELOPER.md b/DEVELOPER.md
index 5025a74..a04b4f4 100644
--- a/DEVELOPER.md
+++ b/DEVELOPER.md
@@ -1,30 +1,24 @@
WinP Developer info
---
-## Prerequisites
-
-In order to build the project, you need MSBuild 15.0, Microsoft Visual Studio 2019, and BuildTools v142.
-Toolchains for x86 and x64 targets should also be installed.
-Furthermore, Windows SDK 10.0.16299 should be installed.
-The `JAVA_HOME` environment variable should point to your Java installation (>= 11).
-
## Building
-To build and test the project, run `mvn clean verify`:
+In order to build and test the project, use the `build.cmd` script available in the repository.
+In order to build the project, you need MSbuild 15.0 and Microsoft Visual Studio 2017 with Windows XP support and BuildTools v140.
-* `mvn clean verify` - Build and test the release version of the JAR file.
+* `build.cmd cleanbuild` - Build and test the release version of the JAR file.
Code will not be signed automatically.
-* `mvn clean verify -Dnative.configuration=Debug` - Build and test the Debug configuration of the library.
+* `build.cmd cleanbuild Debug` - Build and test the Debug configuration of the library.
This version simplifies debugging of the native part of the library (see below).
## Testing
* Right now all tests are implemented in Java part of the library (JUnit Framework).
There is no fully native tests.
-* All tests are automatically invoked by `mvn clean verify`.
-* Tests run from Maven, and the selected 32/64-bit mode depends on the Java version,
+* All tests are being automatically invoked by `build.cmd`
+* Tests run from Maven, and the selected 32/64-bit mode depends on the Java version,
which can be passed to maven using the `JAVA_HOME` environment variable.
-* Generally you need to run `mvn clean verify` and `mvn clean verify -Dnative.configuration=Debug` on 3 configurations:
+* Generally you need to run `build.cmd cleanbuild Debug` and `build.cmd cleanbuild Release` on 3 configurations
* 32-bit Windows, 32-bit Java
* 64-bit Windows, 64-bit Java
* 64-bit Windows, 32-bit Java (WoW64 mode)
@@ -34,16 +28,17 @@ Ideally, tests should be executed on all target platforms.
## Continuous Integration
-The project has a [CI pipeline](https://ci.jenkins.io/job/jenkinsci-libraries/job/winp)
-that automates testing of the release configuration,
+Project has a continuous integration flow being hosted by AppVeyor ([project page](https://ci.appveyor.com/project/oleg-nenashev/winp)).
+This CI instance automates testing of Debug and Release configurations,
but it does not provide full coverage of possible system configurations.
+See [the appveyor.yml file](./appveyor.yml) for more details.
## Debugging
### Debugging Java part
Java part of the library can be debugged independently or within a project using standard tools available in the Java Development Kit.
-
+
### Debugging Native part
In order to debug native parts of the library attach your debugger (e.g. from Microsoft Visual Studio UI) to the `java.exe` process.
diff --git a/Jenkinsfile b/Jenkinsfile
index a06d9ea..163b3ff 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: false, configurations: [
- [platform: 'windows', jdk: 21],
- [platform: 'windows', jdk: 17],
+buildPlugin(useContainerAgent: true, configurations: [
+ [platform: 'linux', jdk: 21],
+ [platform: 'linux', jdk: 17],
])
diff --git a/README.md b/README.md
index 548fce4..3784a64 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
# Windows process management library (WinP)
-[![Build status](https://ci.jenkins.io/job/jenkinsci-libraries/job/winp/job/master/badge/icon)](https://ci.jenkins.io/job/jenkinsci-libraries/job/winp/job/master/)
+[![Build status](https://ci.appveyor.com/api/projects/status/0w6ivhpkt20d88md?svg=true)](https://ci.appveyor.com/project/oleg-nenashev/winp)
-This project develops a library that lets you control Windows processes better, beyond what's available in JDK.
+This project develops a library that lets you control Windows processes better, beyond what's available in JDK.
Features summary:
@@ -28,7 +28,7 @@ Starting with 1.29, this library is published at:
## Java support
Starting with 1.29, this library requires Java 11 or newer.
-
+
WinP Library includes native libraries for all supported platforms, hence it can run on both 32bit and 64bit Java versions without any additional configuration.
## Platform support
@@ -37,8 +37,8 @@ The library supports _x86_ and _amd64_ architectures.
ARM architecture is not supported.
Please raise an issue to the library if you need ARM support && ready to provide proper test environment.
-:exclamation: It is **not recommended** to use WinP with _32bit_ Java on a _64bit_ operating system.
-In such case the library will be running in the WoW64 mode;
+:exclamation: It is **not recommended** to use WinP with _32bit_ Java on a _64bit_ operating system.
+In such case the library will be running in the WoW64 mode;
and it will be unable to properly work with 64bit processes in the system.
E.g. any process information query call (e.g. Environment variables retrieval) may fail if you run it against 64bit process.
@@ -46,11 +46,13 @@ E.g. any process information query call (e.g. Environment variables retrieval) m
The current version of WinP is known to work correctly on the following Windows versions:
-* Windows 10 and above
-* Windows Server 2019 and above
+* Windows XP SP2 and above
+* Windows Server 2003 and above
Other Windows product lines are not being actively tested though WinP may work there.
+:exclamation: Minimal required Windows version is a subject to change in next releases of WinP.
+
## License
[MIT License][license]
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..7898e28
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,55 @@
+# Do not build tags and feature branches
+skip_tags: true
+skip_branch_with_pr: true
+
+version: 1.25.0.{build}-SNAPSHOT
+
+# MVS Project configuration
+image: Visual Studio 2017
+platform: Any CPU
+configuration: Release
+
+# Environment
+environment:
+ matrix:
+ - JAVA_HOME: C:\Program Files\Java\jdk1.8.0
+
+# Environment installation
+install:
+ - cmd: choco install maven -y -f
+ - cmd: refreshenv
+
+# Build and test
+build_script:
+ - .\build.cmd cleanbuild Release %APPVEYOR_BUILD_VERSION%
+ - ps: Get-ChildItem target\winp-$env:APPVEYOR_BUILD_VERSION.jar | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
+ - .\build.cmd cleanbuild Debug %APPVEYOR_BUILD_VERSION%-Debug
+ - ps: Get-ChildItem target\winp-$env:APPVEYOR_BUILD_VERSION-Debug.jar | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
+
+on_finish:
+# TODO: enable once there are tests, implement aggregator somehow
+# - ps: (new-object net.webclient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\tests.xml))
+
+artifacts:
+#x64
+ - path: 'native/x64/Release/winp.dll'
+ name: winp.x64.dll
+ - path: 'native/x64/Release/winp.pdb'
+ name: winp.x64.pdb
+ - path: 'native/x64/Debug/winp.dll'
+ name: winp.x64-debug.dll
+ - path: 'native/x64/Debug/winp.pdb'
+ name: winp.x64-debug.pdb
+#x86
+ - path: 'native/Release/winp.dll'
+ name: winp.x86.dll
+ - path: 'native/Release/winp.pdb'
+ name: winp.x86.pdb
+ - path: 'native/Debug/winp.dll'
+ name: winp.x86-debug.dll
+ - path: 'native/Debug/winp.pdb'
+ name: winp.x86-debug.pdb
+#JARs are pushed above
+#FindBugs
+ - path: 'target/findbugs.xml'
+ name: findbugs.xml
diff --git a/build.cmd b/build.cmd
index d490cbb..47881dc 100644
--- a/build.cmd
+++ b/build.cmd
@@ -1,16 +1,7 @@
+@echo off
setlocal
-
-set VS2019=C:\Program Files (x86)\Microsoft Visual Studio\2019
-set VS=
-
-if exist "%VS2019%\Community\" set VS=%VS2019%\Community
-if exist "%VS2019%\Enterprise\" set VS=%VS2019%\Enterprise
-if "%VS%" == "" (
- echo Can't find VS2019 install
- exit /b 1
-)
-
-call "%VS%/VC/Auxiliary/Build/vcvarsall.bat" amd64 || exit /b 1
+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
set BUIDROOT=%cd%
:getopts
@@ -20,28 +11,39 @@ if "%2"=="" (
set configuration=%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
+ for /f "delims=" %%x in (version.txt) do set version=%%x
+) else (
+ echo Setting MVN project version to the externally defined %3%
+ set version=%3%
+)
+echo Target version is %version%
+
if "%1"=="" (goto :default) else (goto :%1)
goto :exit
:default
-goto :build
+goto :cleanbuild
-:clean
+:cleanbuild
echo ### Cleaning the %configuration% build directory
cd %BUIDROOT%\native
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"
if %errorlevel% neq 0 exit /b %errorlevel%
-msbuild sendctrlc\sendctrlc.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="Win32"
+msbuild sendctrlc\sendctrlc.vcxproj /t:Clean /p:Configuration=Release /verbosity:minimal /nologo /p:Platform="Win32"
if %errorlevel% neq 0 exit /b %errorlevel%
-msbuild sendctrlc\sendctrlc.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="x64"
+msbuild sendctrlc\sendctrlc.vcxproj /t:Clean /p:Configuration=Release /verbosity:minimal /nologo /p:Platform="x64"
if %errorlevel% neq 0 exit /b %errorlevel%
-msbuild ..\native_test\testapp\testapp.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="Win32"
+msbuild ..\native_test\testapp\testapp.vcxproj /t:Clean /p:Configuration=Release /verbosity:minimal /nologo /p:Platform="Win32"
if %errorlevel% neq 0 exit /b %errorlevel%
-msbuild ..\native_test\testapp\testapp.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="x64"
+msbuild ..\native_test\testapp\testapp.vcxproj /t:Clean /p:Configuration=Release /verbosity:minimal /nologo /p:Platform="x64"
if %errorlevel% neq 0 exit /b %errorlevel%
-goto :exit
+goto :build
:build
echo ### Building the %configuration% configuration
@@ -57,21 +59,27 @@ msbuild sendctrlc\sendctrlc.vcxproj /p:Configuration=%configuration% /nologo /p:
if %errorlevel% neq 0 exit /b %errorlevel%
echo ### Building test applications
-msbuild ..\native_test\testapp\testapp.vcxproj /verbosity:minimal /p:Configuration=%configuration% /nologo /p:Platform="Win32"
+msbuild ..\native_test\testapp\testapp.vcxproj /verbosity:minimal /p:Configuration=Release /nologo /p:Platform="Win32"
if %errorlevel% neq 0 exit /b %errorlevel%
-msbuild ..\native_test\testapp\testapp.vcxproj /verbosity:minimal /p:Configuration=%configuration% /nologo /p:Platform="x64"
+msbuild ..\native_test\testapp\testapp.vcxproj /verbosity:minimal /p:Configuration=Release /nologo /p:Platform="x64"
if %errorlevel% neq 0 exit /b %errorlevel%
-echo ### Copying WinP resource files for the %configuration% build
+echo ### Updating WinP resource files for the %configuration% build
cd %BUIDROOT%
-if not exist target\classes mkdir target\classes
-COPY native\Win32\%configuration%\winp.dll target\classes\
+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
if %errorlevel% neq 0 exit /b %errorlevel%
-COPY native\x64\%configuration%\winp.x64.dll target\classes\
+COPY native\sendctrlc\Win32\%configuration%\sendctrlc.exe src\main\resources\sendctrlc.exe
if %errorlevel% neq 0 exit /b %errorlevel%
-COPY native\sendctrlc\Win32\%configuration%\sendctrlc.exe target\classes\
+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%
-COPY native\sendctrlc\x64\%configuration%\sendctrlc.x64.exe target\classes\
+call mvn --batch-mode clean package verify
if %errorlevel% neq 0 exit /b %errorlevel%
goto :exit
diff --git a/install.sh b/install.sh
new file mode 100755
index 0000000..62e5691
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,3 @@
+#!/bin/bash -ex
+cp native/Release/winp.dll src/main/resources/winp.dll
+cp native/x64/Release/winp.dll src/main/resources/winp.x64.dll
diff --git a/native/sendctrlc/sendctrlc.vcxproj b/native/sendctrlc/sendctrlc.vcxproj
index 133e97b..7c84891 100644
--- a/native/sendctrlc/sendctrlc.vcxproj
+++ b/native/sendctrlc/sendctrlc.vcxproj
@@ -28,26 +28,26 @@
Application
true
- v142
+ v140
Unicode
Application
true
- v142
+ v140
Unicode
Application
false
- v142
+ v140
true
Unicode
Application
false
- v142
+ v140
true
Unicode
@@ -69,21 +69,19 @@
true
- $(SolutionDir)$(Platform)\$(Configuration)\
+ $(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\
true
- $(SolutionDir)$(Platform)\$(Configuration)\
- sendctrlc.x64
+ $(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\
false
- $(SolutionDir)$(Platform)\$(Configuration)\
+ $(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\
false
- $(SolutionDir)$(Platform)\$(Configuration)\
- sendctrlc.x64
+ $(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\
diff --git a/native/signing.txt b/native/signing.txt
old mode 100644
new mode 100755
index 9abe1a1..2bc4728
--- a/native/signing.txt
+++ b/native/signing.txt
@@ -2,6 +2,6 @@ Reminder to myself.
To digitally sign the DLLs,
-signtool sign /f PATH-TO-PFX /p PASSWORD /t http://timestamp.comodoca.com/authenticode native\Win32\Release\winp.dll
+signtool sign /f PATH-TO-PFX /p PASSWORD /t http://timestamp.comodoca.com/authenticode Release\winp.dll
-and ditto for native\x64\Release\winp.x64.dll
\ No newline at end of file
+and ditto for x64\Release\winp.dll
\ No newline at end of file
diff --git a/native/winp.vcxproj b/native/winp.vcxproj
index 50f46bf..8227e80 100644
--- a/native/winp.vcxproj
+++ b/native/winp.vcxproj
@@ -26,24 +26,24 @@
DynamicLibrary
- v142
+ v140
Unicode
true
DynamicLibrary
- v142
+ v140
Unicode
DynamicLibrary
- v142
+ v140
Unicode
true
DynamicLibrary
- v142
+ v140
Unicode
@@ -66,7 +66,7 @@
<_ProjectFileVersion>12.0.30501.0
- $(SolutionDir)$(Platform)\$(Configuration)\
+ $(SolutionDir)$(Configuration)\
$(Configuration)\
true
$(VC_IncludePath);$(WindowsSDK_IncludePath);$(JAVA_HOME)\include\;$(JAVA_HOME)\include\win32;
@@ -74,12 +74,11 @@
$(SolutionDir)$(Platform)\$(Configuration)\
$(Platform)\$(Configuration)\
- winp.x64
true
$(VC_IncludePath);$(WindowsSDK_IncludePath);$(JAVA_HOME)\include\;$(JAVA_HOME)\include\win32;
- $(SolutionDir)$(Platform)\$(Configuration)\
+ $(SolutionDir)$(Configuration)\
$(Configuration)\
false
$(VC_IncludePath);$(WindowsSDK_IncludePath);$(JAVA_HOME)\include\;$(JAVA_HOME)\include\win32;
@@ -87,7 +86,6 @@
$(SolutionDir)$(Platform)\$(Configuration)\
$(Platform)\$(Configuration)\
- winp.x64
false
$(VC_IncludePath);$(WindowsSDK_IncludePath);$(JAVA_HOME)\include\;$(JAVA_HOME)\include\win32;
diff --git a/native_test/testapp/testapp.vcxproj b/native_test/testapp/testapp.vcxproj
index e67488e..ecd78a7 100644
--- a/native_test/testapp/testapp.vcxproj
+++ b/native_test/testapp/testapp.vcxproj
@@ -28,26 +28,26 @@
Application
true
- v142
+ v140
Unicode
Application
true
- v142
+ v140
Unicode
Application
false
- v142
+ v140
true
Unicode
Application
false
- v142
+ v140
true
Unicode
@@ -69,21 +69,19 @@
true
- $(SolutionDir)$(Platform)\$(Configuration)\
+ $(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\
true
- $(SolutionDir)$(Platform)\$(Configuration)\
- testapp.x64
+ $(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\
false
- $(SolutionDir)$(Platform)\$(Configuration)\
+ $(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\
false
- $(SolutionDir)$(Platform)\$(Configuration)\
- testapp.x64
+ $(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\
diff --git a/pom.xml b/pom.xml
index 3f9c91b..b276488 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,6 +1,5 @@
- 4.0.0
org.jenkins-ci
jenkins
@@ -8,6 +7,7 @@
+ 4.0.0
org.jvnet.winp
winp
${revision}${changelist}
@@ -15,21 +15,6 @@
Kill process tree in Windows
https://github.com/jenkinsci/${project.artifactId}
-
-
- MIT License
- https://opensource.org/licenses/MIT
- repo
-
-
-
-
- scm:git:https://github.com/${gitHubRepo}.git
- scm:git:git@github.com:${gitHubRepo}.git
- ${scmTag}
- https://github.com/${gitHubRepo}
-
-
1.31
-SNAPSHOT
@@ -37,9 +22,36 @@
High
1.37
- Release
+
+ scm:git:https://github.com/${gitHubRepo}.git
+ scm:git:git@github.com:${gitHubRepo}.git
+ https://github.com/${gitHubRepo}
+ ${scmTag}
+
+
+
+
+
+ maven-jar-plugin
+
+
+
+ org.jvnet.winp.Main
+
+
+
+
+
+ maven-surefire-plugin
+
+ -XX:+CreateCoredumpOnCrash
+
+
+
+
+
com.github.spotbugs
@@ -81,6 +93,14 @@
+
+
+ MIT License
+ https://opensource.org/licenses/MIT
+ repo
+
+
+
repo.jenkins-ci.org
@@ -94,63 +114,4 @@
https://repo.jenkins-ci.org/public/
-
-
-
-
- maven-jar-plugin
-
-
-
- org.jvnet.winp.Main
-
-
-
-
-
- maven-surefire-plugin
-
- -XX:+CreateCoredumpOnCrash
-
- ${native.configuration}
-
-
-
-
-
-
-
-
- build-native
-
-
- Windows
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
-
-
- build-native
-
- exec
-
- process-resources
-
- build.cmd
-
- build
- ${native.configuration}
-
-
-
-
-
-
-
-
-
diff --git a/src/main/resources/sendctrlc.exe b/src/main/resources/sendctrlc.exe
new file mode 100644
index 0000000..5e9cc65
Binary files /dev/null and b/src/main/resources/sendctrlc.exe differ
diff --git a/src/main/resources/sendctrlc.x64.exe b/src/main/resources/sendctrlc.x64.exe
new file mode 100644
index 0000000..91a4b7f
Binary files /dev/null and b/src/main/resources/sendctrlc.x64.exe differ
diff --git a/src/main/resources/winp.dll b/src/main/resources/winp.dll
new file mode 100644
index 0000000..967e163
Binary files /dev/null and b/src/main/resources/winp.dll differ
diff --git a/src/main/resources/winp.x64.dll b/src/main/resources/winp.x64.dll
new file mode 100755
index 0000000..c3e6339
Binary files /dev/null and b/src/main/resources/winp.x64.dll differ
diff --git a/src/test/java/org/jvnet/winp/util/ProcessSpawningTest.java b/src/test/java/org/jvnet/winp/util/ProcessSpawningTest.java
index 227b8d9..e9a8ca2 100644
--- a/src/test/java/org/jvnet/winp/util/ProcessSpawningTest.java
+++ b/src/test/java/org/jvnet/winp/util/ProcessSpawningTest.java
@@ -84,14 +84,13 @@ public Process spawnProcess(boolean delayAfterCreate, boolean spotcheckProcess,
}
protected static File getTestAppExecutable(ExecutablePlatform executablePlatform) {
- final String configuration = System.getProperty("native.configuration", "Release");
final String executable;
switch (executablePlatform) {
case X64:
- executable = "native_test/testapp/x64/" + configuration + "/testapp.x64.exe";
+ executable = "native_test/testapp/x64/Release/testapp.exe";
break;
case X86:
- executable = "native_test/testapp/Win32/" + configuration + "/testapp.exe";
+ executable = "native_test/testapp/Win32/Release/testapp.exe";
break;
default:
throw new IllegalArgumentException("Unsupported platform: " + executablePlatform);