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

Move the Unmanaged package manager to its own plugin project #6797

Merged
merged 2 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions analyzer/src/main/kotlin/Analyzer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import kotlinx.coroutines.withContext
import org.apache.logging.log4j.kotlin.Logging

import org.ossreviewtoolkit.analyzer.PackageManager.Companion.excludes
import org.ossreviewtoolkit.analyzer.managers.Unmanaged
import org.ossreviewtoolkit.downloader.VersionControlSystem
import org.ossreviewtoolkit.model.AnalyzerResult
import org.ossreviewtoolkit.model.AnalyzerRun
Expand Down Expand Up @@ -109,7 +108,8 @@ class Analyzer(private val config: AnalyzerConfiguration, private val labels: Ma
}

if (!hasOnlyManagedDirs) {
distinctPackageManagers.find { it is Unmanaged.Factory }
val unmanagedPackageManagerFactory = PackageManager.ALL["Unmanaged"]
Copy link
Member

@fviernau fviernau Apr 3, 2023

Choose a reason for hiding this comment

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

Oh, I recall that the way we associate scan results with definition files / projects relies on the assumption that the Unmanaged package manager is present. If that doesn't hold, then detected licenses may get discarded silently.

This can be considered out of scope here, but should we do something about it?
(A first idea would be to disallow disabling it)

Copy link
Member Author

@sschuberth sschuberth Apr 3, 2023

Choose a reason for hiding this comment

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

Oh, I recall that the way we associate scan results with definition files / projects relies on the assumption that the Unmanaged package manager is present.

Good point. That somewhat relates to #5365 (comment).

A first idea would be to disallow disabling it

I think that's a good idea. We should probably ensure that

  • it's always present on the classpath,
  • it must not be explicitly disabled,
  • it must not be implicitly disabled by only enabling other package managers.

I'll probably make a follow-up PR.

distinctPackageManagers.find { it == unmanagedPackageManagerFactory }
?.create(absoluteProjectPath, config, repositoryConfiguration)
?.run { managedFiles[this] = listOf(absoluteProjectPath) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ org.ossreviewtoolkit.analyzer.managers.Npm$Factory
org.ossreviewtoolkit.analyzer.managers.NuGet$Factory
org.ossreviewtoolkit.analyzer.managers.Pnpm$Factory
org.ossreviewtoolkit.analyzer.managers.Sbt$Factory
org.ossreviewtoolkit.analyzer.managers.Unmanaged$Factory
org.ossreviewtoolkit.analyzer.managers.Yarn$Factory
org.ossreviewtoolkit.analyzer.managers.Yarn2$Factory
4 changes: 2 additions & 2 deletions cli/src/funTest/kotlin/PackageManagerFunTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import java.io.File

import org.ossreviewtoolkit.analyzer.ManagedProjectFiles
import org.ossreviewtoolkit.analyzer.PackageManager
import org.ossreviewtoolkit.analyzer.managers.*
import org.ossreviewtoolkit.model.config.Excludes
import org.ossreviewtoolkit.model.config.PathExclude
import org.ossreviewtoolkit.model.config.PathExcludeReason
Expand Down Expand Up @@ -87,8 +86,9 @@ class PackageManagerFunTest : WordSpec({

// The test project contains at least one file per package manager, so the result should also contain an
// entry for each package manager.
val unmanagedPackageManagerFactory = PackageManager.ALL["Unmanaged"]
managedFiles.keys shouldContainExactlyInAnyOrder PackageManager.ENABLED_BY_DEFAULT.filterNot {
it is Unmanaged.Factory
it == unmanagedPackageManagerFactory
}

val managedFilesByName = managedFiles.groupByName(projectDir)
Expand Down
1 change: 1 addition & 0 deletions plugins/package-managers/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies {
api(project(":plugins:package-managers:python-package-manager"))
api(project(":plugins:package-managers:spdx-package-manager"))
api(project(":plugins:package-managers:stack-package-manager"))
api(project(":plugins:package-managers:unmanaged-package-manager"))
}

configure<PublishingExtension> {
Expand Down
35 changes: 35 additions & 0 deletions plugins/package-managers/unmanaged/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2023 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)
*
* 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
*
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
* License-Filename: LICENSE
*/

plugins {
// Apply core plugins.
`java-library`
}

dependencies {
api(project(":analyzer"))
api(project(":model"))

implementation(project(":downloader"))
implementation(project(":utils:ort-utils"))

implementation(libs.log4jApiKotlin)

funTestImplementation(testFixtures(project(":analyzer")))
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* License-Filename: LICENSE
*/

package org.ossreviewtoolkit.analyzer.managers
package org.ossreviewtoolkit.plugins.packagemanagers.unmanaged

import java.io.File

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.ossreviewtoolkit.plugins.packagemanagers.unmanaged.Unmanaged$Factory
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ include(":plugins:package-managers:pub")
include(":plugins:package-managers:python")
include(":plugins:package-managers:spdx")
include(":plugins:package-managers:stack")
include(":plugins:package-managers:unmanaged")
include(":reporter")
include(":reporter-web-app")
include(":scanner")
Expand Down Expand Up @@ -94,6 +95,7 @@ project(":plugins:package-managers:pub").name = "pub-package-manager"
project(":plugins:package-managers:python").name = "python-package-manager"
project(":plugins:package-managers:spdx").name = "spdx-package-manager"
project(":plugins:package-managers:stack").name = "stack-package-manager"
project(":plugins:package-managers:unmanaged").name = "unmanaged-package-manager"

project(":utils:common").name = "common-utils"
project(":utils:ort").name = "ort-utils"
Expand Down