-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Activate Camel dev profile when running in development mode
Fixes #6083
- Loading branch information
1 parent
8383b39
commit 9b6665f
Showing
11 changed files
with
184 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...src/main/java/org/apache/camel/quarkus/core/deployment/devmode/CamelDevModeProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.camel.quarkus.core.deployment.devmode; | ||
|
||
import io.quarkus.deployment.Capabilities; | ||
import io.quarkus.deployment.IsDevelopment; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.BuildSteps; | ||
import io.quarkus.deployment.annotations.ExecutionTime; | ||
import io.quarkus.deployment.annotations.Record; | ||
import org.apache.camel.quarkus.core.CamelContextRecorder; | ||
import org.apache.camel.quarkus.core.deployment.spi.CamelContextBuildItem; | ||
|
||
import static org.apache.camel.quarkus.core.CamelCapabilities.DSL_MODELINE; | ||
|
||
/** | ||
* Build steps relating to customizations that should only be made in Dev Mode. | ||
*/ | ||
@BuildSteps(onlyIf = IsDevelopment.class) | ||
class CamelDevModeProcessor { | ||
@Record(ExecutionTime.STATIC_INIT) | ||
@BuildStep | ||
void customizeDevModeCamelContext( | ||
CamelContextBuildItem camelContext, | ||
Capabilities capabilities, | ||
CamelContextRecorder recorder) { | ||
recorder.customizeDevModeCamelContext(camelContext.getCamelContext(), capabilities.isMissing(DSL_MODELINE)); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...java/org/apache/camel/quarkus/core/deployment/main/devmode/CamelMainDevModeProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.camel.quarkus.core.deployment.main.devmode; | ||
|
||
import io.quarkus.deployment.IsDevelopment; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.BuildSteps; | ||
import io.quarkus.deployment.annotations.ExecutionTime; | ||
import io.quarkus.deployment.annotations.Record; | ||
import org.apache.camel.quarkus.core.deployment.main.spi.CamelMainBuildItem; | ||
import org.apache.camel.quarkus.main.CamelMainRecorder; | ||
|
||
/** | ||
* Build steps relating to camel-main customizations that should only be made in Dev Mode. | ||
*/ | ||
@BuildSteps(onlyIf = IsDevelopment.class) | ||
class CamelMainDevModeProcessor { | ||
@Record(ExecutionTime.STATIC_INIT) | ||
@BuildStep | ||
void customizeDevModeCamelMain(CamelMainBuildItem camelMain, CamelMainRecorder recorder) { | ||
recorder.customizeDevModeCamelMain(camelMain.getInstance()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ployment/src/test/java/org/apache/camel/quarkus/core/runtime/CamelDevModeProfileTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.camel.quarkus.core.runtime; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import java.util.logging.Level; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import org.awaitility.Awaitility; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class CamelDevModeProfileTest { | ||
@RegisterExtension | ||
static final QuarkusDevModeTest TEST = new QuarkusDevModeTest() | ||
.setLogRecordPredicate(record -> record.getLevel().equals(Level.INFO)) | ||
.withEmptyApplication(); | ||
|
||
@Test | ||
void camelMainDevProfileConfigured() { | ||
Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> { | ||
return TEST.getLogRecords().stream() | ||
.anyMatch(logRecord -> logRecord.getMessage().contains("The application is starting with profile: dev")); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...core/runtime/src/main/java/org/apache/camel/quarkus/core/devmode/NoOpModelineFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.camel.quarkus.core.devmode; | ||
|
||
import org.apache.camel.spi.ModelineFactory; | ||
import org.apache.camel.spi.Resource; | ||
|
||
/** | ||
* A NoOp ModelineFactory for use in dev mode when camel-quarkus-modeline-dsl is not on the classpath. | ||
*/ | ||
public class NoOpModelineFactory implements ModelineFactory { | ||
@Override | ||
public void parseModeline(Resource resource) { | ||
// Parsing is disabled | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters