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

Added .NET Core Support (OpenNLP.NET 1.9.1.2-preview0001) #14

Closed
Closed
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
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"isRoot": true,
"tools": {
"paket": {
"version": "6.2.1",
"version": "7.1.5",
"commands": [
"paket"
]
},
"fake-cli": {
"version": "5.20.4",
"version": "5.22.0",
"commands": [
"fake"
]
Expand Down
62 changes: 53 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,68 @@ on:
- master

jobs:
build:

build:
name: Build OpenNLP.NET (Windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: Setup .NET 3.1 SDK
uses: actions/setup-dotnet@v2
with:
dotnet-version: 3.1.x
- name: Setup .NET 6.0 SDK
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Install local tools
run: dotnet tool restore
- name: Paket Restore
run: dotnet paket restore
- name: Build Tests and Binaries
run: dotnet fake run build.fsx -t "BuildTests"
- name: Upload NuGet Packages
uses: actions/upload-artifact@v3
with:
name: nuget
path: bin/*.nupkg
- name: Upload Tests
uses: actions/upload-artifact@v3
with:
name: tests
path: tests

test:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macOS-latest]
dotnet: [6.0.100]
os: [windows-latest, ubuntu-latest, macOS-latest]
runs-on: ${{ matrix.os }}

needs:
- build
steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
- name: Setup .NET 3.1 SDK
uses: actions/setup-dotnet@v2
with:
dotnet-version: 3.1.x
- name: Setup .NET 6.0 SDK
uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ matrix.dotnet }}
dotnet-version: 6.0.x
- name: Download OpenNLP.NET Tests
uses: actions/download-artifact@v3
with:
name: tests
path: tests
- name: Install local tools
run: dotnet tool restore
- name: Paket Restore
run: dotnet paket restore
- name: Build and Test
run: dotnet fake run build.fsx
- name: Run Tests
run: dotnet fake run build.fsx -t "RunTests" --single-target
- name: Upload Test Results
uses: actions/upload-artifact@v3
with:
name: TestResults-${{ matrix.os }}
path: TestResults
14 changes: 6 additions & 8 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#### 1.9.4 - Nov 22, 2021
* New version of OpenNLP 1.9.4
* Build with .NET 6.0

#### 1.9.3 - April 11, 2021
* New version of OpenNLP 1.9.3
* 32 dlls compiled instead of 2
* New jar dependency detection using jdep
#### 1.9.1.2-preview0001 - June 2, 2022
* Allow build with any .NET SDK 6.x
* Latest IKVM preview 8.2.0-prerelease0392
* Support for .NET Core 3.1 and higher
* Dropped .NET Framework support prior to 4.6.1
* Tests for .NET Core 3.1

#### 1.9.1.1 - April 5, 2021
* Sign assemblies
Expand Down
96 changes: 71 additions & 25 deletions build.fsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#r @"paket:
source https://nuget.org/api/v2
framework netstandard2.0
nuget FSharp.Core 5.0.0
source https://api.nuget.org/v3/index.json
framework: net6.0
nuget FSharp.Core
nuget Mono.Cecil
nuget System.IO.Compression.ZipFile
nuget Graphviz.DotLanguage
Expand All @@ -18,7 +18,6 @@ nuget Fake.Api.GitHub //"

#if !FAKE
#load "./.fake/build.fsx/intellisense.fsx"
#r "netstandard" // Temp fix for https://github.com/fsharp/FAKE/issues/1985
#endif

open System
Expand Down Expand Up @@ -79,8 +78,17 @@ let restoreFolderFromFile folder zipFile =
if not <| Directory.Exists folder then
zipFile |> unZipTo folder

// Location of IKVM Compiler & ildasm / ilasm
let ikvmcExe = root </> "paket-files/sergeytihon.files.wordpress.com/ikvm-8.1.5717.0/bin/ikvmc.exe"
// Location of IKVM Compiler
let ikvmVersion = @"8.2.0-prerelease.392"
let ikvmRootFolder = root </> "paket-files" </> "github.com"

let ikvmcFolder_NetFramework = ikvmRootFolder </> "ikvm-" + ikvmVersion + "-tools-net461-win7-x64"
let ikvmcFolder_NetCore_Windows = ikvmRootFolder </> "ikvm-" + ikvmVersion + "-tools-net461-win7-x64"
let ikvmcFolder_NetCore_Linux = ikvmRootFolder </> "ikvm-" + ikvmVersion + "-tools-net461-linux-x64"

let ikvmcExe_NetFramework = ikvmcFolder_NetFramework </> "ikvmc.exe"
let ikvmcExe_NetCore_Windows = ikvmcFolder_NetCore_Windows </> "ikvmc.exe"
let ikvmcExe_NetCore_Linux = ikvmcFolder_NetCore_Linux </> "ikvmc.exe"

type IKVMcTask(jar:string, version:string) =
member __.JarFile = jar
Expand All @@ -96,11 +104,33 @@ type IKVMcTask(jar:string, version:string) =

let timeOut = TimeSpan.FromSeconds(120.0)

let IKVMCompile workingDirectory keyFile tasks =
let IKVMCompile framework workingDirectory keyFile tasks =
let origKeyFile =
if (File.Exists keyFile) then
Path.GetFileName(keyFile)
else keyFile
let (|StartsWith|_|) needle (haystack : string) = if haystack.StartsWith(string needle) then Some() else None
let command =
(match framework with
| StartsWith "net4" () ->
(if Environment.isWindows
then ikvmcExe_NetFramework
else "mono")
| _ ->
(if Environment.isWindows
then ikvmcExe_NetCore_Windows
else ikvmcExe_NetCore_Linux))
let commandArgs args =
(match framework with
| StartsWith "net4" () ->
(if not <| Environment.isWindows
then ikvmcExe_NetFramework + " " + args
else args)
| _ -> args)

let ikvmc args =
(if Environment.isWindows
then CreateProcess.fromRawCommandLine ikvmcExe args
else CreateProcess.fromRawCommandLine "mono" (ikvmcExe + " " + args))
let cArgs = commandArgs args
CreateProcess.fromRawCommandLine command cArgs
|> CreateProcess.withWorkingDirectory (DirectoryInfo(workingDirectory).FullName)
|> CreateProcess.withTimeout timeOut
|> CreateProcess.ensureExitCode
Expand Down Expand Up @@ -128,6 +158,8 @@ let IKVMCompile workingDirectory keyFile tasks =
if not <| String.IsNullOrEmpty(task.Version)
then task.Version |> bprintf sb " -version:%s"
bprintf sb " %s -out:%s" task.JarFile task.DllFile
bprintf sb " -keyfile:%s" origKeyFile
//bprintf sb " -debug" // Not supported on Mono
sb.ToString()

if cache.Contains task.JarFile
Expand Down Expand Up @@ -229,13 +261,13 @@ let keyFile = @"./nuget/OpenNLP.snk"
// Clean build results

Target.create "Clean" (fun _ ->
Shell.cleanDirs ["bin"; "temp"]
Shell.cleanDirs ["bin"; "temp"; "TestResults"]
)

// --------------------------------------------------------------------------------------
// Compile Stanford.NLP.CoreNLP and build NuGet package

let openNLPDir = root </> "paket-files/dlcdn.apache.org/apache-opennlp-1.9.4/lib"
let openNLPDir = root </> "paket-files/archive.apache.org/apache-opennlp-1.9.1/lib"

Target.create "Compile" (fun _ ->
// Get *.jar file for compilation
Expand All @@ -246,15 +278,23 @@ Target.create "Compile" (fun _ ->
if (jars.IsEmpty)
then failwith "Found 0 *.jar files"

let ikvmDir = @"bin/lib"
Shell.mkdir ikvmDir

let dotFile = "nuget/OpenNLP.dot"
if not <| File.Exists dotFile then
buildJDepsGraph dotFile openNLPDir jars

let framework = @"net461"
let ikvmDir = @"bin/lib/" + framework
Shell.mkdir ikvmDir

createCompilationGraph dotFile openNLPDir jars
|> IKVMCompile ikvmDir keyFile
|> IKVMCompile framework ikvmDir keyFile

let framework = @"netcoreapp3.1"
let ikvmDir = @"bin/lib/" + framework
Shell.mkdir ikvmDir

createCompilationGraph dotFile openNLPDir jars
|> IKVMCompile framework ikvmDir keyFile
)

Target.create "NuGet" (fun _ ->
Expand All @@ -272,16 +312,22 @@ Target.create "BuildTests" (fun _ ->
)

Target.create "RunTests" (fun _ ->
let libs = !! "tests/**/bin/Release/net45/*.Tests.dll"
let args = String.Join(" ", libs)
let runner = "packages/NUnit.ConsoleRunner/tools/nunit3-console.exe"

(if Environment.isWindows
then CreateProcess.fromRawCommandLine runner args
else CreateProcess.fromRawCommandLine "mono" (runner + " " + args))
|> CreateProcess.ensureExitCode
|> Proc.run
|> ignore
let doubleQuote = '"'

Trace.trace $"Running tests for netcoreapp3.1"
let libs = !! "tests/**/bin/Release/netcoreapp3.1/*.Tests.dll"
for lib in libs do
let result = DotNet.exec id "test" $"{lib} -c Release --no-build --logger:{doubleQuote}console;verbosity=normal{doubleQuote} --logger:{doubleQuote}trx;LogFileName={doubleQuote}netcoreapp3.1-{Path.GetFileNameWithoutExtension(lib)}-TestResults.trx{doubleQuote}"
if not result.OK
then failwithf "Tests failed: %A" result.Errors

Trace.trace $"Running tests for net461"
let libs = !! "tests/**/bin/Release/net461/*.Tests.dll"
for lib in libs do
let result = DotNet.exec id "test" $"{lib} -c Release --no-build --logger:{doubleQuote}console;verbosity=normal{doubleQuote} --logger:{doubleQuote}trx;LogFileName={doubleQuote}net461-{Path.GetFileNameWithoutExtension(lib)}-TestResults.trx{doubleQuote}"
if not result.OK
then failwithf "Tests failed: %A" result.Errors
)

// --------------------------------------------------------------------------------------
Expand Down
Loading