Skip to content

Commit

Permalink
refactor: Move Go package managers to their own plugin project
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Oct 31, 2023
1 parent b330f35 commit 90f9993
Show file tree
Hide file tree
Showing 58 changed files with 92 additions and 49 deletions.
26 changes: 0 additions & 26 deletions analyzer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@
* License-Filename: LICENSE
*/

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

plugins {
// Apply core plugins.
`java-test-fixtures`

// Apply precompiled plugins.
id("ort-library-conventions")

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

dependencies {
Expand All @@ -46,18 +41,10 @@ dependencies {
// container automatically. They are required on the classpath for Maven dependency resolution to work.
implementation(libs.bundles.mavenResolver)

implementation(libs.bundles.kotlinxSerialization)
implementation(libs.kotlinxCoroutines)
implementation(libs.log4jApi)
implementation(libs.semver4j)

implementation(libs.toml4j)
constraints {
implementation("com.google.code.gson:gson:2.10.1") {
because("Earlier versions have vulnerabilities.")
}
}

funTestImplementation(platform(project(":plugins:package-managers")))

// Only the Java plugin's built-in "test" source set automatically depends on the test fixtures.
Expand All @@ -70,16 +57,3 @@ dependencies {

testImplementation(libs.mockk)
}

// Must not opt-in for "compileTestFixturesKotlin" as it does not have kotlinx-serialization in the classpath.
listOf("compileKotlin", "compileTestKotlin").forEach {
tasks.named<KotlinCompile>(it) {
val customCompilerArgs = listOf(
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi"
)

compilerOptions {
freeCompilerArgs.addAll(customCompilerArgs)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
org.ossreviewtoolkit.analyzer.managers.GoDep$Factory
org.ossreviewtoolkit.analyzer.managers.GoMod$Factory
org.ossreviewtoolkit.analyzer.managers.Maven$Factory
org.ossreviewtoolkit.analyzer.managers.Sbt$Factory
64 changes: 64 additions & 0 deletions plugins/package-managers/go/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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

plugins {
// Apply precompiled plugins.
id("ort-library-conventions")

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

dependencies {
api(project(":analyzer"))
api(project(":model"))
api(project(":utils:common-utils")) {
because("This is a CommandLineTool.")
}

api(libs.semver4j) {
because("This is a CommandLineTool.")
}

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

implementation(libs.bundles.kotlinxSerialization)
implementation(libs.toml4j)
constraints {
implementation("com.google.code.gson:gson:2.10.1") {
because("Earlier versions have vulnerabilities.")
}
}

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

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

compilerOptions {
freeCompilerArgs.addAll(customCompilerArgs)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "GoDep::github.com/oss-review-toolkit/ort/analyzer/src/funtest/assets/projects/synthetic/godep/glide:<REPLACE_REVISION>"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/godep/glide/glide.yaml"
id: "GoDep::github.com/oss-review-toolkit/ort/plugins/package-managers/go/src/funtest/assets/projects/synthetic/godep/glide:<REPLACE_REVISION>"
definition_file_path: "plugins/package-managers/go/src/funTest/assets/projects/synthetic/godep/glide/glide.yaml"
declared_licenses: []
declared_licenses_processed: {}
vcs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "GoDep::github.com/oss-review-toolkit/ort/analyzer/src/funtest/assets/projects/synthetic/godep/lockfile:<REPLACE_REVISION>"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/godep/lockfile/Gopkg.toml"
id: "GoDep::github.com/oss-review-toolkit/ort/plugins/package-managers/go/src/funtest/assets/projects/synthetic/godep/lockfile:<REPLACE_REVISION>"
definition_file_path: "plugins/package-managers/go/src/funTest/assets/projects/synthetic/godep/lockfile/Gopkg.toml"
declared_licenses: []
declared_licenses_processed: {}
vcs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "GoDep::github.com/oss-review-toolkit/ort/analyzer/src/funtest/assets/projects/synthetic/godep/godeps/godeps:<REPLACE_REVISION>"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/godep/godeps/Godeps/Godeps.json"
id: "GoDep::github.com/oss-review-toolkit/ort/plugins/package-managers/go/src/funtest/assets/projects/synthetic/godep/godeps/godeps:<REPLACE_REVISION>"
definition_file_path: "plugins/package-managers/go/src/funTest/assets/projects/synthetic/godep/godeps/Godeps/Godeps.json"
declared_licenses: []
declared_licenses_processed: {}
vcs:
Expand All @@ -13,7 +13,7 @@ project:
type: "Git"
url: "<REPLACE_URL_PROCESSED>"
revision: "<REPLACE_REVISION>"
path: "analyzer/src/funTest/assets/projects/synthetic/godep/godeps"
path: "plugins/package-managers/go/src/funTest/assets/projects/synthetic/godep/godeps"
homepage_url: ""
scopes:
- name: "default"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "GoMod::gomod_dangling_embed:<REPLACE_REVISION>"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed/go.mod"
definition_file_path: "plugins/package-managers/go/src/funTest/assets/projects/synthetic/gomod-dangling-embed/go.mod"
declared_licenses: []
declared_licenses_processed: {}
vcs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "GoMod::github.com/oss-review-toolkit/ort/gomod-workspaces:<REPLACE_REVISION>"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/gomod-workspaces/go.mod"
definition_file_path: "plugins/package-managers/go/src/funTest/assets/projects/synthetic/gomod-workspaces/go.mod"
declared_licenses: []
declared_licenses_processed: {}
vcs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "GoMod::github.com/oss-review-toolkit/ort/gomod-workspaces/other-module:<REPLACE_REVISION>"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/gomod-workspaces/other-module/go.mod"
definition_file_path: "plugins/package-managers/go/src/funTest/assets/projects/synthetic/gomod-workspaces/other-module/go.mod"
declared_licenses: []
declared_licenses_processed: {}
vcs:
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.go

import io.kotest.core.spec.style.WordSpec
import io.kotest.matchers.collections.beEmpty
Expand All @@ -29,6 +29,8 @@ import io.kotest.matchers.string.haveSubstring

import java.io.File

import org.ossreviewtoolkit.analyzer.managers.create
import org.ossreviewtoolkit.analyzer.managers.resolveSingleProject
import org.ossreviewtoolkit.model.Identifier
import org.ossreviewtoolkit.model.Project
import org.ossreviewtoolkit.model.VcsInfo
Expand Down Expand Up @@ -56,7 +58,7 @@ class GoDepFunTest : WordSpec({
project.id shouldBe
Identifier("GoDep::src/funTest/assets/projects/synthetic/godep/no-lockfile/Gopkg.toml:")
project.definitionFilePath shouldBe
"analyzer/src/funTest/assets/projects/synthetic/godep/no-lockfile/Gopkg.toml"
"plugins/package-managers/go/src/funTest/assets/projects/synthetic/godep/no-lockfile/Gopkg.toml"
packages should beEmpty()
issues shouldHaveSize 1
issues.first().message should haveSubstring("IllegalArgumentException: No lockfile found in")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
* License-Filename: LICENSE
*/

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

import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.should

import java.io.File

import org.ossreviewtoolkit.analyzer.managers.collateMultipleProjects
import org.ossreviewtoolkit.analyzer.managers.create
import org.ossreviewtoolkit.analyzer.managers.resolveSingleProject
import org.ossreviewtoolkit.downloader.VersionControlSystem
import org.ossreviewtoolkit.model.toYaml
import org.ossreviewtoolkit.utils.test.getAssetFile
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.go

import com.moandjiezana.toml.Toml

Expand All @@ -32,7 +32,6 @@ import org.apache.logging.log4j.kotlin.logger

import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory
import org.ossreviewtoolkit.analyzer.PackageManager
import org.ossreviewtoolkit.analyzer.managers.utils.normalizeModuleVersion
import org.ossreviewtoolkit.downloader.VcsHost
import org.ossreviewtoolkit.downloader.VersionControlSystem
import org.ossreviewtoolkit.model.Identifier
Expand All @@ -50,6 +49,7 @@ import org.ossreviewtoolkit.model.config.AnalyzerConfiguration
import org.ossreviewtoolkit.model.config.RepositoryConfiguration
import org.ossreviewtoolkit.model.createAndLogIssue
import org.ossreviewtoolkit.model.orEmpty
import org.ossreviewtoolkit.plugins.packagemanagers.go.utils.normalizeModuleVersion
import org.ossreviewtoolkit.utils.common.CommandLineTool
import org.ossreviewtoolkit.utils.common.ProcessCapture
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.go

import java.io.File

Expand All @@ -31,8 +31,6 @@ import org.apache.logging.log4j.kotlin.logger

import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory
import org.ossreviewtoolkit.analyzer.PackageManager
import org.ossreviewtoolkit.analyzer.managers.utils.Graph
import org.ossreviewtoolkit.analyzer.managers.utils.normalizeModuleVersion
import org.ossreviewtoolkit.downloader.VersionControlSystem
import org.ossreviewtoolkit.model.Hash
import org.ossreviewtoolkit.model.Identifier
Expand All @@ -48,6 +46,8 @@ import org.ossreviewtoolkit.model.VcsType
import org.ossreviewtoolkit.model.config.AnalyzerConfiguration
import org.ossreviewtoolkit.model.config.RepositoryConfiguration
import org.ossreviewtoolkit.model.orEmpty
import org.ossreviewtoolkit.plugins.packagemanagers.go.utils.Graph
import org.ossreviewtoolkit.plugins.packagemanagers.go.utils.normalizeModuleVersion
import org.ossreviewtoolkit.utils.common.CommandLineTool
import org.ossreviewtoolkit.utils.common.Os
import org.ossreviewtoolkit.utils.common.splitOnWhitespace
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.go.utils

/**
* Return the given [moduleVersion] normalized to a Semver compliant version. The `v` prefix gets stripped and
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.go.utils

import java.util.LinkedList

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.ossreviewtoolkit.plugins.packagemanagers.go.GoDep$Factory
org.ossreviewtoolkit.plugins.packagemanagers.go.GoMod$Factory
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.go

import io.kotest.core.spec.style.WordSpec
import io.kotest.matchers.collections.beEmpty
Expand Down

0 comments on commit 90f9993

Please sign in to comment.