-
Notifications
You must be signed in to change notification settings - Fork 10
fix: Package name collisions #22
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
Changes from 8 commits
584bc50
824bb84
0ed3c1d
8f34bab
58e1784
0e460c8
d8b1e8b
4508c2e
b25f102
8726b66
036f654
35ebfdf
8381fda
c62fc33
b0448a1
d9727c0
8839018
f6ab3b4
2abca41
6bfc372
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,6 +18,12 @@ export interface Options { | |
| */ | ||
| jsii?: JsiiOutputOptions; | ||
|
|
||
| /** | ||
| * Package name | ||
| * @default - hash of the basepath to the module | ||
| */ | ||
| packageName?: string | ||
|
Contributor
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 am not sure that's the correct name for this because users don't really interact with this value after code generation. Maybe Docstring help needs to indicate that it should be project-unique. |
||
|
|
||
| /** | ||
| * Produce python code. | ||
| * @default - python is not generated | ||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,7 @@ public final class $Module extends JsiiModule { | |
| private final Map<String, Class<?>> cache = new HashMap<>(); | ||
|
|
||
| public $Module() { | ||
| super(\\"generated\\", \\"0.0.0\\", $Module.class, \\"generated@0.0.0.jsii.tgz\\"); | ||
| super(\\"javapackage\\", \\"0.0.0\\", $Module.class, \\"javapackage@0.0.0.jsii.tgz\\"); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -73,7 +73,7 @@ public final class $Module extends JsiiModule { | |
| "src/main/java/hello/world/Hello.java": "package hello.world; | ||
|
|
||
|
|
||
| @software.amazon.jsii.Jsii(module = hello.world.$Module.class, fqn = \\"generated.Hello\\") | ||
| @software.amazon.jsii.Jsii(module = hello.world.$Module.class, fqn = \\"javapackage.Hello\\") | ||
| public class Hello extends software.amazon.jsii.JsiiObject { | ||
|
|
||
| protected Hello(final software.amazon.jsii.JsiiObjectRef objRef) { | ||
|
|
@@ -97,7 +97,7 @@ public class Hello extends software.amazon.jsii.JsiiObject { | |
| "src/main/java/hello/world/Operands.java": "package hello.world; | ||
|
|
||
|
|
||
| @software.amazon.jsii.Jsii(module = hello.world.$Module.class, fqn = \\"generated.Operands\\") | ||
| @software.amazon.jsii.Jsii(module = hello.world.$Module.class, fqn = \\"javapackage.Operands\\") | ||
| @software.amazon.jsii.Jsii.Proxy(Operands.Jsii$Proxy.class) | ||
| public interface Operands extends software.amazon.jsii.JsiiSerializable { | ||
|
|
||
|
|
@@ -194,7 +194,7 @@ public interface Operands extends software.amazon.jsii.JsiiSerializable { | |
| data.set(\\"rhs\\", om.valueToTree(this.getRhs())); | ||
|
|
||
| final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); | ||
| struct.set(\\"fqn\\", om.valueToTree(\\"generated.Operands\\")); | ||
| struct.set(\\"fqn\\", om.valueToTree(\\"javapackage.Operands\\")); | ||
| struct.set(\\"data\\", data); | ||
|
|
||
| final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); | ||
|
|
@@ -223,9 +223,11 @@ public interface Operands extends software.amazon.jsii.JsiiSerializable { | |
| } | ||
| } | ||
| ", | ||
| "src/main/resources/hello/world/$Module.txt": "generated.Hello=hello.world.Hello | ||
| generated.Operands=hello.world.Operands | ||
| "src/main/resources/hello/world/$Module.txt": "javapackage.Hello=hello.world.Hello | ||
| javapackage.Operands=hello.world.Operands | ||
| ", | ||
| "src/main/resources/hello/world/javapackage@0.0.0.jsii.tgz": "� �ko�H�����K���&@J�Hw�&�B ��ʏ�Yb���5�T��?1��.m�:F����˳��qU�Q5Q�8f��1 IR�R֭T��5��I�\\\\�I@'�R�����x��T��|\\"c������� ���G�\`s��f���*G�騨;���Q�B�� | ||
| _m]֔fU��mKs]�!M}Ь&c��t���t��]�7�Ӛ�e�zXkZc�y�8<M��i� ��H����[��H���=_i%rR�%���4�O�_e��y�7�n�9�xܒx0����\`�CH�Rv��e���!���?� ���O�o϶F�ai����h���+>�L\\\\�!�I}�\\\\;g]�fS�fw���֙A�f���i�K[?���jgs�%�u������Y*�75�VJ�y��6�����}�Em�E���1��[��6���|-���\\\\^��{r����?��ZH{JB�ታE����&?���e�b�*]0T� k��T�Nv�[;d[���'�7/��� ", | ||
| } | ||
| `; | ||
|
|
||
|
|
@@ -237,26 +239,26 @@ Object { | |
| "author", | ||
| ], | ||
| }, | ||
| "description": "generated", | ||
| "fingerprint": "cNtb65kyZQOiBulmzr+bs6dCGdv4uhea1tFTkbRGJTw=", | ||
| "description": "1bc04b5291c26a46d918139138b992d2de976d6851d0893b0476b85bfbdfc6e6", | ||
| "fingerprint": "6oK+Fme17BaQrSRFIR9SO8fcGINzbxpouGPKqn9MAhs=", | ||
| "homepage": "http://generated", | ||
| "jsiiVersion": "1.6.0 (build 248e75b)", | ||
| "jsiiVersion": "1.9.0 (build 5c646d5)", | ||
| "license": "Apache-2.0", | ||
| "name": "generated", | ||
| "name": "1bc04b5291c26a46d918139138b992d2de976d6851d0893b0476b85bfbdfc6e6", | ||
| "repository": Object { | ||
| "type": "git", | ||
| "url": "http://generated", | ||
| }, | ||
| "schema": "jsii/0.10.0", | ||
| "targets": Object { | ||
| "js": Object { | ||
| "npm": "generated", | ||
| "npm": "1bc04b5291c26a46d918139138b992d2de976d6851d0893b0476b85bfbdfc6e6", | ||
| }, | ||
| }, | ||
| "types": Object { | ||
| "generated.Foo": Object { | ||
| "assembly": "generated", | ||
| "fqn": "generated.Foo", | ||
| "1bc04b5291c26a46d918139138b992d2de976d6851d0893b0476b85bfbdfc6e6.Foo": Object { | ||
| "assembly": "1bc04b5291c26a46d918139138b992d2de976d6851d0893b0476b85bfbdfc6e6", | ||
| "fqn": "1bc04b5291c26a46d918139138b992d2de976d6851d0893b0476b85bfbdfc6e6.Foo", | ||
| "initializer": Object {}, | ||
| "kind": "class", | ||
| "locationInModule": Object { | ||
|
|
@@ -300,7 +302,7 @@ import publication | |
| from ._jsii import * | ||
|
|
||
|
|
||
| class Hello(metaclass=jsii.JSIIMeta, jsii_type=\\"generated.Hello\\"): | ||
| class Hello(metaclass=jsii.JSIIMeta, jsii_type=\\"pythonpackage.Hello\\"): | ||
| def __init__(self) -> None: | ||
| jsii.create(Hello, self, []) | ||
|
|
||
|
|
@@ -315,25 +317,29 @@ class Hello(metaclass=jsii.JSIIMeta, jsii_type=\\"generated.Hello\\"): | |
| return jsii.invoke(self, \\"add\\", [ops]) | ||
|
|
||
|
|
||
| @jsii.data_type(jsii_type=\\"generated.Operands\\", jsii_struct_bases=[], name_mapping={'lhs': 'lhs', 'rhs': 'rhs'}) | ||
| class Operands(): | ||
| @jsii.data_type( | ||
| jsii_type=\\"pythonpackage.Operands\\", | ||
| jsii_struct_bases=[], | ||
| name_mapping={\\"lhs\\": \\"lhs\\", \\"rhs\\": \\"rhs\\"}, | ||
| ) | ||
| class Operands: | ||
| def __init__(self, *, lhs: jsii.Number, rhs: jsii.Number) -> None: | ||
| \\"\\"\\" | ||
| :param lhs: - | ||
| :param rhs: - | ||
| \\"\\"\\" | ||
| self._values = { | ||
| 'lhs': lhs, | ||
| 'rhs': rhs, | ||
| \\"lhs\\": lhs, | ||
| \\"rhs\\": rhs, | ||
| } | ||
|
|
||
| @builtins.property | ||
| def lhs(self) -> jsii.Number: | ||
| return self._values.get('lhs') | ||
| return self._values.get(\\"lhs\\") | ||
|
|
||
| @builtins.property | ||
| def rhs(self) -> jsii.Number: | ||
| return self._values.get('rhs') | ||
| return self._values.get(\\"rhs\\") | ||
|
|
||
| def __eq__(self, rhs) -> bool: | ||
| return isinstance(rhs, self.__class__) and rhs._values == self._values | ||
|
|
@@ -342,7 +348,9 @@ class Operands(): | |
| return not (rhs == self) | ||
|
|
||
| def __repr__(self) -> str: | ||
| return 'Operands(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) | ||
| return \\"Operands(%s)\\" % \\", \\".join( | ||
| k + \\"=\\" + repr(v) for k, v in self._values.items() | ||
| ) | ||
|
|
||
|
|
||
| __all__ = [ | ||
|
|
@@ -362,14 +370,29 @@ import jsii | |
| import jsii.compat | ||
| import publication | ||
|
|
||
| __jsii_assembly__ = jsii.JSIIAssembly.load(\\"generated\\", \\"0.0.0\\", __name__[0:-6], \\"generated@0.0.0.jsii.tgz\\") | ||
| __jsii_assembly__ = jsii.JSIIAssembly.load( | ||
| \\"pythonpackage\\", \\"0.0.0\\", __name__[0:-6], \\"pythonpackage@0.0.0.jsii.tgz\\" | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| \\"__jsii_assembly__\\", | ||
| ] | ||
|
|
||
| publication.publish() | ||
| ", | ||
| "my_python_module/submodule/_jsii/pythonpackage@0.0.0.jsii.tgz": "� �ko�H�����K���6��D��� ��� �TE�z����5�T����<]Ҫ���ݙ��Ύ��ih��p.;f��y�$�T(�� | ||
|
Contributor
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. This needs to be filtered out
Contributor
Author
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. Yeah... not really sure why my macbook keeps trying to add them... will try to fix |
||
| y�(��K�,�J�I��(yx��>�3�QP����o�3� j>7]*���fc��#�\`�ql����ȵţ���f@�w4]�_��f��� �z9^w+�tm�3@��{'�\\\\*0����)[��$��}bB� | ||
| %��.����X}!&�S�J1*1k�{.#ܥ��<�b/�X�Sk�����ZHj�����H�0a�V�ǫq��g��!K�1j}�Aoo��RW@ۮ�[����w�Z����H | ||
| �^�qC�l[������u+��Ո����S_2Ji�C8�,2�Q.RĄ8F�Y iEo�H�IuZ���J�Db�� | ||
| r�)vx~4���(V���x���kc��X�maM�! | ||
| ��ź&�V�$i�j���W�4 | ||
| (wcC�m�7���p����^yn�h�~�yh�uCo��O���=Jl�id���:�V�d�JO��+�c��\\"�и�4�S?~R;1O8�{ | ||
| ��{e'���Zyԅ5N�#�B���[�G8b�>�tk�+��z�m����&��ܻ?���Z���)�}n�$�p�}3]���M��+�3��;��D>0��Z�T�W�����Y�:�f�Dy�{?�w�j�<�ޜ��E�WU�,�Pn;t���d<^��ż�]�+��7�k��� ���$��̕>ƈg | ||
| �S~��<�rv$�ww�-ё�]�j���%,ޝf��qy'� S��t���7!^��1o� | ||
| y��O�@��,�e�}4�4t������4���!0ק�4σ�qӽ<_�'0�ρ(����uNu��R�Me8hε~�W����ڴ��̂1��r&�����|/�UzR�B�J���ed�-��~дt��k�4 | ||
| �����'KL�e5*�n�p�՜wnj���Y����tn���M��W�5\`�qyц��J�����ܴ��}���p�u � �x-���sX;ߠ��&��w%�6��S�:�w&�f'P�괧Ơ9��R�B_�cOW���V?��z�������=N�B�мUnF_���a�5��~���z����^7�W��}���^�t�\`دM@�ו@k�Jj�(������$�)��dl�Fe����V��(�]�{L�ؔ���n��zm2��S�(�s7u�;����N��ڽ@m$rR�%������PPd���SP y��;�����㆜� ��t��/�B���z4�&�-���/���/����3�������,m=�\\"m�8���17� | ||
| ;FR�>���׳y�As���IKаS����� 4V������;v���̓Z2Iɼ*� | ||
| �a���?��6��aLϷ1�ŏ��C�_x�c��yH ���g@\\\\S i�AH>��aM�f��P�����&��c�*M00T}�~'��w���C^�^��'�/�~9M ", | ||
| "my_python_module/submodule/py.typed": " | ||
| ", | ||
| } | ||
|
|
||
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 am assuming java would have a similar issue. I wonder if the correct behavior here is to validate per the language constraints and throw an error so the user will be required to pass in a valid name for the module.
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.
Yeah! We can do some validation instead of just correcting it. I'd be worried in some cases though where the user isn't the one explicitly choosing what this value is. In some use-cases, like CRDs in cdk8s from the internet, they might not control the group.
Would we then add this correction behavior to all consumers?
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.
Maybe we can do a
warnthat lets the user know we're correcting it?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 think the consumers of this library (eg cdk8s) should do the name mangling if needed. The constraints should be well documented
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.
Ok! I will add validation here then