adobe / aem-project-archetype

Maven template to create best-practice websites on AEM.
https://experienceleague.adobe.com/docs/experience-manager-core-components/using/developing/archetype/overview.html
Apache License 2.0
546 stars 421 forks source link

Incremental build and descripissue in eclipse #118

Closed dipen-sen closed 5 years ago

dipen-sen commented 6 years ago

Modifying pom.xml like this solves the issue.

<plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <executions>
                    <!-- Configure extra execution of 'manifest' in process-classes phase 
                        to make sure SCR metadata is generated before unit test runs -->
                    <execution>
                        <id>scr-metadata</id>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                        <configuration>
                            <supportIncrementalBuild>true</supportIncrementalBuild>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <instructions>
                        <!-- Import any version of javax.inject, to allow running on multiple 
                            versions of AEM -->
                        <Import-Package>javax.inject;version=0.0.0,*</Import-Package>
                        <Sling-Model-Packages>
                            com.demo.demo_project.core
                        </Sling-Model-Packages>
                        <!-- Enable processing of OSGI DS component annotations -->
                        <_dsannotations>*</_dsannotations>
                        <!-- Enable processing of OSGI metatype annotations -->
                        <_metatypeannotations>*</_metatypeannotations>
                    </instructions>
                    <exportScr>true</exportScr>
                </configuration>
            </plugin>

Similar changes needed in it.tests module as well.

gabrielwalt commented 6 years ago

Hi @dipen-sen, please add more information and describe the actual issue. I'm closing this issue for now, but we'll reopen it if we get more information.

dipen-sen commented 6 years ago

@gabrielwalt Once you create a project in Eclipse using AEM archetype, you will get this error in eclipse for core and test module pom.xml. Missing m2e incremental build support for generating the bundle manifest, component descriptions and metatype resources. Please use the provided Quick Fixes on this issue to resolve this.

You need to manually define below in maven-bundle-plugin to get rid of this error.

<executions>    <execution>
                        <id>scr-metadata</id>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                        <configuration>
                            <supportIncrementalBuild>true</supportIncrementalBuild>
                        </configuration>
                    </execution>
                </executions>
dipen-sen commented 6 years ago

@gabrielwalt Can you please have a look into it?

dipen-sen commented 5 years ago

@gabrielwalt Did you get time to check? This issue is inherited into all archtypes.

rmcdouga commented 5 years ago

Were you able to get this working? For some reason I cannot. I read the directions provided here which links to this which in turn links to this.

The instructions basically boil down to the change you've indicated above however after cutting and pasting your code into my project, Eclipse is still giving me the same errors. It would be helpful to me if I knew that someone else had overcome this issue.

EasonPai commented 5 years ago

@rmcdouga I had the same problem, and follow the step @dipen-sen provided, I can get it to work. What I did is copy and paste too, and right click on project > maven > update project.

hwrichter commented 5 years ago

http://felix.apache.org/documentation/faqs/apache-felix-bundle-plugin-faq.html copy and paste the missing part.

rmcdouga commented 5 years ago

Thanks to @EasonPai and @hwrichter . I tried this again and it now works in my project based on Archetype 16. I copied and pasted the text from the 11 Oct 2018 post by @dipen-sen into the core project's pom.xml file (minus the surrounding tag since that section already existed). I also pasted it into the it.tests project pom.xml as well but also had to merge the configuration section from the faq to make that work. Now I am no longer getting the error. Thanks everyone for the help.

godanny86 commented 5 years ago

@gabrielwalt , @bpauli can we re-open this issue and update the poms in core and it.tests? IMO the archetype should already be pre-configured in the POMs to support the incremental build and avoid seeing errors in eclipse when dropping in a fresh project generated from the archetype.

FWIW here are the updates I made to the maven-bundle-plugin in core/pom.xml (following generation of archetype 17):

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>generate-osgi-metadata-for-unittests</id>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                    <execution>
                        <id>scr-metadata</id>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                        <configuration>
                            <supportIncrementalBuild>true</supportIncrementalBuild>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <exportScr>true</exportScr>
                    <instructions>
                        <!-- Import any version of javax.inject, to allow 
                            running on multiple versions of AEM -->
                        <Import-Package>javax.inject;version=0.0.0,*</Import-Package>
                        <Sling-Model-Packages>
                            com.adobe.aem.guides.wknd.core
                        </Sling-Model-Packages>
                        <_dsannotations>*</_dsannotations>
                        <_metatypeannotations>*</_metatypeannotations>
                        <!-- Allow the processing of SCR annotations via 
                            a bnd plugin -->
                       <_plugin>org.apache.felix.scrplugin.bnd.SCRDescriptorBndPlugin;destdir=${project.build.outputDirectory}</_plugin>
                    </instructions>
                </configuration>

And the updates in it.tests/pom.xml:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <inherited>true</inherited>
                <executions>
                    <!-- Configure extra execution of 'manifest' in process-classes phase to make sure SCR metadata is generated before unit test runs -->
                    <execution>
                        <id>scr-metadata</id>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                        <configuration>
                            <supportIncrementalBuild>true</supportIncrementalBuild>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <exportScr>true</exportScr>
                    <instructions>
                        <Sling-Test-Regexp>.*Test</Sling-Test-Regexp>
                        <!-- Enable processing of OSGI DS component annotations -->
                        <_dsannotations>*</_dsannotations>
                        <!-- Enable processing of OSGI metatype annotations -->
                        <_metatypeannotations>*</_metatypeannotations>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>
bpauli commented 5 years ago

@godanny86 Thank you for bringing this up again. I'll reopen the issue.

timdonovanuk commented 4 years ago

This is still a problem in the aem-guides-wknd-events.core projects