Skip to content

Commit

Permalink
build(Gradle): Move the Python package managers to their own plugin p…
Browse files Browse the repository at this point in the history
…roject

This continues the effort started in be4bb69 to move plugin
implementations, here for the Python package managers. See [1] for more
context.

[1]: #6602

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
  • Loading branch information
sschuberth committed Mar 9, 2023
1 parent 5bc44fa commit 5c3ed31
Show file tree
Hide file tree
Showing 49 changed files with 80 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "example-python-flask"]
path = analyzer/src/funTest/assets/projects/external/example-python-flask
path = plugins/package-managers/python/src/funTest/assets/projects/external/example-python-flask
url = https://github.com/deis/example-python-flask.git
ignore = untracked
[submodule "spdx-tools-python"]
path = analyzer/src/funTest/assets/projects/external/spdx-tools-python
path = plugins/package-managers/python/src/funTest/assets/projects/external/spdx-tools-python
url = https://github.com/spdx/tools-python.git
ignore = untracked
[submodule "quickcheck-state-machine"]
Expand Down
17 changes: 0 additions & 17 deletions analyzer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@
* License-Filename: LICENSE
*/

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

@Suppress("DSL_SCOPE_VIOLATION") // See https://youtrack.jetbrains.com/issue/KTIJ-19369.
plugins {
// Apply core plugins.
`java-library`
`java-test-fixtures`

// Apply third-party plugins.
alias(libs.plugins.kotlinSerialization)
}

repositories {
Expand Down Expand Up @@ -58,7 +52,6 @@ dependencies {
implementation(libs.jacksonModuleKotlin)
implementation(libs.jruby)
implementation(libs.kotlinxCoroutines)
implementation(libs.kotlinxSerialization)
implementation(libs.semver4j)

implementation(libs.toml4j)
Expand All @@ -76,13 +69,3 @@ dependencies {
testFixturesImplementation(libs.kotestAssertionsCore)
testFixturesImplementation(libs.kotestRunnerJunit5)
}

tasks.withType<KotlinCompile>().configureEach {
val customCompilerArgs = listOf(
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi"
)

kotlinOptions {
freeCompilerArgs = freeCompilerArgs + customCompilerArgs
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ org.ossreviewtoolkit.analyzer.managers.Gradle$Factory
org.ossreviewtoolkit.analyzer.managers.Maven$Factory
org.ossreviewtoolkit.analyzer.managers.Npm$Factory
org.ossreviewtoolkit.analyzer.managers.NuGet$Factory
org.ossreviewtoolkit.analyzer.managers.Pip$Factory
org.ossreviewtoolkit.analyzer.managers.Pipenv$Factory
org.ossreviewtoolkit.analyzer.managers.Pnpm$Factory
org.ossreviewtoolkit.analyzer.managers.Poetry$Factory
org.ossreviewtoolkit.analyzer.managers.Pub$Factory
org.ossreviewtoolkit.analyzer.managers.Sbt$Factory
org.ossreviewtoolkit.analyzer.managers.SpdxDocumentFile$Factory
Expand Down
4 changes: 2 additions & 2 deletions downloader/src/funTest/kotlin/vcs/GitWorkingTreeFunTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ class GitWorkingTreeFunTest : StringSpec({
"Git correctly lists submodules" {
val expectedSubmodules = listOf(
"analyzer/src/funTest/assets/projects/external/dart-http",
"analyzer/src/funTest/assets/projects/external/example-python-flask",
"analyzer/src/funTest/assets/projects/external/quickcheck-state-machine",
"analyzer/src/funTest/assets/projects/external/sbt-multi-project-example",
"analyzer/src/funTest/assets/projects/external/spdx-tools-python"
"plugins/package-managers/python/src/funTest/assets/projects/external/example-python-flask",
"plugins/package-managers/python/src/funTest/assets/projects/external/spdx-tools-python"
).associateWith { VersionControlSystem.getPathInfo(File("../$it")) }

val workingTree = git.getWorkingTree(File(".."))
Expand Down
2 changes: 1 addition & 1 deletion plugins/package-managers/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ javaPlatform {
}

dependencies {
// TODO: Add plugin projects as API dependencies here.
api(project(":plugins:package-managers:python-package-manager"))
}

configure<PublishingExtension> {
Expand Down
49 changes: 49 additions & 0 deletions plugins/package-managers/python/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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
*/

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

@Suppress("DSL_SCOPE_VIOLATION") // See https://youtrack.jetbrains.com/issue/KTIJ-19369.
plugins {
// Apply core plugins.
`java-library`

// Apply third-party plugins.
alias(libs.plugins.kotlinSerialization)
}

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

implementation(project(":downloader"))

implementation(libs.kotlinxSerialization)

funTestImplementation(testFixtures(project(":analyzer")))
}

tasks.withType<KotlinCompile>().configureEach {
val customCompilerArgs = listOf(
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi"
)

kotlinOptions {
freeCompilerArgs = freeCompilerArgs + customCompilerArgs
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "PIP::Example-App-with-requirements-pip:2.4.0"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/pip/requirements.txt"
definition_file_path: "plugins/package-managers/python/src/funTest/assets/projects/synthetic/pip/requirements.txt"
declared_licenses:
- "MIT License"
declared_licenses_processed:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "PIP::pip-python3:<REPLACE_REVISION>"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/pip-python3/requirements.txt"
definition_file_path: "plugins/package-managers/python/src/funTest/assets/projects/synthetic/pip-python3/requirements.txt"
declared_licenses: []
declared_licenses_processed: {}
vcs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "Pipenv::pipenv-from-pipenv:<REPLACE_REVISION>"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/pipenv/requirements-from-pipenv.txt"
definition_file_path: "plugins/package-managers/python/src/funTest/assets/projects/synthetic/pipenv/requirements-from-pipenv.txt"
declared_licenses: []
declared_licenses_processed: {}
vcs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "Pipenv::pipenv-python3-from-pipenv:<REPLACE_REVISION>"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/pipenv-python3/requirements-from-pipenv.txt"
definition_file_path: "plugins/package-managers/python/src/funTest/assets/projects/synthetic/pipenv-python3/requirements-from-pipenv.txt"
declared_licenses: []
declared_licenses_processed: {}
vcs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "Poetry::poetry-from-poetry:<REPLACE_REVISION>"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/poetry/requirements-from-poetry.txt"
definition_file_path: "plugins/package-managers/python/src/funTest/assets/projects/synthetic/poetry/requirements-from-poetry.txt"
declared_licenses: []
declared_licenses_processed: {}
vcs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "PIP::python-inspector:<REPLACE_REVISION>"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/python-inspector/requirements.txt"
definition_file_path: "plugins/package-managers/python/src/funTest/assets/projects/synthetic/python-inspector/requirements.txt"
declared_licenses: []
declared_licenses_processed: {}
vcs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
* License-Filename: LICENSE
*/

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

import io.kotest.core.spec.style.WordSpec
import io.kotest.matchers.collections.beEmpty
import io.kotest.matchers.should
import io.kotest.matchers.shouldBe

import org.ossreviewtoolkit.analyzer.managers.resolveSingleProject
import org.ossreviewtoolkit.downloader.VersionControlSystem
import org.ossreviewtoolkit.model.config.AnalyzerConfiguration
import org.ossreviewtoolkit.model.config.PackageManagerConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
* License-Filename: LICENSE
*/

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

import io.kotest.core.spec.style.WordSpec
import io.kotest.matchers.shouldBe

import org.ossreviewtoolkit.analyzer.managers.resolveSingleProject
import org.ossreviewtoolkit.downloader.VersionControlSystem
import org.ossreviewtoolkit.model.config.AnalyzerConfiguration
import org.ossreviewtoolkit.model.config.RepositoryConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
* License-Filename: LICENSE
*/

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

import io.kotest.core.spec.style.WordSpec
import io.kotest.matchers.shouldBe

import org.ossreviewtoolkit.analyzer.managers.resolveSingleProject
import org.ossreviewtoolkit.downloader.VersionControlSystem
import org.ossreviewtoolkit.model.config.AnalyzerConfiguration
import org.ossreviewtoolkit.model.config.RepositoryConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* License-Filename: LICENSE
*/

package org.ossreviewtoolkit.analyzer.managers.utils
package org.ossreviewtoolkit.plugins.packagemanagers.python.utils

import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.collections.haveSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
* License-Filename: LICENSE
*/

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

import java.io.File

import org.apache.logging.log4j.kotlin.Logging

import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory
import org.ossreviewtoolkit.analyzer.PackageManager
import org.ossreviewtoolkit.analyzer.managers.utils.PythonInspector
import org.ossreviewtoolkit.analyzer.managers.utils.toOrtPackages
import org.ossreviewtoolkit.analyzer.managers.utils.toOrtProject
import org.ossreviewtoolkit.model.ProjectAnalyzerResult
import org.ossreviewtoolkit.model.config.AnalyzerConfiguration
import org.ossreviewtoolkit.model.config.PackageManagerConfiguration
import org.ossreviewtoolkit.model.config.RepositoryConfiguration
import org.ossreviewtoolkit.plugins.packagemanagers.python.utils.PythonInspector
import org.ossreviewtoolkit.plugins.packagemanagers.python.utils.toOrtPackages
import org.ossreviewtoolkit.plugins.packagemanagers.python.utils.toOrtProject
import org.ossreviewtoolkit.utils.common.CommandLineTool
import org.ossreviewtoolkit.utils.common.Os
import org.ossreviewtoolkit.utils.common.collectMessages
Expand Down
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.python

import java.io.File

Expand Down
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.python

import java.io.File

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* License-Filename: LICENSE
*/

package org.ossreviewtoolkit.analyzer.managers.utils
package org.ossreviewtoolkit.plugins.packagemanagers.python.utils

import java.io.File
import java.util.SortedSet
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org.ossreviewtoolkit.plugins.packagemanagers.python.Pip$Factory
org.ossreviewtoolkit.plugins.packagemanagers.python.Pipenv$Factory
org.ossreviewtoolkit.plugins.packagemanagers.python.Poetry$Factory
3 changes: 3 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ include(":plugins:package-curation-providers:file")
include(":plugins:package-curation-providers:ort-config")
include(":plugins:package-curation-providers:sw360")
include(":plugins:package-managers")
include(":plugins:package-managers:python")
include(":reporter")
include(":reporter-web-app")
include(":scanner")
Expand All @@ -69,6 +70,8 @@ project(":plugins:package-curation-providers:file").name = "file-package-curatio
project(":plugins:package-curation-providers:ort-config").name = "ort-config-package-curation-provider"
project(":plugins:package-curation-providers:sw360").name = "sw360-package-curation-provider"

project(":plugins:package-managers:python").name = "python-package-manager"

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

0 comments on commit 5c3ed31

Please sign in to comment.