diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 71a1f32da1..1dee8fbd1a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,7 +10,8 @@ on: branches: '**' paths-ignore: - 'docs/**' - + workflow_dispatch: + concurrency: group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' cancel-in-progress: true diff --git a/.github/workflows/generateclasses.yaml b/.github/workflows/generateclasses.yaml index 2bc20d374d..f9f81bee17 100644 --- a/.github/workflows/generateclasses.yaml +++ b/.github/workflows/generateclasses.yaml @@ -58,9 +58,7 @@ jobs: run: Remove-Item .\src\net\JNet\Generated\* -Recurse -Force -Exclude README.md - name: Clear Java generated files - run: | - Remove-Item .\src\jvm\jnetcore\src\main\java\org\mases\jnet\generated\* -Recurse -Force -Exclude README.md - Remove-Item .\src\jvm\jnet\src\main\java\org\mases\jnet\generated\* -Recurse -Force -Exclude README.md + run: Remove-Item .\src\jvm\jnet\src\main\java\org\mases\jnet\generated\* -Recurse -Force -Exclude README.md - run: dotnet build --no-incremental --configuration Release src\net\JNetReflector\JNetReflector.csproj @@ -72,7 +70,15 @@ jobs: env: JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ONLINE }} - - name: Try compilation + - name: Try Java compilation + continue-on-error: true + run: mvn "-Djcobridgepath=../../../binReflector/net8.0/JCOBridge.jar" --file ./src/jvm/jnet/pom.xml --no-transfer-progress package + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + + - name: Try C# compilation continue-on-error: true run: dotnet build --no-incremental --configuration Release /p:Platform="Any CPU" /p:NoWarn="0108%3B1030%3B0618" src\net\JNet.sln diff --git a/src/configuration.json b/src/configuration.json index 7daf55a51e..97ee0bf81a 100644 --- a/src/configuration.json +++ b/src/configuration.json @@ -1,4 +1,5 @@ { + "CopyrightFile": "copyright.txt", "RelativeDestinationCSharpClassPath": "net\\JNet\\Generated", "RelativeDestinationJavaListenerPath": "jvm\\jnet\\src\\main\\java", "JavaListenerBasePackage": "org.mases.jnet.generated", diff --git a/src/copyright.txt b/src/copyright.txt new file mode 100644 index 0000000000..726955e2eb --- /dev/null +++ b/src/copyright.txt @@ -0,0 +1,17 @@ +/* +* Copyright 2024 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ \ No newline at end of file diff --git a/src/documentation/articles/usageReflector.md b/src/documentation/articles/usageReflector.md index 29e5a4dcc5..18db01db44 100644 --- a/src/documentation/articles/usageReflector.md +++ b/src/documentation/articles/usageReflector.md @@ -26,6 +26,7 @@ jnetreflector -OriginRootPath C:\\myJars -OriginJavadocUrl \"https://thehost/jav _jnr_ accepts the following command-line switch: * **ConfigurationFile**: The path where is stored a JSON file containing the tool configuration properties; the JSON items shall be written using the same command-line property names +* **CopyrightFile**: The path where the tool will locate copyright info * **JavaPLocationPath**: The path where the tool will locate javap, default is to use system available * **OriginRootPath**: The origin path where Jars to be analyzed, and dependencies, are stored * **OriginJavadocUrl**: The base URL of the Javadoc to be associated to the classes diff --git a/src/net/JNetReflector/InternalConst.cs b/src/net/JNetReflector/InternalConst.cs index c3e5164ff8..7ffb23060c 100644 --- a/src/net/JNetReflector/InternalConst.cs +++ b/src/net/JNetReflector/InternalConst.cs @@ -28,6 +28,7 @@ class CLIParam : MASES.JNet.CLIParam { // ReflectorArgs public const string ConfigurationFile = "ConfigurationFile"; + public const string CopyrightFile = "CopyrightFile"; public const string JavaPLocationPath = "JavaPLocationPath"; public const string OriginRootPath = "OriginRootPath"; public const string OriginJavadocUrl = "OriginJavadocUrl"; diff --git a/src/net/JNetReflector/InternalMethods.cs b/src/net/JNetReflector/InternalMethods.cs index d0d1b801f6..7f83f3f75a 100644 --- a/src/net/JNetReflector/InternalMethods.cs +++ b/src/net/JNetReflector/InternalMethods.cs @@ -330,7 +330,8 @@ static void AnalyzeSubItems(string package, IDictionary classDef { var singleClassFileTemplate = Template.GetTemplate(Template.SingleClassFileTemplate); - var fileContent = singleClassFileTemplate.Replace(AllPackageClasses.VERSION, SpecialNames.VersionPlaceHolder()) + var fileContent = singleClassFileTemplate.Replace(AllPackageClasses.COPYRIGHT, JNetReflectorCore.CopyrightFileContent) + .Replace(AllPackageClasses.VERSION, SpecialNames.VersionPlaceHolder()) .Replace(AllPackageClasses.JAR, jarOrModuleName) .Replace(AllPackageClasses.NAMESPACE, jClass.Namespace(JNetReflectorCore.UseCamel)) .Replace(AllPackageClasses.CLASSES, singleFileBlockStr); @@ -832,32 +835,42 @@ static void PrepareSingleClass(this Class jClass, IReadOnlyDictionary CommandLineArguments Help = "The path where is stored a JSON file containing the tool configuration properties", }, new ArgumentMetadata() + { + Name = CLIParam.CopyrightFile, + Type = ArgumentType.Double, + Help = "The path where the tool will locate copyright info", + }, + new ArgumentMetadata() { Name = CLIParam.JavaPLocationPath, Type = ArgumentType.Double, @@ -418,6 +427,10 @@ public JNetReflectorCore() static ConfigurationType _ConfigurationFromFile; + static string _CopyrightFile; + public static string CopyrightFile => _CopyrightFile ?? _ConfigurationFromFile.CopyrightFile; + public static string CopyrightFileContent = string.Empty; + static string _JavaPLocationPath; public static string JavaPLocationPath => _JavaPLocationPath ?? _ConfigurationFromFile.JavaPLocationPath; @@ -547,6 +560,8 @@ protected override string[] ProcessCommandLine() { var result = base.ProcessCommandLine(); + _CopyrightFile = ParsedArgs.Get(CLIParam.CopyrightFile); + _JavaPLocationPath = ParsedArgs.Get(CLIParam.JavaPLocationPath); if (ParsedArgs.Exist(CLIParam.ConfigurationFile)) @@ -745,6 +760,16 @@ protected override string[] ProcessCommandLine() _TraceLevel = ParsedArgs.Get(CLIParam.TraceLevel); _TraceTo = ParsedArgs.Get(CLIParam.TraceTo); + if (!string.IsNullOrWhiteSpace(CopyrightFile)) + { + if (Path.IsPathRooted(CopyrightFile)) CopyrightFileContent = File.ReadAllText(CopyrightFile); + else + { + var path = Path.Combine(DestinationRootPath, CopyrightFile); + CopyrightFileContent = File.ReadAllText(path); + } + } + return result; } diff --git a/src/net/JNetReflector/Templates/AllPackageClasses.template b/src/net/JNetReflector/Templates/AllPackageClasses.template index d8cb12b515..a8d66c6494 100644 --- a/src/net/JNetReflector/Templates/AllPackageClasses.template +++ b/src/net/JNetReflector/Templates/AllPackageClasses.template @@ -1,20 +1,4 @@ -/* -* Copyright 2024 MASES s.r.l. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* Refer to LICENSE for more information. -*/ +ALLPACKAGE_COPYRIGHT_PLACEHOLDER /* * This file is generated by ALLPACKAGE_VERSION_PLACEHOLDER diff --git a/src/net/JNetReflector/Templates/SingleClassFile.template b/src/net/JNetReflector/Templates/SingleClassFile.template index ee2b8d6bba..2f8810e521 100644 --- a/src/net/JNetReflector/Templates/SingleClassFile.template +++ b/src/net/JNetReflector/Templates/SingleClassFile.template @@ -1,20 +1,4 @@ -/* -* Copyright 2024 MASES s.r.l. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* Refer to LICENSE for more information. -*/ +ALLPACKAGE_COPYRIGHT_PLACEHOLDER /* * This file is generated by ALLPACKAGE_VERSION_PLACEHOLDER diff --git a/src/net/JNetReflector/Templates/SingleListenerJavaFile.template b/src/net/JNetReflector/Templates/SingleListenerJavaFile.template index 2c828af108..5a05bbc48a 100644 --- a/src/net/JNetReflector/Templates/SingleListenerJavaFile.template +++ b/src/net/JNetReflector/Templates/SingleListenerJavaFile.template @@ -1,20 +1,4 @@ -/* - * Copyright 2024 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ +ALLPACKAGE_COPYRIGHT_PLACEHOLDER /* * This file is generated by ALLPACKAGE_VERSION_PLACEHOLDER @@ -22,9 +6,51 @@ package ALLPACKAGE_PACKAGE_PLACEHOLDER; -public final class ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER extends org.mases.jcobridge.JCListener implements ALLPACKAGE_CLASSES_STUB_JAVACLASS_PLACEHOLDER { - public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(String key) throws org.mases.jcobridge.JCNativeException { - super(key); +public final class ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER ALLPACKAGE_CLASSES_STUB_EXTEND_JAVACLASS_PLACEHOLDERimplements org.mases.jcobridge.IJCListenerALLPACKAGE_CLASSES_STUB_JAVACLASS_PLACEHOLDER { + final org.mases.jcobridge.JCListener _internalListener; + + public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(String key) throws org.mases.jcobridge.JCNativeExceptionALLPACKAGE_CLASSES_STUB_EXTEND_EXCEPTIONS_PLACEHOLDER { + _internalListener = new org.mases.jcobridge.JCListener(key); + } + + public synchronized void release() { + _internalListener.release(); + } + + public synchronized void raiseEvent(String eventName) { + _internalListener.raiseEvent(eventName); + } + + public synchronized void raiseEvent(String eventName, Object e) { + _internalListener.raiseEvent(eventName, e); + } + + public synchronized void raiseEvent(String eventName, Object e, Object... objects) { + _internalListener.raiseEvent(eventName, e, objects); + } + + public Object getEventData() { + return _internalListener.getEventData(); + } + + public boolean hasExtraData() { + return _internalListener.hasExtraData(); + } + + public int extraDataLength() { + return _internalListener.extraDataLength(); + } + + public Object[] extraData() { + return _internalListener.extraData(); + } + + public Object getReturnData() { + return _internalListener.getReturnData(); + } + + public void setReturnData(Object retData) { + _internalListener.setReturnData(retData); } // ALLPACKAGE_CLASSES_STUB_LISTENER_METHODS_PLACEHOLDER diff --git a/src/net/JNetReflector/Templates/Templates.cs b/src/net/JNetReflector/Templates/Templates.cs index 3461db9ec9..ab6fc5c446 100644 --- a/src/net/JNetReflector/Templates/Templates.cs +++ b/src/net/JNetReflector/Templates/Templates.cs @@ -103,6 +103,7 @@ public static string GetTemplate(string templateName) public class AllPackageClasses { + public const string COPYRIGHT = "ALLPACKAGE_COPYRIGHT_PLACEHOLDER"; public const string VERSION = "ALLPACKAGE_VERSION_PLACEHOLDER"; public const string JAR = "ALLPACKAGE_JAR_PLACEHOLDER"; public const string NAMESPACE = "ALLPACKAGE_NAMESPACE_PLACEHOLDER"; @@ -130,6 +131,8 @@ public class ClassStub public const string BASECLASS = "ALLPACKAGE_CLASSES_STUB_BASECLASS_PLACEHOLDER"; public const string BASEINTERFACE = "ALLPACKAGE_CLASSES_STUB_BASEINTERFACE_PLACEHOLDER"; public const string WHERECLAUSES = "ALLPACKAGE_CLASSES_STUB_WHERECLAUSES_PLACEHOLDER"; + public const string EXTEND_JAVACLASS = "ALLPACKAGE_CLASSES_STUB_EXTEND_JAVACLASS_PLACEHOLDER"; + public const string EXTEND_EXCEPTIONS = "ALLPACKAGE_CLASSES_STUB_EXTEND_EXCEPTIONS_PLACEHOLDER"; public const string JAVACLASS = "ALLPACKAGE_CLASSES_STUB_JAVACLASS_PLACEHOLDER"; public const string JAVACLASS_DIRECT = "ALLPACKAGE_CLASSES_STUB_JAVACLASS_DIRECT_PLACEHOLDER"; public const string CONSTRUCTORS = "// ALLPACKAGE_CLASSES_STUB_CONSTRUCTORS_PLACEHOLDER";