Skip to content

Commit

Permalink
Version Added in project file
Browse files Browse the repository at this point in the history
  • Loading branch information
ragavareddychalapala committed Jul 12, 2024
1 parent cd044ce commit 494cb35
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>ArtifactoryUploader</AssemblyName>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
13 changes: 13 additions & 0 deletions src/ArtifactoryUploader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using LCT.Common.Model;

namespace ArtifactoryUploader
{
Expand All @@ -44,6 +45,7 @@ static async Task Main(string[] args)
string FolderPath = InitiateLogger(appSettings);

settingsManager.CheckRequiredArgsToRun(appSettings, "Uploader");
CatoolInfo caToolVersion = GetCatoolVersionFromProjectfile();

Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Artifactory Uploader >>>>>====================", null);
Logger.Logger.Log(null, Level.Notice, $"\nStart of Artifactory Uploader execution: {DateTime.Now}", null);
Expand All @@ -55,6 +57,8 @@ static async Task Main(string[] args)

Logger.Logger.Log(null, Level.Info, $"Input Parameters used in Artifactory Uploader:\n\t", null);
Logger.Logger.Log(null, Level.Notice, $"\tBomFilePath:\t\t {appSettings.BomFilePath}\n\t" +
$"CaToolVersion\t\t --> {caToolVersion.CatoolVersion}\n\t" +
$"CaToolRunningPath\t --> {caToolVersion.CatoolRunningLocation}\n\t" +
$"JFrogUrl:\t\t {appSettings.JFrogApi}\n\t" +
$"Release:\t\t {appSettings.Release}\n\t" +
$"LogFolderPath:\t\t {Path.GetFullPath(FolderPath)}\n", null);
Expand All @@ -77,6 +81,15 @@ static async Task Main(string[] args)
Logger.Logger.Log(null, Level.Notice, $"End of Artifactory Uploader execution : {DateTime.Now}\n", null);
}

private static CatoolInfo GetCatoolVersionFromProjectfile()
{
CatoolInfo catoolInfo = new CatoolInfo();
var versionFromProj = Assembly.GetExecutingAssembly().GetName().Version;
catoolInfo.CatoolVersion = $"{versionFromProj.Major}.{versionFromProj.Minor}.{versionFromProj.Build}";
catoolInfo.CatoolRunningLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
return catoolInfo;
}

private static string InitiateLogger(CommonAppSettings appSettings)
{
string FolderPath;
Expand Down
1 change: 1 addition & 0 deletions src/LCT.APICommunications/LCT.APICommunications.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
1 change: 1 addition & 0 deletions src/LCT.Common/LCT.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
16 changes: 16 additions & 0 deletions src/LCT.Common/Model/CatoolInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// --------------------------------------------------------------------------------------------------------------------
// SPDX-FileCopyrightText: 2024 Siemens AG
//
// SPDX-License-Identifier: MIT
// --------------------------------------------------------------------------------------------------------------------


namespace LCT.Common.Model
{
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class CatoolInfo
{
public string CatoolVersion { get; set; }
public string CatoolRunningLocation { get; set; }
}
}
1 change: 1 addition & 0 deletions src/LCT.CycloneDxProcessor/LCT.CycloneDxProcessor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
1 change: 1 addition & 0 deletions src/LCT.Facade/LCT.Facade.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
5 changes: 3 additions & 2 deletions src/LCT.PackageIdentifier/BomCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using LCT.Common;
using LCT.Common.Constants;
using LCT.Common.Interface;
using LCT.Common.Model;
using LCT.PackageIdentifier.Interface;
using LCT.PackageIdentifier.Model;
using LCT.Services.Interface;
Expand Down Expand Up @@ -41,7 +42,7 @@ public BomCreator(ICycloneDXBomParser cycloneDXBomParser)
CycloneDXBomParser = cycloneDXBomParser;
}

public async Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations, ProjectReleases projectReleases)
public async Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations, ProjectReleases projectReleases, CatoolInfo caToolInformation)
{
Logger.Debug($"GenerateBom():Start");
Bom listOfComponentsToBom;
Expand All @@ -55,7 +56,7 @@ public async Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelpe
//Get project details for metadata properties

//sets metadata properties
listOfComponentsToBom = CycloneBomProcessor.SetMetadataInComparisonBOM(listOfComponentsToBom, appSettings, projectReleases);
listOfComponentsToBom = CycloneBomProcessor.SetMetadataInComparisonBOM(listOfComponentsToBom, appSettings, projectReleases,caToolInformation);

// Writes Comparison Bom
Logger.Logger.Log(null, Level.Notice, $"Writing CycloneDX BOM..", null);
Expand Down
5 changes: 3 additions & 2 deletions src/LCT.PackageIdentifier/CycloneBomProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using LCT.APICommunications.Model;
using LCT.Common;
using LCT.Common.Constants;
using LCT.Common.Model;
using log4net;
using NuGet.Packaging.Signing;
using System;
Expand All @@ -24,7 +25,7 @@ public static class CycloneBomProcessor

private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

public static Bom SetMetadataInComparisonBOM(Bom bom, CommonAppSettings appSettings, ProjectReleases projectReleases)
public static Bom SetMetadataInComparisonBOM(Bom bom, CommonAppSettings appSettings, ProjectReleases projectReleases,CatoolInfo caToolInformation)
{
Logger.Debug("Starting to add metadata info into the BOM");
List<Tool> tools = new List<Tool>();
Expand All @@ -33,7 +34,7 @@ public static Bom SetMetadataInComparisonBOM(Bom bom, CommonAppSettings appSetti
Tool tool = new Tool
{
Name = "Clearing Automation Tool",
Version = appSettings.CaVersion,
Version = caToolInformation.CatoolVersion,
Vendor = "Siemens AG",
ExternalReferences = new List<ExternalReference>() { new ExternalReference { Url = "https://github.com/siemens/continuous-clearing", Type = ExternalReference.ExternalReferenceType.Website } }

Expand Down
3 changes: 2 additions & 1 deletion src/LCT.PackageIdentifier/Interface/IBomCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using LCT.APICommunications.Model;
using LCT.Common;
using LCT.Common.Interface;
using LCT.Common.Model;
using LCT.Services.Interface;
using System.Threading.Tasks;

Expand All @@ -21,7 +22,7 @@ public interface IBomCreator

public IBomHelper BomHelper { get; set; }

public Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations, ProjectReleases projectReleases);
public Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations, ProjectReleases projectReleases,CatoolInfo caToolVersion);

public Task<bool> CheckJFrogConnection();
}
Expand Down
3 changes: 2 additions & 1 deletion src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>PackageIdentifier</AssemblyName>
<AssemblyName>PackageIdentifier</AssemblyName>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
20 changes: 15 additions & 5 deletions src/LCT.PackageIdentifier/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Program
protected Program() { }

static async Task Main(string[] args)
{
{
BomStopWatch = new Stopwatch();
BomStopWatch.Start();

Expand All @@ -52,9 +52,8 @@ static async Task Main(string[] args)
CommonAppSettings appSettings = settingsManager.ReadConfiguration<CommonAppSettings>(args, FileConstant.appSettingFileName);
ProjectReleases projectReleases = new ProjectReleases();
string FolderPath = LogFolderInitialisation(appSettings);

settingsManager.CheckRequiredArgsToRun(appSettings, "Identifer");

CatoolInfo caToolInformation = GetCatoolVersionFromProjectfile();
settingsManager.CheckRequiredArgsToRun(appSettings, "Identifer");
Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Package Identifier >>>>>====================", null);
Logger.Logger.Log(null, Level.Notice, $"\nStart of Package Identifier execution: {DateTime.Now}", null);

Expand All @@ -78,6 +77,8 @@ static async Task Main(string[] args)
}

Logger.Logger.Log(null, Level.Notice, $"Input Parameters used in Package Identifier:\n\t" +
$"CaToolVersion\t\t --> {caToolInformation.CatoolVersion}\n\t" +
$"CaToolRunningPath\t --> {caToolInformation.CatoolRunningLocation}\n\t" +
$"PackageFilePath\t\t --> {appSettings.PackageFilePath}\n\t" +
$"BomFolderPath\t\t --> {appSettings.BomFolderPath}\n\t" +
$"SBOMTemplateFilePath\t --> {appSettings.CycloneDxSBomTemplatePath}\n\t" +
Expand All @@ -104,11 +105,20 @@ static async Task Main(string[] args)
//Validating JFrog Settings
if (await bomCreator.CheckJFrogConnection())
{
await bomCreator.GenerateBom(appSettings, new BomHelper(), new FileOperations(),projectReleases);
await bomCreator.GenerateBom(appSettings, new BomHelper(), new FileOperations(),projectReleases, caToolInformation);
}
Logger.Logger.Log(null, Level.Notice, $"End of Package Identifier execution : {DateTime.Now}\n", null);
}

private static CatoolInfo GetCatoolVersionFromProjectfile()
{
CatoolInfo catoolInfo = new CatoolInfo();
var versionFromProj = Assembly.GetExecutingAssembly().GetName().Version;
catoolInfo.CatoolVersion = $"{versionFromProj.Major}.{versionFromProj.Minor}.{versionFromProj.Build}";
catoolInfo.CatoolRunningLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
return catoolInfo;
}

private static IJFrogService GetJfrogService(CommonAppSettings appSettings)
{
ArtifactoryCredentials artifactoryUpload = new ArtifactoryCredentials()
Expand Down
1 change: 1 addition & 0 deletions src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>SW360PackageCreator</AssemblyName>
<RootNamespace>LCT.SW360PackageCreator</RootNamespace>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
12 changes: 12 additions & 0 deletions src/LCT.SW360PackageCreator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ static async Task Main(string[] args)
string FolderPath = InitiateLogger(appSettings);
settingsManager.CheckRequiredArgsToRun(appSettings, "Creator");
await CreatorValidator.ValidateAppSettings(appSettings, sw360ProjectService, projectReleases);
CatoolInfo caToolInformation = GetCatoolVersionFromProjectfile();

Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Package creator >>>>>====================", null);
Logger.Logger.Log(null, Level.Notice, $"\nStart of Package creator execution : {DateTime.Now}", null);
Expand All @@ -62,6 +63,8 @@ static async Task Main(string[] args)
Logger.Logger.Log(null, Level.Alert, $"Package creator is running in TEST mode \n", null);

Logger.Logger.Log(null, Level.Notice, $"Input parameters used in Package Creator:\n\t" +
$"CaToolVersion\t\t --> {caToolInformation.CatoolVersion}\n\t" +
$"CaToolRunningPath\t --> {caToolInformation.CatoolRunningLocation}\n\t" +
$"BomFilePath\t\t --> {appSettings.BomFilePath}\n\t" +
$"SW360Url\t\t --> {appSettings.SW360URL}\n\t" +
$"SW360AuthTokenType\t --> {appSettings.SW360AuthTokenType}\n\t" +
Expand All @@ -79,6 +82,15 @@ static async Task Main(string[] args)
Logger.Logger.Log(null, Level.Notice, $"End of Package Creator execution: {DateTime.Now}\n", null);
}

private static CatoolInfo GetCatoolVersionFromProjectfile()
{
CatoolInfo catoolInfo = new CatoolInfo();
var versionFromProj = Assembly.GetExecutingAssembly().GetName().Version;
catoolInfo.CatoolVersion = $"{versionFromProj.Major}.{versionFromProj.Minor}.{versionFromProj.Build}";
catoolInfo.CatoolRunningLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
return catoolInfo;
}

private static ISw360ProjectService Getsw360ProjectServiceObject(CommonAppSettings appSettings, out ISW360ApicommunicationFacade sW360ApicommunicationFacade)
{
ISw360ProjectService sw360ProjectService;
Expand Down
1 change: 1 addition & 0 deletions src/LCT.Services/LCT.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down

0 comments on commit 494cb35

Please sign in to comment.