OpenLiberty / ci.maven

Maven plugins for managing Liberty profile servers #devops
Apache License 2.0
130 stars 91 forks source link

Dependency change to fix compilation errors results in no features generated #1507

Open kathrynkodama opened 2 years ago

kathrynkodama commented 2 years ago

Starting dev mode without all of the correct dependencies (no features generated on startup) add the correct dependencies to pom.xml, no additional features are generated when features should be generated. Workaround is "o" and Enter or saving a source file to trigger feature generation again.

To reproduce

  1. Using the finish directory of the multi-module guide: https://github.com/openliberty/guide-maven-multimodules
  2. Add API usage, ex. simple jaxrs application and resource classes and an healthcheck class to /war module.
  3. Remove the umbrella Jakarta EE and MicroProfile dependencies from the war/pom.xml.
  4. Start dev mode, compilation should be unsuccessful and no features should be generated
  5. Add the correct dependencies to the pom.xml to fix the compilation errors. Features generation runs before failing classes are recompiled no additional features are generated. Source compilation occurs after liberty:deploy, but feature generation does not run again."o" and Enter or saving a source file should trigger feature generation again and the correct features are generated and installed.
    [INFO] ************************************************************************
    [INFO] guide-maven-multimodules-jar source compilation was successful.
    /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/war/src/main/java/io/openliberty/guides/multimodules/web/SystemLivenessCheck.java:8: error: package org.eclipse.microprofile.health does not exist
    import org.eclipse.microprofile.health.Liveness;
                                      ^
    /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/war/src/main/java/io/openliberty/guides/multimodules/web/SystemLivenessCheck.java:9: error: package org.eclipse.microprofile.health does not exist
    import org.eclipse.microprofile.health.HealthCheck;
                                      ^
    /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/war/src/main/java/io/openliberty/guides/multimodules/web/SystemLivenessCheck.java:10: error: package org.eclipse.microprofile.health does not exist
    import org.eclipse.microprofile.health.HealthCheckResponse;
                                      ^
    /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/war/src/main/java/io/openliberty/guides/multimodules/web/SystemLivenessCheck.java:14: error: cannot find symbol
    public class SystemLivenessCheck implements HealthCheck {
                                            ^
    symbol: class HealthCheck
    /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/war/src/main/java/io/openliberty/guides/multimodules/web/SystemLivenessCheck.java:12: error: cannot find symbol
    @Liveness
    ^
    symbol: class Liveness
    /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/war/src/main/java/io/openliberty/guides/multimodules/web/SystemLivenessCheck.java:17: error: cannot find symbol
    public HealthCheckResponse call() {
           ^
    symbol:   class HealthCheckResponse
    location: class SystemLivenessCheck
    /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/war/src/main/java/io/openliberty/guides/multimodules/web/SystemLivenessCheck.java:16: error: method does not override or implement a method from a supertype
    @Override
    ^
    /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/war/src/main/java/io/openliberty/guides/multimodules/web/SystemLivenessCheck.java:22: error: cannot find symbol
        return HealthCheckResponse.named(
               ^
    symbol:   variable HealthCheckResponse
    location: class SystemLivenessCheck
    8 errors
    [INFO] guide-maven-multimodules-war source compilation had errors.
    [INFO] guide-maven-multimodules-ear tests compilation was successful.
    [INFO] [AUDIT   ] CWWKT0017I: Web application removed (default_host): http://192.168.0.27:9080/converter/
    [INFO] [AUDIT   ] CWWKZ0009I: The application guide-maven-multimodules-ear has stopped successfully.
    [INFO] [AUDIT   ] CWWKT0016I: Web application available (default_host): http://192.168.0.27:9080/converter/
    [INFO] [AUDIT   ] CWWKZ0003I: The application guide-maven-multimodules-ear updated in 0.104 seconds.
    [INFO] Running liberty:generate-features
    [INFO] No additional features were generated.
    [INFO] Running liberty:deploy
    [INFO] CWWKM2102I: Using artifact based assembly archive : io.openliberty:openliberty-kernel:null:22.0.0.4:zip.
    [INFO] CWWKM2102I: Using installDirectory : /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/ear/target/liberty/wlp.
    [INFO] CWWKM2102I: Using serverName : defaultServer.
    [INFO] CWWKM2102I: Using serverDirectory : /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer.
    [INFO] Copying 2 files to /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer
    [INFO] CWWKM2144I: Update server configuration file server.xml from /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/ear/src/main/liberty/config/server.xml.
    [INFO] CWWKM2185I: The liberty-maven-plugin configuration parameter "appsDirectory" value defaults to "apps".
    [INFO] CWWKM2160I: Installing application guide-maven-multimodules-ear.ear.xml.
    [INFO] CWWKM2010I: Searching for CWWKZ0001I.*guide-maven-multimodules-ear in /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer/logs/messages.log. This search will timeout after 40 seconds.
    [INFO] CWWKM2015I: Match number: 1 is [10/05/22 15:43:11:690 EDT] 00000039 com.ibm.ws.app.manager.AppMessageHelper                      A CWWKZ0001I: Application guide-maven-multimodules-ear started in 0.495 seconds..
    [INFO] guide-maven-multimodules-war source compilation was successful.
    [INFO] guide-maven-multimodules-ear tests compilation was successful.
    [INFO] [AUDIT   ] CWWKG0016I: Starting server configuration update.
    [INFO] [AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer/configDropins/overrides/generated-features.xml
    [INFO] [AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /Users/kathrynkodama/devex/featureGeneration/snapshot-testing-04-22/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer/configDropins/overrides/liberty-plugin-variable-config.xml
    [INFO] [AUDIT   ] CWWKG0018I: The server configuration was not updated. No functional changes were detected.
    [INFO] [AUDIT   ] CWWKT0017I: Web application removed (default_host): http://192.168.0.27:9080/converter/
    [INFO] [AUDIT   ] CWWKZ0009I: The application guide-maven-multimodules-ear has stopped successfully.
    [INFO] [AUDIT   ] CWWKT0016I: Web application available (default_host): http://192.168.0.27:9080/converter/
    [INFO] [AUDIT   ] CWWKZ0003I: The application guide-maven-multimodules-ear updated in 0.076 seconds.

Mac OS Java 1.8 Maven 3.8.4

TrevCraw commented 2 years ago

Was able to reproduce this with a non-umbrella dependency addition to a single module project on Windows - Maven 3.6.3 - Java 1.8.0

Added the below dependencies...

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.25</version>
</dependency>
<dependency>
    <groupId>javax.batch</groupId>
    <artifactId>javax.batch-api</artifactId>
    <version>1.0.1</version>
</dependency>

...to resolve compilation errors with HelloBatch.java...

/*******************************************************************************
 * (c) Copyright IBM Corporation 2021.
 *
 * Licensed 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.
 *******************************************************************************/
package io.openliberty.sample.system;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.batch.api.Batchlet;

import static javax.ws.rs.core.MediaType.TEXT_PLAIN;

@Path("/batchlet")
public class HelloBatch implements Batchlet {
    private static final Logger log = LoggerFactory.getLogger(HelloBatch.class);

    @GET
    @Produces(TEXT_PLAIN)
    public String process() {
        log.info("Called Batchlet.process()");
        return "Batchlet.process()";
    }
    public void stop() {}
}

...and batch-1.0 was not generated when feature generation ran.