Skip to content

Commit

Permalink
Initialize maven for tests on Github.
Browse files Browse the repository at this point in the history
Enable private repo test. Need to publish some sort of jar that we can use to actually test against.
  • Loading branch information
wasabii committed Dec 14, 2023
1 parent 00c58a8 commit 56b6eff
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/IKVM.Maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Set up Java 8
uses: actions/setup-java@v2
with:
java-version: 8
server-id: github
settings-path: ${{ github.workspace }}
- name: Add NuGet Source (GitHub)
shell: pwsh
run: dotnet nuget add source --username USERNAME --password $env:GITHUB_TOKEN --store-password-in-clear-text --name ikvm $env:GITHUB_REPOS
Expand Down
54 changes: 26 additions & 28 deletions src/IKVM.Maven.Sdk.Tasks.Tests/MavenReferenceItemResolveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,34 +545,32 @@ public void CanResolveFromLocalRepository()
t.ResolvedReferences.Should().Contain(i => i.ItemSpec == "maven$hellotest:hellotest:1.0");
}

// TODO, need to set up some sort of local repository resolution or something to run this test
//
//[TestMethod]
//public void CanResolveFromPrivateRepository()
//{
// var cacheFile = Path.GetTempFileName();

// var engine = new Mock<IBuildEngine>();
// var errors = new List<BuildErrorEventArgs>();
// engine.Setup(x => x.LogErrorEvent(It.IsAny<BuildErrorEventArgs>())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine("ERROR: " + e.Message); });
// engine.Setup(x => x.LogWarningEvent(It.IsAny<BuildWarningEventArgs>())).Callback((BuildWarningEventArgs e) => TestContext.WriteLine("WARNING: " + e.Message));
// engine.Setup(x => x.LogMessageEvent(It.IsAny<BuildMessageEventArgs>())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message));
// var t = new MavenReferenceItemResolve();
// t.BuildEngine = engine.Object;
// t.CacheFile = cacheFile;
// t.Repositories = new[] { GetCentralRepositoryItem(), GetPrivateRepositoryItem() };

// var i1 = new TaskItem("hellotest:hellotest:1.0");
// i1.SetMetadata(MavenReferenceItemMetadata.GroupId, "hellotest");
// i1.SetMetadata(MavenReferenceItemMetadata.ArtifactId, "hellotest");
// i1.SetMetadata(MavenReferenceItemMetadata.Version, "1.0");
// i1.SetMetadata(MavenReferenceItemMetadata.Scope, "compile");
// t.References = new[] { i1 };

// t.Execute().Should().BeTrue();
// errors.Should().BeEmpty();
// t.ResolvedReferences.Should().Contain(i => i.ItemSpec == "maven$hellotest:hellotest:1.0");
//}
[TestMethod]
public void CanResolveFromPrivateRepository()
{
var cacheFile = Path.GetTempFileName();

var engine = new Mock<IBuildEngine>();
var errors = new List<BuildErrorEventArgs>();
engine.Setup(x => x.LogErrorEvent(It.IsAny<BuildErrorEventArgs>())).Callback((BuildErrorEventArgs e) => { errors.Add(e); TestContext.WriteLine("ERROR: " + e.Message); });
engine.Setup(x => x.LogWarningEvent(It.IsAny<BuildWarningEventArgs>())).Callback((BuildWarningEventArgs e) => TestContext.WriteLine("WARNING: " + e.Message));
engine.Setup(x => x.LogMessageEvent(It.IsAny<BuildMessageEventArgs>())).Callback((BuildMessageEventArgs e) => TestContext.WriteLine(e.Message));
var t = new MavenReferenceItemResolve();
t.BuildEngine = engine.Object;
t.CacheFile = cacheFile;
t.Repositories = new[] { GetCentralRepositoryItem(), GetPrivateRepositoryItem() };

var i1 = new TaskItem("org.apache.xmlgraphics:fop:2.8");
i1.SetMetadata(MavenReferenceItemMetadata.GroupId, "org.apache.xmlgraphics");
i1.SetMetadata(MavenReferenceItemMetadata.ArtifactId, "fop");
i1.SetMetadata(MavenReferenceItemMetadata.Version, "2.8");
i1.SetMetadata(MavenReferenceItemMetadata.Scope, "compile");
t.References = new[] { i1 };

t.Execute().Should().BeTrue();
errors.Should().BeEmpty();
t.ResolvedReferences.Should().Contain(i => i.ItemSpec == "maven$org.apache.xmlgraphics:fop:2.8");
}

}

Expand Down
4 changes: 2 additions & 2 deletions src/IKVM.Maven.Sdk.Tasks/MavenEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ File GetDefaultLocalRepoDir()
{
if (settings.getLocalRepository() != null)
return new File(settings.getLocalRepository());

return new File(Path.Combine(UserHome, "repository"));
else
return new File(Path.Combine(UserHome, "repository"));
}

/// <summary>
Expand Down

0 comments on commit 56b6eff

Please sign in to comment.