Make apex-common accessable over shared namespace 2nd gen packages#520
Make apex-common accessable over shared namespace 2nd gen packages#520nwcm wants to merge 6 commits intoapex-enterprise-patterns:masterfrom
Conversation
|
@nwcm how did this go for you?? any gotchas? |
Have validated this with a base 2GP package with extension package with dependency. All working without issue |
daveespo
left a comment
There was a problem hiding this comment.
@daveespo made 1 comment.
Reviewable status: 0 of 21 files reviewed, 1 unresolved discussion (waiting on @john-storey-devops and @nwcm).
a discussion (no related file):
@john-storey-devops It looks like this PR also has a tabs vs. spaces problem. A lot of the changes you introduced replaced whitespace. Can you restore the whitespace as it was so that this PR is solely about adding the @namespaceaccessible
Separately, we'd like the same treatment applied to fflib-apex-mocks so that 2GP developers that want to move AEP into its own package can use Mocks as well. Do you have time to propose that PR for fflib-apex-mocks?
Down the road, we'll do force-di and at4dx but those projects are less adopted than fflib-apex-common (and it's required dependency fflib-apex-mocks) so we'll defer that work for another day.
I have addressed the spaces. However, as this project does not have a unified formatter the existing files already have a mix of spaces and tabs. So, there are now diffs converting spaces to tabs. I would suggest implementing prettier with the "@prettier/plugin-xml", "prettier-plugin-apex" plugins |
|
I don't have too much time, but here is a start at custom PMD rules for flagging missing annotations. Will need some work <?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Namespace Accessible" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>Ensure source supports access over namespace for 2GP packages</description>
<rule name="ClassesMustBeNamespaceAccessible" language="apex" message="Public or protected classes must be annotated with @namespaceAccessiable" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<description>Public or protected classes must be annotated as @NamespaceAccessible</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//UserClass[ModifierNode[@Public=true() or @Protected=true()][not(Annotation[@Image = 'NamespaceAccessible'])]]
]]>
</value>
</property>
</properties>
</rule>
<rule name="MethodsMustBeNamespaceAccessible"
language="apex"
message="Public or protected class methods must be annotated as @NamespaceAccessible"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<description>
</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//UserClass[ModifierNode[@Public=true() or @Protected=true()]]/Method[ModifierNode[@Public=true() or @Protected=true()]]
[not(ModifierNode/Annotation[@Image = 'NamespaceAccessible'])]
]]>
</value>
</property>
</properties>
</rule>
</ruleset> |
|
Thanks @nwcm for the above - looking to get this one through soon for you - thanks for your patience. |
Annotate public and protected with @NamespaceAccessible
Open for discussion, still validating these changes.
This change is