-
Notifications
You must be signed in to change notification settings - Fork 352
New plugin API #9002
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
New plugin API #9002
Changes from all commits
54f30ce
29ac2e0
d46f636
e593f94
e26221e
cb31f9c
fb9a6f5
0d3912d
8628934
71bfe29
7455d2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2024 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 precompiled plugins. | ||
id("ort-library-conventions") | ||
id("ort-publication-conventions") | ||
|
||
// Apply third-party plugins. | ||
id("com.google.devtools.ksp") | ||
} | ||
|
||
dependencies { | ||
ksp(project(":plugins:compiler")) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,38 +47,26 @@ | |
companion object { | ||
const val BATCH_REQUEST_MAX_SIZE = 1000 | ||
|
||
val JSON = Json { namingStrategy = JsonNamingStrategy.SnakeCase } | ||
/** The URL of the production server. */ | ||
const val PRODUCTION_SERVER_URL = "https://api.osv.dev" | ||
|
||
/** The URL of the staging server. */ | ||
const val STAGING_SERVER_URL = "https://api-staging.osv.dev" | ||
|
||
/** | ||
* Create a service instance for communicating with the given [server], optionally using a pre-built OkHttp | ||
* [client]. | ||
*/ | ||
fun create(server: Server, client: OkHttpClient? = null): OsvService = create(server.url, client) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, does this removal make the following implementations easier? Because if not, I'd prefer to keep it, and later on refactor it differently, to have functions with the following signatures (and do the same for
Because to me it makes more sense to use the URL constructor only in cases where you want a non-default URL. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, it's not used anywhere and I don't think the OSV advisor which is the only consumer of the library would ever use it. However, the important part is happening in the next commit and moving the URL value to a constant could happen without removing the enum. It just appeared to me that removing unused code along the way would be a good idea. |
||
val JSON = Json { namingStrategy = JsonNamingStrategy.SnakeCase } | ||
|
||
fun create(serverUrl: String? = null, client: OkHttpClient? = null): OsvService { | ||
val converterFactory = JSON.asConverterFactory(contentType = "application/json".toMediaType()) | ||
|
||
return Retrofit.Builder() | ||
.apply { client(client ?: defaultHttpClient()) } | ||
.baseUrl(serverUrl ?: Server.PRODUCTION.url) | ||
.baseUrl(serverUrl ?: PRODUCTION_SERVER_URL) | ||
.addConverterFactory(converterFactory) | ||
.build() | ||
.create(OsvService::class.java) | ||
} | ||
} | ||
|
||
enum class Server(val url: String) { | ||
/** | ||
* The production API server. | ||
*/ | ||
PRODUCTION("https://api.osv.dev"), | ||
|
||
/** | ||
* The staging API server. | ||
*/ | ||
STAGING("https://api-staging.osv.dev") | ||
} | ||
|
||
/** | ||
* Get the vulnerabilities for the package matched by the given [request]. | ||
*/ | ||
|
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.