-
Notifications
You must be signed in to change notification settings - Fork 213
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
Add manifest files generated from ksp into final jar #1094
Changes from all commits
2e40d03
25d22aa
32ea60b
6590765
0ace303
2a488ab
ab6cb1a
a5df20c
0ebc3cd
d48cb0c
d7405ab
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 |
---|---|---|
|
@@ -18,4 +18,4 @@ abstract static class Builder { | |
|
||
abstract CoffeeAppJavaModel build(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package coffee; | ||
|
||
import com.google.auto.service.AutoService; | ||
|
||
@AutoService(Object.class) | ||
public class CoffeeAppService { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ package io.bazel.kotlin.builder.utils.jars | |
|
||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
import java.nio.file.StandardCopyOption | ||
import java.util.jar.JarFile | ||
|
||
open class JarExtractor protected constructor( | ||
|
@@ -42,7 +43,7 @@ open class JarExtractor protected constructor( | |
Files.createDirectories(target) | ||
else -> jar.getInputStream(entry).use { | ||
Files.createDirectories(target.parent) | ||
Files.copy(it, target) | ||
Files.copy(it, target, StandardCopyOption.REPLACE_EXISTING) | ||
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. What happened here to need the 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. since we are using the same generated classes directory for all the jar creation processes during 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. I think one common file that would be a duplicate is |
||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
load("//kotlin:core.bzl", "kt_ksp_plugin") | ||
load("//kotlin:jvm.bzl", "kt_jvm_library") | ||
|
||
# Copyright 2018 The Bazel Authors. All rights reserved. | ||
# | ||
# 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 | ||
# | ||
# http://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. | ||
package(default_visibility = ["//visibility:private"]) | ||
|
||
kt_ksp_plugin( | ||
name = "autoservice", | ||
processor_class = "dev.zacsweers.autoservice.ksp.AutoServiceSymbolProcessor$Provider", | ||
deps = [ | ||
"@kotlin_rules_maven//:dev_zacsweers_autoservice_auto_service_ksp", | ||
], | ||
) | ||
|
||
kt_ksp_plugin( | ||
name = "moshi", | ||
processor_class = "com.squareup.moshi.kotlin.codegen.ksp.JsonClassSymbolProcessorProvider", | ||
deps = [ | ||
"@kotlin_rules_maven//:com_squareup_moshi_moshi", | ||
"@kotlin_rules_maven//:com_squareup_moshi_moshi_kotlin", | ||
"@kotlin_rules_maven//:com_squareup_moshi_moshi_kotlin_codegen", | ||
], | ||
) | ||
|
||
kt_jvm_library( | ||
name = "moshi_lib", | ||
srcs = ["CoffeeAppModel.kt"], | ||
plugins = [":moshi"], | ||
deps = [ | ||
"@kotlin_rules_maven//:com_squareup_moshi_moshi", | ||
"@kotlin_rules_maven//:com_squareup_moshi_moshi_kotlin", | ||
"@kotlin_rules_maven//:com_squareup_moshi_moshi_kotlin_codegen", | ||
], | ||
) | ||
|
||
kt_jvm_library( | ||
name = "coffee_lib", | ||
srcs = ["CoffeeAppService.java"], | ||
plugins = [":autoservice"], | ||
deps = [ | ||
"@kotlin_rules_maven//:dev_zacsweers_autoservice_auto_service_ksp", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "ksp", | ||
srcs = [ | ||
":coffee_lib.jar", | ||
":moshi_lib.jar", | ||
], | ||
visibility = ["//visibility:public"], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2018 The Bazel Authors. All rights reserved. | ||
* | ||
* 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 | ||
* | ||
* http://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. | ||
*/ | ||
package coffee | ||
|
||
import com.squareup.moshi.Moshi | ||
|
||
class CoffeeApp { | ||
|
||
companion object { | ||
|
||
private val adapter = CoffeeAppModelJsonAdapter(Moshi.Builder().build()) | ||
private val d = AutoValue_CoffeeAppJavaModel.Builder() | ||
.setCoffeeAppModel(CoffeeAppModel("1")) | ||
.build() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2018 The Bazel Authors. All rights reserved. | ||
* | ||
* 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 | ||
* | ||
* http://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. | ||
*/ | ||
package src.test.data.jvm.ksp | ||
Bencodes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import com.squareup.moshi.JsonClass | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class CoffeeAppModel(val id: Int) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2018 The Bazel Authors. All rights reserved. | ||
* | ||
* 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 | ||
* | ||
* http://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. | ||
*/ | ||
package src.test.data.jvm.ksp; | ||
Bencodes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import com.google.auto.service.AutoService; | ||
|
||
@AutoService(Object.class) | ||
public class CoffeeAppService { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not fully aware of the whole compilation process but if we add this logic here, it will also run for jars generated by
kapt
(as it's based on wholeinput.sourceJarsList
). Since the issue for missing manifest files seems to be related toksp
only, could we possibly put this expand logic in a place where it wouldn't affectkapt
generated jars? 💭There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zalewskise I think we actually want this for Kapt as wellsince the meta directory could contain files needed in the final jar. One example that comes to mind is google-auto-service where it spits out information that's needed in the final jar.