rules_jvm_external icon indicating copy to clipboard operation
rules_jvm_external copied to clipboard

Retain comments / licenses in service provider files when merging jars

Open vinnybod opened this issue 1 year ago • 5 comments

I have a situation where I need a license to be on the META-INF/services files in the final jar. The current behavior sorts the lines of the service file, including lines that are just comments, resulting in a jumbled output.

The desired behavior is to preserve the comments/licenses

Examples below and in this repo: https://github.com/vinnybod/bazel_java_example/tree/service-file-issues

For an input of:

 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements. See the NOTICE file distributed with
 # this work for additional information regarding copyright ownership.
 # The ASF licenses this file to You 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.
com.example.ThingProviderImpl

The current output is:

 #
 #    http://www.apache.org/licenses/LICENSE-2.0
 # (the "License"); you may not use this file except in compliance with
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # See the License for the specific language governing permissions and
 # The ASF licenses this file to You under the Apache License, Version 2.0
 # Unless required by applicable law or agreed to in writing, software
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # contributor license agreements. See the NOTICE file distributed with
 # distributed under the License is distributed on an "AS IS" BASIS,
 # limitations under the License.
 # the License. You may obtain a copy of the License at
 # this work for additional information regarding copyright ownership.
com.example.ThingProviderImpl

vinnybod avatar May 01 '24 21:05 vinnybod