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

Package the jar analyzers #5290

Merged
merged 25 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,4 @@ $RECYCLE.BIN/
/build/DownloadDependencies/tmp
/**/launchSettings.json
/src/Rules/Embedded
/src/Integration.Vsix/DownloadedJars
20 changes: 19 additions & 1 deletion SonarLint.VisualStudio.Integration.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Integration.Vsix", "src\Integration.Vsix\Integration.Vsix.csproj", "{FF2AD819-28F4-493A-8E9B-1D3F16BD4689}"
ProjectSection(ProjectDependencies) = postProject
{0E50D9A0-693D-4B4E-81E2-8B8028231CFA} = {0E50D9A0-693D-4B4E-81E2-8B8028231CFA}
{2BB16C6F-BF06-4225-99A0-F1CFE70CBE44} = {2BB16C6F-BF06-4225-99A0-F1CFE70CBE44}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Integration", "src\Integration\Integration.csproj", "{03278C1A-EE78-4FA7-A5B0-1AB0A81EA76F}"
Expand Down Expand Up @@ -167,7 +168,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SLCore.Listeners", "src\SLC
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SLCore.Listeners.UnitTests", "src\SLCore.Listeners.UnitTests\SLCore.Listeners.UnitTests.csproj", "{23321F44-DE37-4801-96BB-BC8E3CCFC7F1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLCore.IntegrationTests", "src\SLCore.IntegrationTests\SLCore.IntegrationTests.csproj", "{1625398B-2343-481E-9B90-57B38EBEE8C5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SLCore.IntegrationTests", "src\SLCore.IntegrationTests\SLCore.IntegrationTests.csproj", "{1625398B-2343-481E-9B90-57B38EBEE8C5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CopyDependencies", "CopyDependencies", "{421D8026-2CBF-4444-A886-67428C1813E9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CopyDependencies", "build\CopyDependencies\CopyDependencies.csproj", "{2BB16C6F-BF06-4225-99A0-F1CFE70CBE44}"
ProjectSection(ProjectDependencies) = postProject
{3ECCAF9D-3B23-4980-83E2-8ACEE0FC6BEB} = {3ECCAF9D-3B23-4980-83E2-8ACEE0FC6BEB}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -513,6 +521,14 @@ Global
{1625398B-2343-481E-9B90-57B38EBEE8C5}.Release|Any CPU.Build.0 = Release|Any CPU
{1625398B-2343-481E-9B90-57B38EBEE8C5}.Release|x86.ActiveCfg = Release|Any CPU
{1625398B-2343-481E-9B90-57B38EBEE8C5}.Release|x86.Build.0 = Release|Any CPU
{2BB16C6F-BF06-4225-99A0-F1CFE70CBE44}.Debug|Any CPU.ActiveCfg = Debug|x86
{2BB16C6F-BF06-4225-99A0-F1CFE70CBE44}.Debug|Any CPU.Build.0 = Debug|x86
{2BB16C6F-BF06-4225-99A0-F1CFE70CBE44}.Debug|x86.ActiveCfg = Debug|x86
{2BB16C6F-BF06-4225-99A0-F1CFE70CBE44}.Debug|x86.Build.0 = Debug|x86
{2BB16C6F-BF06-4225-99A0-F1CFE70CBE44}.Release|Any CPU.ActiveCfg = Debug|x86
{2BB16C6F-BF06-4225-99A0-F1CFE70CBE44}.Release|Any CPU.Build.0 = Debug|x86
{2BB16C6F-BF06-4225-99A0-F1CFE70CBE44}.Release|x86.ActiveCfg = Debug|x86
{2BB16C6F-BF06-4225-99A0-F1CFE70CBE44}.Release|x86.Build.0 = Debug|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -565,6 +581,8 @@ Global
{8523D19D-1760-4608-9A4F-3A9353279A16} = {236587E8-62A7-4E4E-815D-A50433859DC7}
{23321F44-DE37-4801-96BB-BC8E3CCFC7F1} = {236587E8-62A7-4E4E-815D-A50433859DC7}
{1625398B-2343-481E-9B90-57B38EBEE8C5} = {236587E8-62A7-4E4E-815D-A50433859DC7}
{421D8026-2CBF-4444-A886-67428C1813E9} = {E93C2CF9-69A6-4669-BE8A-6060B18FEDCA}
{2BB16C6F-BF06-4225-99A0-F1CFE70CBE44} = {421D8026-2CBF-4444-A886-67428C1813E9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DABC27C8-E761-4826-AD2D-056F677EF3C0}
Expand Down
19 changes: 19 additions & 0 deletions build/CopyDependencies/CommonMSBuild.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project>
<!-- ************************************************************** -->
<!-- Common MSBuild targets -->
<!-- ************************************************************** -->
<!-- We aren't importing any of the standard MS targets/SDKs, so we need to define these targets
so we can clean and rebuild from the command line as normal. -->
<Target Name="Clean" />
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />

<!-- No-op. Called by MSBuild when building other projects that reference this one.
The empty targets don't seem to be needed when building inside VS, but command
line builds fail if they are not defined (even though there are no explicit
<ProjectReferences> to this project. -->
<Target Name="BuiltProjectOutputGroup" />
<Target Name="BuiltProjectOutputGroupDependencies" />
<Target Name="GetCopyToOutputDirectoryItems" />
<Target Name="SatelliteDllsProjectOutputGroup" />
<Target Name="DebugSymbolsProjectOutputGroup" />
</Project>
11 changes: 11 additions & 0 deletions build/CopyDependencies/CopyDependencies.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project DefaultTargets="Build" ToolsVersion="Current">
<PropertyGroup>
<ProjectGuid>{2BB16C6F-BF06-4225-99A0-F1CFE70CBE44}</ProjectGuid>
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)CommonMSBuild.targets" />
<Import Project="$(MSBuildThisFileDirectory)CopyDependencies.targets" />
<ItemGroup>
<None Include="CommonMSBuild.targets" />
<None Include="CopyDependencies.targets" />
</ItemGroup>
</Project>
29 changes: 29 additions & 0 deletions build/CopyDependencies/CopyDependencies.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project>
<Import Project="..\..\src\EmbeddedSonarAnalyzer.props" />

<Target Name="Build">
<CallTarget Targets="ClearDirs" />
<CallTarget Targets="CopyJars" />
</Target>

<PropertyGroup>
<JarDownloadDir>$(LOCALAPPDATA)\SLVS_Build_DownloadedJars</JarDownloadDir>
<EmbeddedJarDir>..\..\src\Integration.Vsix\DownloadedJars</EmbeddedJarDir>
</PropertyGroup>


<Target Name="ClearDirs">
<RemoveDir Directories="$(EmbeddedJarDir)" />
</Target>

<Target Name="CopyJars">
<ItemGroup>
<SourceJars Include="$(JarDownloadDir)\sonar-cfamily-plugin-$(EmbeddedSonarCFamilyAnalyzerVersion).jar" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we somehow centralize the list of dependencies between this and DownloadDependencies task? Currently, if we ever add another analyzer, we would need to modify these 2 targets + EmbeddedSonarAnalyzer.props file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add another ticket for this and we can tackle it if we have time in this sprint or we can handle it in a hardening sprint.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this fail if it can't find any of those files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and I believe it's desired behaviour.

<SourceJars Include="$(JarDownloadDir)\sonar-csharp-plugin-$(EmbeddedSonarAnalyzerVersion).jar" />
<SourceJars Include="$(JarDownloadDir)\sonar-vbnet-plugin-$(EmbeddedSonarAnalyzerVersion).jar" />
<SourceJars Include="$(JarDownloadDir)\sonar-javascript-plugin-$(EmbeddedSonarJSAnalyzerVersion).jar" />
<SourceJars Include="$(JarDownloadDir)\sonar-text-plugin-$(EmbeddedSonarSecretsJarVersion).jar" />
</ItemGroup>
<Copy SourceFiles ="@(SourceJars)" DestinationFolder="$(EmbeddedJarDir)" />
</Target>
</Project>
9 changes: 8 additions & 1 deletion src/Integration.Vsix/Integration.Vsix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
<IncludeInVSIX>true</IncludeInVSIX>
<Link>THIRD-PARTY-NOTICES</Link>
</Content>
</ItemGroup>

<ItemGroup Label="Sloop Dependencies">
<Content Include="$(MSBuildThisFileDirectory)$(JarsFolderName)\*.jar">
<IncludeInVSIX>True</IncludeInVSIX>
<VSIXSubPath>$(JarsFolderName)</VSIXSubPath>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this somehow related?

[ProvideBindingPath(SubPath = "secrets")]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how these can be related. The one you referred is about loading assemblies, we are not interested in that here.

</Content>
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -388,6 +394,7 @@
<PluginUrl>https://binaries.sonarsource.com/CommercialDistribution/sonar-cfamily-plugin/sonar-cfamily-plugin-$(EmbeddedSonarCFamilyAnalyzerVersion).jar</PluginUrl>

<CFamilyFolderName>lib</CFamilyFolderName>
<JarsFolderName>DownloadedJars</JarsFolderName>

<!-- Folder the embedded files should be copied to. This folder should be excluded from source code control. -->
<CFamilyTargetDirectory>$(MSBuildThisFileDirectory)$(CFamilyFolderName)</CFamilyTargetDirectory>
Expand Down Expand Up @@ -565,5 +572,5 @@

<WriteLinesToFile File="$(BaselineWithStrongNames)" Overwrite="true" WriteOnlyWhenDifferent="true" Encoding="UTF-8" Lines="$(NewSignedBaseLineText)" />
</Target>

</Project>
3 changes: 3 additions & 0 deletions src/Integration.Vsix/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,9 @@
"Microsoft.VisualStudio.Interop": "17.0.31902.203"
}
},
"copydependencies": {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it lowercase?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea it's auto generated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some other stuff is also lowercase (e.g. "sonarqube.client"). Since it doesn't affect anything other than cosmetics on an auto-generated file I don't consider it as a problem.

"type": "Project"
},
"SonarLint.VisualStudio.CFamily": {
"type": "Project",
"dependencies": {
Expand Down
Loading