Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes with CEQ 3.2.0 #291

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,8 @@ static Map<Ga, Set<Ga>> collectIntegrationTests(final MavenSourceTree tree, Pred
final String pomXmlRelPath = PomTunerUtils.toUnixPath(basedir.relativize(pomXmlPath).toString());
final Module testModule = tree.getModulesByPath().get(pomXmlRelPath);
if (testModule == null) {
throw new IllegalStateException("Could not find module for path " + pomXmlRelPath);
log.warn("Could not find module for path " + pomXmlRelPath);
continue;
}
final Ga moduleGa = evaluator.evaluateGa(testModule.getGav());
if (!excludeTests.contains(moduleGa)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.l2x6.pom.tuner.PomTransformer.TransformationContext;
import org.l2x6.pom.tuner.PomTunerUtils;
import org.l2x6.pom.tuner.model.Dependency;
import org.l2x6.pom.tuner.model.Ga;
import org.l2x6.pom.tuner.model.Gavtcs;
import org.l2x6.pom.tuner.model.Profile;
import org.w3c.dom.Document;
Expand Down Expand Up @@ -153,6 +154,14 @@ public class ProdInitMojo extends AbstractMojo {
@Parameter(defaultValue = "${quarkiverse-cxf.version}", readonly = true)
String quarkiverseCxfVersion;

/**
* Camel Sap version
*
* @since 4.4.6
*/
@Parameter(defaultValue = "${camel-sap.version}", required = true)
String camelSapVersion;

/** {@inheritDoc} */
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
Expand Down Expand Up @@ -195,6 +204,10 @@ public void execute() throws MojoExecutionException, MojoFailureException {
props.addChildTextElementIfNeeded("camel-quarkus-community.version", version,
Comparator.comparing(Map.Entry::getKey, Comparators.before("cassandra-quarkus.version")));

getLog().info("Adding to pom.xml: camel-sap.version property");
props.addChildTextElementIfNeeded("camel-sap.version", camelSapVersion,
Comparator.comparing(Map.Entry::getKey, Comparators.before("cassandra-quarkus.version")));

getLog().info("Adding to pom.xml: quarkus-community.version property");
props.addChildTextElementIfNeeded("quarkus-community.version", quarkusVersion,
Comparator.comparing(Map.Entry::getKey, Comparators.after("quarkus.version")));
Expand Down Expand Up @@ -231,10 +244,18 @@ public void execute() throws MojoExecutionException, MojoFailureException {
final String xPath = PomTunerUtils.anyNs("project", "modules", "module") + "[text() = 'docs']";
context.removeNode(xPath, true, true, false);

/* Add product module */
getLog().info("Adding to pom.xml: product module");
final ContainerElement profileParent = context.getOrAddProfileParent(null);
final ContainerElement modules = profileParent.getOrAddChildContainerElement("modules");

/* Add integration-tests/message module.
camel-quarkus-integration-test-messaging-jms needed to be productized as a transitive dependency
of jms-(artemis|qpid-jms|ibmmq)-client tests.
*/
getLog().info("Adding to pom.xml: integration-tests/messaging module");
modules.addChildTextElement("module", "integration-tests/messaging");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why we need to add <module>integration-tests/messaging</messaging> to the root pom.xml?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it looks like a work around.
The org.apache.camel.quarkus:camel-quarkus-integration-test-messaging-jms should be set with ${camel-quarkus-community.version} but this does not happen when running with cq:prod-excludes.

If we find a fix, it should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I think I find a cause. Let's take a look at og.apache.camel.quarkus:camel-quarkus-integration-test-jms-artemis-client dependencies filtered by camel-quarkus extensions:

[INFO] contains org.apache.camel.quarkus:camel-quarkus-core
[INFO] contains org.apache.camel.quarkus:camel-quarkus-jms
[INFO] contains org.apache.camel.quarkus:camel-quarkus-support-spring
[INFO] contains org.apache.camel.quarkus:camel-quarkus-bean
[INFO] contains org.apache.camel.quarkus:camel-quarkus-jta
[INFO] contains org.apache.camel.quarkus:camel-quarkus-mock
[INFO] contains org.apache.camel.quarkus:camel-quarkus-xml-jaxp
[INFO] contains org.apache.camel.quarkus:camel-quarkus-support-commons-logging
[INFO] contains org.apache.camel.quarkus:camel-quarkus-direct

Then all of them haven been productized. We introduce camel-quarkus-xml-jaxp in 3.2.0 recently. So the jms-artemis-client test is taken into TestCategory.PURE_PRODUCT. Now we have to product org.apache.camel.quarkus:camel-quarkus-integration-test-messaging-jms as a transitive dependency.

That could be the reason it keeps ${camel-quarkus.version} in the poms/bom-test/pom.xml.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it really solves some problem, it is fine to leave it there. Anyway it would be nice to add a comment explaining the motivation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


/* Add product module */
getLog().info("Adding to pom.xml: product module");
modules.addChildTextElement("module", "product");

/* Change the version of camel-build-tools under license-maven-plugin to camel-community.version */
Expand Down Expand Up @@ -327,6 +348,14 @@ public void execute() throws MojoExecutionException, MojoFailureException {
.map(ContainerElement::asGavtcs)
.filter(gavtcs -> gavtcs.getGroupId().equals("org.graalvm.js"))
.forEach(node -> node.getNode().setVersion("${graalvm-community.version}"));

/** Add camel-sap and camel-quarkus-sap dependencies */
dependencyManagementDeps.addGavtcs(new Gavtcs("org.fusesource", "camel-sap", "${camel-sap.version}",
"", "", "", Ga.of("org.eclipse:osgi")));
dependencyManagementDeps
.addGavtcs(new Gavtcs("org.apache.camel.quarkus", "camel-quarkus-sap", "${camel-quarkus.version}"));
dependencyManagementDeps.addGavtcs(
new Gavtcs("org.apache.camel.quarkus", "camel-quarkus-sap-deployment", "${camel-quarkus.version}"));
});

/* Edit poms/bom-test/pom.xml */
Expand All @@ -350,6 +379,25 @@ public void execute() throws MojoExecutionException, MojoFailureException {
qcxfBomNode.getNode().setVersion("${quarkiverse-cxf-community.version}");
});

/* Edit extensions-jvm/pom.xml to add sap extension */
new PomTransformer(basedir.toPath().resolve("extensions-jvm/pom.xml"), charset, simpleElementWhitespace).transform(
(Document document, TransformationContext context) -> {
final ContainerElement profileParent = context.getOrAddProfileParent(null);
final ContainerElement modules = profileParent.getOrAddChildContainerElement("modules");

modules.addChildTextElement("module", "sap");
});

/* Edit integration-tests-jvm/pom.xml to add sap test */
new PomTransformer(basedir.toPath().resolve("integration-tests-jvm/pom.xml"), charset, simpleElementWhitespace)
.transform(
(Document document, TransformationContext context) -> {
final ContainerElement profileParent = context.getOrAddProfileParent(null);
final ContainerElement modules = profileParent.getOrAddChildContainerElement("modules");

modules.addChildTextElement("module", "sap");
});

// Force Camel community version for unsupported Maven plugins
final Path buildParentItPomPath = basedir.toPath().resolve("poms/build-parent-it/pom.xml");
new PomTransformer(buildParentItPomPath, charset, simpleElementWhitespace)
Expand All @@ -374,7 +422,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
"product/pom.xml",
"product/README.adoc",
"product/src/main/groovy/generate-camel-quarkus-product-json.groovy",
"product/src/main/resources/camel-quarkus-product-source.json");
"product/src/main/resources/camel-quarkus-product-source.json",
"extensions-jvm/sap/",
"integration-tests-jvm/sap/");

try (Repository repo = new FileRepositoryBuilder()
.readEnvironment() // scan environment GIT_* variables
Expand All @@ -389,20 +439,26 @@ public void execute() throws MojoExecutionException, MojoFailureException {
final RevTree tree = commit.getTree();

for (String relPath : filesToCopy) {
getLog().info("Copying from " + fromBranch + ": " + relPath);
try (TreeWalk treeWalk = new TreeWalk(repo)) {
treeWalk.addTree(tree);
treeWalk.setRecursive(true);
treeWalk.setFilter(PathFilter.create(relPath));
if (!treeWalk.next()) {
throw new IllegalStateException("Could not find '" + relPath + "' in branch " + fromBranch);
boolean found = false;
while (treeWalk.next()) {
final ObjectId objectId = treeWalk.getObjectId(0);

final String copyPath = treeWalk.getPathString();
final Path destFile = basedir.toPath().resolve(copyPath);

getLog().info("Copying from " + fromBranch + ": " + copyPath);
Files.createDirectories(destFile.getParent());
try (OutputStream out = Files.newOutputStream(destFile)) {
repo.open(objectId).copyTo(out);
}
found = true;
}
final ObjectId objectId = treeWalk.getObjectId(0);

final Path destFile = basedir.toPath().resolve(relPath);
Files.createDirectories(destFile.getParent());
try (OutputStream out = Files.newOutputStream(destFile)) {
repo.open(objectId).copyTo(out);
if (!found) {
throw new IllegalStateException("Could not find '" + relPath + "' in branch " + fromBranch);
}
}
}
Expand Down