diff --git a/IKVM.Maven.sln b/IKVM.Maven.sln index 690d005..9cd62d3 100644 --- a/IKVM.Maven.sln +++ b/IKVM.Maven.sln @@ -28,9 +28,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IKVM.Maven.Sdk.Tasks.Tests" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dist", "dist", "{2B1DC931-2EBF-4544-8076-3C7BF5870163}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dist-nuget", "src\dist-nuget\dist-nuget.csproj", "{9DC62B51-6F8F-4764-B29E-588AFE9EE643}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dist-nuget", "src\dist-nuget\dist-nuget.csproj", "{9DC62B51-6F8F-4764-B29E-588AFE9EE643}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dist-tests", "src\dist-tests\dist-tests.csproj", "{7CF45054-BD9C-4874-8A4B-3C2BE86FDB25}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dist-tests", "src\dist-tests\dist-tests.csproj", "{7CF45054-BD9C-4874-8A4B-3C2BE86FDB25}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IKVM.Maven.Sdk.Tasks.Java", "src\IKVM.Maven.Sdk.Tasks.Java\IKVM.Maven.Sdk.Tasks.Java.csproj", "{45334A6F-F78C-4D95-81F6-7D6E2B8C5798}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -62,6 +64,10 @@ Global {7CF45054-BD9C-4874-8A4B-3C2BE86FDB25}.Debug|Any CPU.Build.0 = Debug|Any CPU {7CF45054-BD9C-4874-8A4B-3C2BE86FDB25}.Release|Any CPU.ActiveCfg = Release|Any CPU {7CF45054-BD9C-4874-8A4B-3C2BE86FDB25}.Release|Any CPU.Build.0 = Release|Any CPU + {45334A6F-F78C-4D95-81F6-7D6E2B8C5798}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {45334A6F-F78C-4D95-81F6-7D6E2B8C5798}.Debug|Any CPU.Build.0 = Debug|Any CPU + {45334A6F-F78C-4D95-81F6-7D6E2B8C5798}.Release|Any CPU.ActiveCfg = Release|Any CPU + {45334A6F-F78C-4D95-81F6-7D6E2B8C5798}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/global.json b/global.json index 77c776f..423ec2b 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,9 @@ { - "sdk": { - "version": "7.0.100", - "rollForward": "latestFeature" - } + "sdk": { + "version": "7.0.100", + "rollForward": "latestFeature" + }, + "msbuild-sdks": { + "IKVM.NET.Sdk": "8.7.3" + } } diff --git a/src/IKVM.Maven.Sdk.Tasks.Java/AdapterLoggerFactory.java b/src/IKVM.Maven.Sdk.Tasks.Java/AdapterLoggerFactory.java new file mode 100644 index 0000000..be75219 --- /dev/null +++ b/src/IKVM.Maven.Sdk.Tasks.Java/AdapterLoggerFactory.java @@ -0,0 +1,20 @@ +package IKVM.Maven.Sdk.Tasks.Java; + +import org.slf4j.*; + +public class AdapterLoggerFactory implements ILoggerFactory { + + public static ILoggerFactory LoggerFactory; + + final ILoggerFactory factory; + + public AdapterLoggerFactory(ILoggerFactory factory) { + this.factory = factory; + } + + @Override + public final Logger getLogger(final String name) { + return factory.getLogger(name); + } + +} diff --git a/src/IKVM.Maven.Sdk.Tasks.Java/IKVM.Maven.Sdk.Tasks.Java.csproj b/src/IKVM.Maven.Sdk.Tasks.Java/IKVM.Maven.Sdk.Tasks.Java.csproj new file mode 100644 index 0000000..b4e04d8 --- /dev/null +++ b/src/IKVM.Maven.Sdk.Tasks.Java/IKVM.Maven.Sdk.Tasks.Java.csproj @@ -0,0 +1,23 @@ + + + net472;net6.0 + + + + + + + + + + + + + + + + + + + + diff --git a/src/IKVM.Maven.Sdk.Tasks/ikvm-maven-sdk-tasks.pom b/src/IKVM.Maven.Sdk.Tasks.Java/ikvm-maven-sdk-tasks-java.pom similarity index 97% rename from src/IKVM.Maven.Sdk.Tasks/ikvm-maven-sdk-tasks.pom rename to src/IKVM.Maven.Sdk.Tasks.Java/ikvm-maven-sdk-tasks-java.pom index 843251e..b663caf 100644 --- a/src/IKVM.Maven.Sdk.Tasks/ikvm-maven-sdk-tasks.pom +++ b/src/IKVM.Maven.Sdk.Tasks.Java/ikvm-maven-sdk-tasks-java.pom @@ -1,7 +1,7 @@  4.0.0 ikvm.maven - ikvm-maven-sdk-tasks + ikvm-maven-sdk-tasks-java 1 1.8 diff --git a/src/IKVM.Maven.Sdk.Tasks.Java/org/slf4j/impl/StaticLoggerBinder.java b/src/IKVM.Maven.Sdk.Tasks.Java/org/slf4j/impl/StaticLoggerBinder.java new file mode 100644 index 0000000..8281f27 --- /dev/null +++ b/src/IKVM.Maven.Sdk.Tasks.Java/org/slf4j/impl/StaticLoggerBinder.java @@ -0,0 +1,33 @@ +package org.slf4j.impl; + +import org.slf4j.*; +import org.slf4j.spi.*; + +import IKVM.Maven.Sdk.Tasks.Java.*; + +public final class StaticLoggerBinder implements LoggerFactoryBinder { + + public static String REQUESTED_API_VERSION = "1.7"; + static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); + + final ILoggerFactory loggerFactory; + + private StaticLoggerBinder() { + loggerFactory = new AdapterLoggerFactory(AdapterLoggerFactory.LoggerFactory); + } + + public static StaticLoggerBinder getSingleton() { + return SINGLETON; + } + + @Override + public ILoggerFactory getLoggerFactory() { + return loggerFactory; + } + + @Override + public String getLoggerFactoryClassStr() { + return AdapterLoggerFactory.class.getName(); + } + +} diff --git a/src/IKVM.Maven.Sdk.Tasks.Tests/MavenReferenceItemResolveTests.cs b/src/IKVM.Maven.Sdk.Tasks.Tests/MavenReferenceItemResolveTests.cs index cbb2aaf..ef23873 100644 --- a/src/IKVM.Maven.Sdk.Tasks.Tests/MavenReferenceItemResolveTests.cs +++ b/src/IKVM.Maven.Sdk.Tasks.Tests/MavenReferenceItemResolveTests.cs @@ -39,12 +39,15 @@ static ITaskItem GetLocalRepositoryItem() return item; } + public TestContext TestContext { get; set; } + [TestMethod] public void CanResolve() { var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.Repositories = new[] { GetCentralRepositoryItem() }; @@ -76,7 +79,8 @@ public void CanResolveWithClassifier() { var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.Repositories = new[] { GetCentralRepositoryItem() }; @@ -104,7 +108,8 @@ public void CanResolveWithMajorVersionOnly() { var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.Repositories = new[] { GetCentralRepositoryItem() }; @@ -134,7 +139,8 @@ public void CanResolvePackagingTypePom() { var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.Repositories = new[] { GetCentralRepositoryItem() }; @@ -164,7 +170,8 @@ public void CanResolveWithCache() var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); { var t = new MavenReferenceItemResolve(); @@ -221,7 +228,8 @@ public void CanResolveWithVersionOverride() { var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.Repositories = new[] { GetCentralRepositoryItem() }; @@ -252,7 +260,8 @@ public void CanResolveWithTransitiveDependencies() { var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.Repositories = new[] { GetCentralRepositoryItem() }; @@ -285,7 +294,8 @@ public void ShouldIncludeUnifiedVersions() var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.CacheFile = cacheFile; @@ -317,7 +327,8 @@ public void ShouldIncludeProvidedDependencies() var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.CacheFile = cacheFile; @@ -344,7 +355,8 @@ public void CompileDependencyShouldBePrivateAndReferenced() var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.CacheFile = cacheFile; @@ -373,7 +385,8 @@ public void RuntimeDependencyShouldBePrivateAndReferenced() var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.CacheFile = cacheFile; @@ -402,7 +415,8 @@ public void ProvidedDependencyShouldBeNotPrivateAndReferenced() var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.CacheFile = cacheFile; @@ -431,7 +445,8 @@ public void SystemDependencyShouldBeExcluded() var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.CacheFile = cacheFile; @@ -457,7 +472,8 @@ public void CanResolveApacheFop() var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.CacheFile = cacheFile; @@ -484,7 +500,8 @@ public void CanResolveFromLocalRepository() var engine = new Mock(); var errors = new List(); - engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => errors.Add(e)); + engine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine(e.Message); }); + engine.Setup(x => x.LogMessageEvent(It.IsAny())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message)); var t = new MavenReferenceItemResolve(); t.BuildEngine = engine.Object; t.CacheFile = cacheFile; diff --git a/src/IKVM.Maven.Sdk.Tasks/IKVM.Maven.Sdk.Tasks.csproj b/src/IKVM.Maven.Sdk.Tasks/IKVM.Maven.Sdk.Tasks.csproj index a91d2f5..d0ae67a 100644 --- a/src/IKVM.Maven.Sdk.Tasks/IKVM.Maven.Sdk.Tasks.csproj +++ b/src/IKVM.Maven.Sdk.Tasks/IKVM.Maven.Sdk.Tasks.csproj @@ -17,19 +17,9 @@ - - - - - - - - ikvm-maven-sdk-tasks - $(AssemblyVersion) - $(IntermediateOutputPath)\ikvm-maven-sdk-tasks\*.jar - - - + + + diff --git a/src/IKVM.Maven.Sdk.Tasks/ISLF4JLoggerProxy.cs b/src/IKVM.Maven.Sdk.Tasks/ISLF4JLoggerProxy.cs new file mode 100644 index 0000000..f0bfdf7 --- /dev/null +++ b/src/IKVM.Maven.Sdk.Tasks/ISLF4JLoggerProxy.cs @@ -0,0 +1,133 @@ +using System; + +using org.slf4j; + +namespace IKVM.Maven.Sdk.Tasks +{ + + interface ISLF4JLoggerProxy + { + + void trace(SLF4JContextLogger logger, string str); + + void trace(SLF4JContextLogger logger, string str, object obj); + + void trace(SLF4JContextLogger logger, string str, object obj1, object obj2); + + void trace(SLF4JContextLogger logger, string str, params object[] objarr); + + void trace(SLF4JContextLogger logger, string str, Exception t); + + void trace(SLF4JContextLogger logger, Marker m, string str); + + void trace(SLF4JContextLogger logger, Marker m, string str, object obj); + + void trace(SLF4JContextLogger logger, Marker m, string str, object obj1, object obj2); + + void trace(SLF4JContextLogger logger, Marker m, string str, params object[] objarr); + + void trace(SLF4JContextLogger logger, Marker m, string str, Exception t); + + void debug(SLF4JContextLogger logger, string str); + + void debug(SLF4JContextLogger logger, string str, object obj); + + void debug(SLF4JContextLogger logger, string str, object obj1, object obj2); + + void debug(SLF4JContextLogger logger, string str, params object[] objarr); + + void debug(SLF4JContextLogger logger, string str, Exception t); + + void debug(SLF4JContextLogger logger, Marker m, string str); + + void debug(SLF4JContextLogger logger, Marker m, string str, object obj); + + void debug(SLF4JContextLogger logger, Marker m, string str, object obj1, object obj2); + + void debug(SLF4JContextLogger logger, Marker m, string str, params object[] objarr); + + void debug(SLF4JContextLogger logger, Marker m, string str, Exception t); + + void info(SLF4JContextLogger logger, string str); + + void info(SLF4JContextLogger logger, string str, object obj); + + void info(SLF4JContextLogger logger, string str, object obj1, object obj2); + + void info(SLF4JContextLogger logger, string str, params object[] objarr); + + void info(SLF4JContextLogger logger, string str, Exception t); + + void info(SLF4JContextLogger logger, Marker m, string str); + + void info(SLF4JContextLogger logger, Marker m, string str, object obj); + + void info(SLF4JContextLogger logger, Marker m, string str, object obj1, object obj2); + + void info(SLF4JContextLogger logger, Marker m, string str, params object[] objarr); + + void info(SLF4JContextLogger logger, Marker m, string str, Exception t); + + bool isDebugEnabled(SLF4JContextLogger logger); + + bool isDebugEnabled(SLF4JContextLogger logger, Marker m); + + bool isErrorEnabled(SLF4JContextLogger logger); + + bool isErrorEnabled(SLF4JContextLogger logger, Marker m); + + bool isInfoEnabled(SLF4JContextLogger logger); + + bool isInfoEnabled(SLF4JContextLogger logger, Marker m); + + bool isTraceEnabled(SLF4JContextLogger logger); + + bool isTraceEnabled(SLF4JContextLogger logger, Marker m); + + bool isWarnEnabled(SLF4JContextLogger logger); + + bool isWarnEnabled(SLF4JContextLogger logger, Marker m); + + void warn(SLF4JContextLogger logger, string str); + + void warn(SLF4JContextLogger logger, string str, object obj); + + void warn(SLF4JContextLogger logger, string str, params object[] objarr); + + void warn(SLF4JContextLogger logger, string str, object obj1, object obj2); + + void warn(SLF4JContextLogger logger, string str, Exception t); + + void warn(SLF4JContextLogger logger, Marker m, string str); + + void warn(SLF4JContextLogger logger, Marker m, string str, object obj); + + void warn(SLF4JContextLogger logger, Marker m, string str, object obj1, object obj2); + + void warn(SLF4JContextLogger logger, Marker m, string str, params object[] objarr); + + void warn(SLF4JContextLogger logger, Marker m, string str, Exception t); + + void error(SLF4JContextLogger logger, string str); + + void error(SLF4JContextLogger logger, string str, object obj); + + void error(SLF4JContextLogger logger, string str, object obj1, object obj2); + + void error(SLF4JContextLogger logger, string str, params object[] objarr); + + void error(SLF4JContextLogger logger, string str, Exception t); + + void error(SLF4JContextLogger logger, Marker m, string str); + + void error(SLF4JContextLogger logger, Marker m, string str, object obj); + + void error(SLF4JContextLogger logger, Marker m, string str, object obj1, object obj2); + + void error(SLF4JContextLogger logger, Marker m, string str, params object[] objarr); + + void error(SLF4JContextLogger logger, Marker m, string str, Exception t); + + } + +} \ No newline at end of file diff --git a/src/IKVM.Maven.Sdk.Tasks/MavenEnvironment.cs b/src/IKVM.Maven.Sdk.Tasks/MavenEnvironment.cs index 23b9ead..cc975c4 100644 --- a/src/IKVM.Maven.Sdk.Tasks/MavenEnvironment.cs +++ b/src/IKVM.Maven.Sdk.Tasks/MavenEnvironment.cs @@ -14,7 +14,6 @@ using org.apache.maven.settings.building; using org.apache.maven.settings.crypto; using org.eclipse.aether; -using org.eclipse.aether.collection; using org.eclipse.aether.connector.basic; using org.eclipse.aether.impl; using org.eclipse.aether.repository; @@ -261,8 +260,7 @@ AuthenticationSelector CreateAuthenticationSelector() public RepositorySystemSession CreateRepositorySystemSession(bool noError = false) { var session = MavenRepositorySystemUtils.newSession(); - var repository = new LocalRepository(GetDefaultLocalRepoDir()); - session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, repository)); + session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, new LocalRepository(GetDefaultLocalRepoDir()))); session.setCache(new DefaultRepositoryCache()); session.setProxySelector(CreateProxySelector()); session.setMirrorSelector(CreateMirrorSelector()); @@ -274,15 +272,6 @@ public RepositorySystemSession CreateRepositorySystemSession(bool noError = fals return session; } - /// - /// Creates a new based on the currently loaded settings. - /// - /// - DependencyGraphTransformer CreateDependencyGraphTransformer() - { - return new ConflictResolver(new NearestVersionSelector(), new JavaScopeSelector(), new SimpleOptionalitySelector(), new JavaScopeDeriver()); - } - /// /// Creates a new representing Maven Central. /// diff --git a/src/IKVM.Maven.Sdk.Tasks/MavenReferenceItemResolve.cs b/src/IKVM.Maven.Sdk.Tasks/MavenReferenceItemResolve.cs index caf2189..4fc76e1 100644 --- a/src/IKVM.Maven.Sdk.Tasks/MavenReferenceItemResolve.cs +++ b/src/IKVM.Maven.Sdk.Tasks/MavenReferenceItemResolve.cs @@ -144,6 +144,8 @@ void TryWriteCacheFile(MavenResolveCacheFile cacheFile) /// public override bool Execute() { + using var d = SLF4JContextLogger.Enter(new SLF4JMSBuildLoggerProxy(Log)); + try { var repositories = MavenRepositoryItemMetadata.Load(Repositories); diff --git a/src/IKVM.Maven.Sdk.Tasks/SLF4JContextLogger.cs b/src/IKVM.Maven.Sdk.Tasks/SLF4JContextLogger.cs new file mode 100644 index 0000000..6d39ded --- /dev/null +++ b/src/IKVM.Maven.Sdk.Tasks/SLF4JContextLogger.cs @@ -0,0 +1,386 @@ +using System; +using System.Runtime.CompilerServices; + +using org.slf4j; + +namespace IKVM.Maven.Sdk.Tasks +{ + + class SLF4JContextLogger : org.slf4j.Logger + { + + /// + /// Initializes the static instance. + /// + static SLF4JContextLogger() + { + RuntimeHelpers.RunClassConstructor(typeof(SLF4JContextLoggerFactory).TypeHandle); + } + + [ThreadStatic] + static ISLF4JLoggerProxy context; + + /// + /// Holds the previous context to restore upon exit. + /// + class ExitContext : IDisposable + { + + readonly ISLF4JLoggerProxy previous; + + /// + /// Initializes a new instance. + /// + /// + public ExitContext(ISLF4JLoggerProxy previous) + { + this.previous = previous; + } + + /// + /// Disposes of the instance. + /// + public void Dispose() + { + context = previous; + } + + } + + /// + /// Enters a new log context. + /// + /// + /// + /// + public static IDisposable Enter(TProxy proxy) + where TProxy : ISLF4JLoggerProxy + { + var previous = context; + context = proxy; + return new ExitContext(previous); + } + + readonly string name; + + /// + /// Initializes a new instance. + /// + /// + /// + public SLF4JContextLogger(string name) + { + this.name = name; + } + + public string getName() + { + return name; + } + + public void trace(string str) + { + context?.trace(this, str); + } + + public void trace(string str, object obj) + { + context?.trace(this, str, obj); + } + + public void trace(string str, object obj1, object obj2) + { + context?.trace(this, str, obj1, obj2); + } + + public void trace(string str, params object[] objarr) + { + context?.trace(this, str, objarr); + } + + public void trace(string str, Exception t) + { + context?.trace(this, str, t); + } + + public void trace(Marker m, string str) + { + context?.trace(this, m, str); + } + + public void trace(Marker m, string str, object obj) + { + context?.trace(this, m, str, obj); + } + + public void trace(Marker m, string str, object obj1, object obj2) + { + context?.trace(this, m, str, obj1, obj2); + } + + public void trace(Marker m, string str, params object[] objarr) + { + context?.trace(this, m, str, objarr); + } + + public void trace(Marker m, string str, Exception t) + { + context?.trace(this, m, str, t); + } + + public void debug(string str) + { + context?.debug(this, str); + } + + public void debug(string str, object obj) + { + context?.debug(this, str, obj); + } + + public void debug(string str, object obj1, object obj2) + { + context?.debug(this, str, obj1, obj2); + } + + public void debug(string str, params object[] objarr) + { + context?.debug(this, str, objarr); + } + + public void debug(string str, Exception t) + { + context?.debug(this, str, t); + } + + public void debug(Marker m, string str) + { + context?.debug(this, m, str); + } + + public void debug(Marker m, string str, object obj) + { + context?.debug(this, m, str, obj); + } + + public void debug(Marker m, string str, object obj1, object obj2) + { + context?.debug(this, m, str, obj1, obj2); + } + + public void debug(Marker m, string str, params object[] objarr) + { + context?.debug(this, m, str, objarr); + } + + public void debug(Marker m, string str, Exception t) + { + context?.debug(this, m, str, t); + } + + public void info(string str) + { + context?.info(this, str); + } + + public void info(string str, object obj) + { + context?.info(this, str, obj); + } + + public void info(string str, object obj1, object obj2) + { + context?.info(this, str, obj1, obj2); + } + + public void info(string str, params object[] objarr) + { + context?.info(this, str, objarr); + } + + public void info(string str, Exception t) + { + context?.info(this, str, t); + } + + public void info(Marker m, string str) + { + context?.info(this, m, str); + } + + public void info(Marker m, string str, object obj) + { + context?.info(this, m, str, obj); + } + + public void info(Marker m, string str, object obj1, object obj2) + { + context?.info(this, m, str, obj1, obj2); + } + + public void info(Marker m, string str, params object[] objarr) + { + context?.info(this, m, str, objarr); + } + + public void info(Marker m, string str, Exception t) + { + context?.info(this, m, str, t); + } + + public bool isDebugEnabled() + { + return context?.isDebugEnabled(this) ?? false; + } + + public bool isDebugEnabled(Marker m) + { + return context?.isDebugEnabled(this, m) ?? false; + } + + public bool isErrorEnabled() + { + return context?.isErrorEnabled(this) ?? false; + } + + public bool isErrorEnabled(Marker m) + { + return context?.isErrorEnabled(this, m) ?? false; + } + + public bool isInfoEnabled() + { + return context?.isInfoEnabled(this) ?? false; + } + + public bool isInfoEnabled(Marker m) + { + return context?.isInfoEnabled(this, m) ?? false; + } + + public bool isTraceEnabled() + { + return context?.isTraceEnabled(this) ?? false; + } + + public bool isTraceEnabled(Marker m) + { + return context?.isTraceEnabled(this, m) ?? false; + } + + public bool isWarnEnabled() + { + return context?.isWarnEnabled(this) ?? false; + } + + public bool isWarnEnabled(Marker m) + { + return context?.isWarnEnabled(this, m) ?? false; + } + + public void warn(string str) + { + context?.warn(this, str); + } + + public void warn(string str, object obj) + { + context?.warn(this, str, obj); + } + + public void warn(string str, params object[] objarr) + { + context?.warn(this, str, objarr); + } + + public void warn(string str, object obj1, object obj2) + { + context?.warn(this, str, obj1, obj2); + } + + public void warn(string str, Exception t) + { + context?.warn(this, str, t); + } + + public void warn(Marker m, string str) + { + context?.warn(this, m, str); + } + + public void warn(Marker m, string str, object obj) + { + context?.warn(this, m, str, obj); + } + + public void warn(Marker m, string str, object obj1, object obj2) + { + context?.warn(this, m, str, obj1, obj2); + } + + public void warn(Marker m, string str, params object[] objarr) + { + context?.warn(this, m, str, objarr); + } + + public void warn(Marker m, string str, Exception t) + { + context?.warn(this, m, str, t); + } + + public void error(string str) + { + context?.error(this, str); + } + + public void error(string str, object obj) + { + context?.error(this, str, obj); + } + + public void error(string str, object obj1, object obj2) + { + context?.error(this, str, obj1, obj2); + } + + public void error(string str, params object[] objarr) + { + context?.error(this, str, objarr); + } + + public void error(string str, Exception t) + { + context?.error(this, str, t); + } + + public void error(Marker m, string str) + { + context?.error(this, m, str); + } + + public void error(Marker m, string str, object obj) + { + + context?.error(this, m, str, obj); + } + + public void error(Marker m, string str, object obj1, object obj2) + { + + context?.error(this, m, str, obj1, obj2); + } + + public void error(Marker m, string str, params object[] objarr) + { + + context?.error(this, m, str, objarr); + } + + public void error(Marker m, string str, Exception t) + { + context?.error(this, m, str, t); + } + + } + +} \ No newline at end of file diff --git a/src/IKVM.Maven.Sdk.Tasks/SLF4JContextLoggerFactory.cs b/src/IKVM.Maven.Sdk.Tasks/SLF4JContextLoggerFactory.cs new file mode 100644 index 0000000..2c276be --- /dev/null +++ b/src/IKVM.Maven.Sdk.Tasks/SLF4JContextLoggerFactory.cs @@ -0,0 +1,26 @@ +using IKVM.Maven.Sdk.Tasks.Java; + +using org.slf4j; + +namespace IKVM.Maven.Sdk.Tasks +{ + + class SLF4JContextLoggerFactory : org.slf4j.ILoggerFactory + { + + /// + /// Initializes the static instance. + /// + static SLF4JContextLoggerFactory() + { + AdapterLoggerFactory.LoggerFactory = new SLF4JContextLoggerFactory(); + } + + public Logger getLogger(string name) + { + return new SLF4JContextLogger(name); + } + + } + +} diff --git a/src/IKVM.Maven.Sdk.Tasks/SLF4JMSBuildLoggerProxy.cs b/src/IKVM.Maven.Sdk.Tasks/SLF4JMSBuildLoggerProxy.cs new file mode 100644 index 0000000..5a15985 --- /dev/null +++ b/src/IKVM.Maven.Sdk.Tasks/SLF4JMSBuildLoggerProxy.cs @@ -0,0 +1,336 @@ +using System; +using System.Runtime.CompilerServices; + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +using org.slf4j; +using org.slf4j.helpers; + +namespace IKVM.Maven.Sdk.Tasks +{ + + class SLF4JMSBuildLoggerProxy : ISLF4JLoggerProxy + { + + /// + /// Initializes the static instance. + /// + static SLF4JMSBuildLoggerProxy() + { + RuntimeHelpers.RunClassConstructor(typeof(SLF4JContextLogger).TypeHandle); + } + + readonly TaskLoggingHelper log; + + /// + /// Initializes a new instance. + /// + /// + public SLF4JMSBuildLoggerProxy(TaskLoggingHelper log) + { + this.log = log ?? throw new ArgumentNullException(nameof(log)); + } + + public void trace(SLF4JContextLogger logger, string message) + { + log.LogMessageFromText(message, MessageImportance.Low); + } + + public void trace(SLF4JContextLogger logger, string str, object obj) + { + log.LogMessageFromText(MessageFormatter.format(str, obj).getMessage(), MessageImportance.Low); + } + + public void trace(SLF4JContextLogger logger, string str, object obj1, object obj2) + { + log.LogMessageFromText(MessageFormatter.format(str, obj1, obj2).getMessage(), MessageImportance.Low); + } + + public void trace(SLF4JContextLogger logger, string str, params object[] objarr) + { + log.LogMessageFromText(MessageFormatter.arrayFormat(str, objarr).getMessage(), MessageImportance.Low); + } + + public void trace(SLF4JContextLogger logger, string str, Exception t) + { + log.LogMessageFromText(str + ": " + t?.Message, MessageImportance.Low); + } + + public void trace(SLF4JContextLogger logger, Marker m, string str) + { + log.LogMessageFromText(str, MessageImportance.Low); + } + + public void trace(SLF4JContextLogger logger, Marker m, string str, object obj) + { + log.LogMessageFromText(MessageFormatter.format(str, obj).getMessage(), MessageImportance.Low); + } + + public void trace(SLF4JContextLogger logger, Marker m, string str, object obj1, object obj2) + { + log.LogMessageFromText(MessageFormatter.format(str, obj1, obj2).getMessage(), MessageImportance.Low); + } + + public void trace(SLF4JContextLogger logger, Marker m, string str, params object[] objarr) + { + log.LogMessageFromText(MessageFormatter.arrayFormat(str, objarr).getMessage(), MessageImportance.Low); + } + + public void trace(SLF4JContextLogger logger, Marker m, string str, Exception t) + { + log.LogMessageFromText(str + ": " + t?.Message, MessageImportance.Low); + } + + public void debug(SLF4JContextLogger logger, string message) + { + log.LogMessageFromText(message, MessageImportance.Low); + } + + public void debug(SLF4JContextLogger logger, string str, object obj) + { + log.LogMessageFromText(MessageFormatter.format(str, obj).getMessage(), MessageImportance.Low); + } + + public void debug(SLF4JContextLogger logger, string str, object obj1, object obj2) + { + log.LogMessageFromText(MessageFormatter.format(str, obj1, obj2).getMessage(), MessageImportance.Low); + } + + public void debug(SLF4JContextLogger logger, string str, params object[] objarr) + { + log.LogMessageFromText(MessageFormatter.arrayFormat(str, objarr).getMessage(), MessageImportance.Low); + } + + public void debug(SLF4JContextLogger logger, string str, Exception t) + { + log.LogMessageFromText(str + ": " + t?.Message, MessageImportance.Low); + } + + public void debug(SLF4JContextLogger logger, Marker m, string str) + { + log.LogMessageFromText(str, MessageImportance.Low); + } + + public void debug(SLF4JContextLogger logger, Marker m, string str, object obj) + { + log.LogMessageFromText(MessageFormatter.format(str, obj).getMessage(), MessageImportance.Low); + } + + public void debug(SLF4JContextLogger logger, Marker m, string str, object obj1, object obj2) + { + log.LogMessageFromText(MessageFormatter.format(str, obj1, obj2).getMessage(), MessageImportance.Low); + } + + public void debug(SLF4JContextLogger logger, Marker m, string str, params object[] objarr) + { + log.LogMessageFromText(MessageFormatter.arrayFormat(str, objarr).getMessage(), MessageImportance.Low); + } + + public void debug(SLF4JContextLogger logger, Marker m, string str, Exception t) + { + log.LogMessageFromText(str + ": " + t?.Message, MessageImportance.Low); + } + public void info(SLF4JContextLogger logger, string message) + { + log.LogMessageFromText(message, MessageImportance.Normal); + } + + public void info(SLF4JContextLogger logger, string str, object obj) + { + log.LogMessageFromText(MessageFormatter.format(str, obj).getMessage(), MessageImportance.Normal); + } + + public void info(SLF4JContextLogger logger, string str, object obj1, object obj2) + { + log.LogMessageFromText(MessageFormatter.format(str, obj1, obj2).getMessage(), MessageImportance.Normal); + } + + public void info(SLF4JContextLogger logger, string str, params object[] objarr) + { + log.LogMessageFromText(MessageFormatter.arrayFormat(str, objarr).getMessage(), MessageImportance.Normal); + } + + public void info(SLF4JContextLogger logger, string str, Exception t) + { + log.LogMessageFromText(str + ": " + t?.Message, MessageImportance.Normal); + } + + public void info(SLF4JContextLogger logger, Marker m, string str) + { + log.LogMessageFromText(str, MessageImportance.Normal); + } + + public void info(SLF4JContextLogger logger, Marker m, string str, object obj) + { + log.LogMessageFromText(MessageFormatter.format(str, obj).getMessage(), MessageImportance.Normal); + } + + public void info(SLF4JContextLogger logger, Marker m, string str, object obj1, object obj2) + { + log.LogMessageFromText(MessageFormatter.format(str, obj1, obj2).getMessage(), MessageImportance.Normal); + } + + public void info(SLF4JContextLogger logger, Marker m, string str, params object[] objarr) + { + log.LogMessageFromText(MessageFormatter.arrayFormat(str, objarr).getMessage(), MessageImportance.Normal); + } + + public void info(SLF4JContextLogger logger, Marker m, string str, Exception t) + { + log.LogMessageFromText(str + ": " + t?.Message, MessageImportance.Normal); + } + + public void warn(SLF4JContextLogger logger, string message) + { + log.LogWarning(message, MessageImportance.Normal); + } + + public void warn(SLF4JContextLogger logger, string str, object obj) + { + log.LogWarning(MessageFormatter.format(str, obj).getMessage(), MessageImportance.Normal); + } + + public void warn(SLF4JContextLogger logger, string str, object obj1, object obj2) + { + log.LogWarning(MessageFormatter.format(str, obj1, obj2).getMessage(), MessageImportance.Normal); + } + + public void warn(SLF4JContextLogger logger, string str, params object[] objarr) + { + log.LogWarning(MessageFormatter.arrayFormat(str, objarr).getMessage(), MessageImportance.Normal); + } + + public void warn(SLF4JContextLogger logger, string str, Exception t) + { + log.LogWarning(str + ": " + t?.Message, MessageImportance.Normal); + } + + public void warn(SLF4JContextLogger logger, Marker m, string str) + { + log.LogWarning(str, MessageImportance.Normal); + } + + public void warn(SLF4JContextLogger logger, Marker m, string str, object obj) + { + log.LogWarning(MessageFormatter.format(str, obj).getMessage(), MessageImportance.Normal); + } + + public void warn(SLF4JContextLogger logger, Marker m, string str, object obj1, object obj2) + { + log.LogWarning(MessageFormatter.format(str, obj1, obj2).getMessage(), MessageImportance.Normal); + } + + public void warn(SLF4JContextLogger logger, Marker m, string str, params object[] objarr) + { + log.LogWarning(MessageFormatter.arrayFormat(str, objarr).getMessage(), MessageImportance.Normal); + } + + public void warn(SLF4JContextLogger logger, Marker m, string str, Exception t) + { + log.LogWarning(str + ": " + t?.Message, MessageImportance.Normal); + } + + public void error(SLF4JContextLogger logger, string message) + { + log.LogError(message, MessageImportance.Normal); + } + + public void error(SLF4JContextLogger logger, string str, object obj) + { + log.LogError(MessageFormatter.format(str, obj).getMessage(), MessageImportance.Normal); + } + + public void error(SLF4JContextLogger logger, string str, object obj1, object obj2) + { + log.LogError(MessageFormatter.format(str, obj1, obj2).getMessage(), MessageImportance.Normal); + } + + public void error(SLF4JContextLogger logger, string str, params object[] objarr) + { + log.LogError(MessageFormatter.arrayFormat(str, objarr).getMessage(), MessageImportance.Normal); + } + + public void error(SLF4JContextLogger logger, string str, Exception t) + { + log.LogError(str + ": " + t?.Message, MessageImportance.Normal); + } + + public void error(SLF4JContextLogger logger, Marker m, string str) + { + log.LogError(str, MessageImportance.Normal); + } + + public void error(SLF4JContextLogger logger, Marker m, string str, object obj) + { + log.LogError(MessageFormatter.format(str, obj).getMessage(), MessageImportance.Normal); + } + + public void error(SLF4JContextLogger logger, Marker m, string str, object obj1, object obj2) + { + log.LogError(MessageFormatter.format(str, obj1, obj2).getMessage(), MessageImportance.Normal); + } + + public void error(SLF4JContextLogger logger, Marker m, string str, params object[] objarr) + { + log.LogError(MessageFormatter.arrayFormat(str, objarr).getMessage(), MessageImportance.Normal); + } + + public void error(SLF4JContextLogger logger, Marker m, string str, Exception t) + { + log.LogError(str + ": " + t?.Message, MessageImportance.Normal); + } + + public bool isDebugEnabled(SLF4JContextLogger logger) + { + return true; + } + + public bool isDebugEnabled(SLF4JContextLogger logger, Marker m) + { + return true; + } + + public bool isTraceEnabled(SLF4JContextLogger logger) + { + return true; + } + + public bool isTraceEnabled(SLF4JContextLogger logger, Marker m) + { + return true; + } + + public bool isInfoEnabled(SLF4JContextLogger logger) + { + return true; + } + + public bool isInfoEnabled(SLF4JContextLogger logger, Marker m) + { + return true; + } + + public bool isWarnEnabled(SLF4JContextLogger logger) + { + return true; + } + + public bool isWarnEnabled(SLF4JContextLogger logger, Marker m) + { + return true; + } + + public bool isErrorEnabled(SLF4JContextLogger logger) + { + return true; + } + + public bool isErrorEnabled(SLF4JContextLogger logger, Marker m) + { + return true; + } + + } + +}