03-04-2022 05:35 AM
Hi,
All the modules that i have created with SDK 4.1 are reported twice at ACS startup and in share admin modules with ACS 6.2.2.
The others modules not.
And in share admin module navigator :
I have not modified the default structure of the AMP. The modules in twice work normally but i dont understand why they are listed twice.
An old post talk about a same problem in sdk 3 but it has been fixed since (mix of test-classes and classes).
Does someone have an idea where i can search ? I think the problem is linked with the fact that the module.properties file of the module is also in the jar file of the module in the war file...
Thanks for your help.
03-09-2022 11:57 AM
I see the problem, it is not just with share modules but its the same case with platform modules as well.
By default SDK4.x meant to build jar based artifact and hence the module.properties file is located under "src\main\resources\alfresco\module\<yourShareModule>" path. and when you also enable the sdk to generate amps along with jars, it end up putting the jar inside the amp/lib having one more module.properties file.
If you enabled this plug-in, you get the amp along with jars:
some details can be found here: https://github.com/Alfresco/alfresco-sdk/blob/master/docs/advanced-topics/amps.md
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>build-amp-file</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptor>src/main/assembly/amp.xml</descriptor>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.alfresco.maven.plugin</groupId>
<artifactId>alfresco-maven-plugin</artifactId>
<version>${alfresco.sdk.version}</version>
</dependency>
</dependencies>
</plugin>
The catch is that, amps can't be installed unless there is module.properties file at the top level of the amp.
There are two options to fix this:
1- Exclude the module.properties from jar via maven-jar-plugin exclude config. Pros: Issue will be fixed, Cons: Only amp artifact can be deployed. If for any reason if you would have to go back to jar artifact only, then you have to include the module.properties back and remove the exclude config. OOTB local docker deployment may also fail as it will by default copy the jar in extensions directory and if jar doesn't have module.properties, it will not work. so you must also add <includeTypes>amp</includeTypes> to the docker projects where it copies the extensions and <type>amp</type> to the dependencies section.
2- Create a custom copy jar (name it well so you can identify the purpose) and exclude the original jar + include the custom jar with no module.properties in the amp. Pros: Issue will be fixed. Both amp and jar based artifacts can be used. Cons: An additonal jar will be created
Here is one of the examples:
- Add following plugin before maven-assembly-plugin in <YourShareModule>\pom.xml. Note that order of plugins matter, so must be added before maven-assembly-plugin
- Add following plugin before maven-assembly-plugin in <YourPlatformModule>\pom.xml. Note that order of plugins matter, so must be added before maven-assembly-plugin
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <filters> <filter> <artifact>*:*</artifact> <excludes>
<!-- Exclude module.properties --> <exclude>**/alfresco/module/${project.artifactId}/module.properties</exclude> </excludes> </filter> </filters> </configuration> </execution> </executions> </plugin>
- Update platform dependency type for your platform module and includeTypes under maven-dependency-plugin's copy-dependencies goal in <YourPlatformModule>-docker\pom.xml, example (see in bold😞
<dependency>
<groupId>com.demo</groupId>
<artifactId>acs71-demo-platform</artifactId>
<version>1.0-SNAPSHOT</version>
<type>amp</type>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<!-- Copy the repository extension and the dependencies required for execute integration tests -->
<execution>
<id>collect-test-artifacts</id>
<phase>pre-integration-test</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/extensions</outputDirectory>
<excludeScope>compile</excludeScope>
</configuration>
</execution>
<!-- Collect extensions (JARs or AMPs) declared in this module do be deployed to docker -->
<execution>
<id>collect-extensions</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/extensions</outputDirectory>
<includeScope>runtime</includeScope>
<includeTypes>amp,jar</includeTypes>
<!-- IMPORTANT: if using amp dependencies only, add <includeTypes>amp</includeTypes> -->
</configuration>
</execution>
</executions>
</plugin>
- Update platform dependency type for your platform module and includeTypes under maven-dependency-plugin's copy-dependencies goal in <YourShareModule>-docker\pom.xml, example (see in bold😞
<dependency>
<groupId>com.demo</groupId>
<artifactId>acs71-demo-share</artifactId>
<version>1.0-SNAPSHOT</version>
<type>amp</type>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<!-- Collect extensions (JARs or AMPs) declared in this module do be deployed to docker -->
<execution>
<id>collect-extensions</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/extensions</outputDirectory>
<includeScope>runtime</includeScope>
<includeTypes>amp</includeTypes>
<!-- IMPORTANT: if using amp dependencies only, add <includeTypes>amp</includeTypes> -->
</configuration>
</execution>
</executions>
</plugin>
You can find examples here: https://github.com/abhinavmishra14/acs7-sdk43-demo
03-10-2022 10:31 AM
Thank you for the github link, the command and the time spent helping me.
Explore our Alfresco products with the links below. Use labels to filter content by product module.