Skip to content
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

Revert "Use official Jenkins CI to build and test winp" #128

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 11 additions & 16 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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],
])

16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:

Expand All @@ -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
Expand All @@ -37,20 +37,22 @@ 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.

## Supported Windows versions

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]
Expand Down
55 changes: 55 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -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
62 changes: 35 additions & 27 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -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
18 changes: 8 additions & 10 deletions native/sendctrlc/sendctrlc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand All @@ -69,21 +69,19 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<TargetName>sendctrlc.x64</TargetName>
<OutDir>$(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<TargetName>sendctrlc.x64</TargetName>
<OutDir>$(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down
4 changes: 2 additions & 2 deletions native/signing.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
and ditto for x64\Release\winp.dll
Loading
Loading