stataru8 commented on code in PR #317: URL: https://github.com/apache/camel-karaf/pull/317#discussion_r1625926118
########## tooling/camel-karaf-feature-maven-plugin/pom.xml: ########## @@ -0,0 +1,111 @@ +<!-- + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.camel.karaf</groupId> + <artifactId>tooling</artifactId> + <version>4.6.0-SNAPSHOT</version> + </parent> + + <artifactId>camel-karaf-feature-maven-plugin</artifactId> + <packaging>maven-plugin</packaging> + <name>Apache Camel :: Karaf :: Tooling :: Feature Maven Plugin</name> + + <properties> + <felix.utils.version>1.11.8</felix.utils.version> + <junit.jupiter.version>5.10.2</junit.jupiter.version> Review Comment: Done 👍 ########## tooling/camel-karaf-feature-maven-plugin/src/main/java/org/apache/camel/karaf/feature/maven/EnsureWrapBundleVersionMojo.java: ########## @@ -0,0 +1,319 @@ +/* + * 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.karaf.feature.maven; + +import java.io.StringWriter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.felix.utils.version.VersionCleaner; +import org.apache.karaf.features.internal.model.Bundle; +import org.apache.karaf.features.internal.model.Feature; +import org.apache.karaf.features.internal.model.Features; +import org.apache.karaf.features.internal.model.JaxbUtil; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.osgi.framework.Version; + +@Mojo(name = "ensure-wrap-bundle-version", defaultPhase = LifecyclePhase.PROCESS_RESOURCES) +public class EnsureWrapBundleVersionMojo extends AbstractMojo { + + public static final String FILE_PROTOCOL = "file:"; + + public static final String WRAP_PROTOCOL = "wrap:mvn:"; + public static final String BUNDLE_VERSION = "Bundle-Version"; + public static final List<String> HEADERS_AFTER_BUNDLE_VEIRSION = Arrays.asList( Review Comment: I agree, Done 👍 ########## tooling/camel-karaf-feature-maven-plugin/src/main/java/org/apache/camel/karaf/feature/maven/EnsureWrapBundleVersionMojo.java: ########## @@ -0,0 +1,319 @@ +/* + * 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.karaf.feature.maven; + +import java.io.StringWriter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.felix.utils.version.VersionCleaner; +import org.apache.karaf.features.internal.model.Bundle; +import org.apache.karaf.features.internal.model.Feature; +import org.apache.karaf.features.internal.model.Features; +import org.apache.karaf.features.internal.model.JaxbUtil; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.osgi.framework.Version; + +@Mojo(name = "ensure-wrap-bundle-version", defaultPhase = LifecyclePhase.PROCESS_RESOURCES) +public class EnsureWrapBundleVersionMojo extends AbstractMojo { + + public static final String FILE_PROTOCOL = "file:"; + + public static final String WRAP_PROTOCOL = "wrap:mvn:"; + public static final String BUNDLE_VERSION = "Bundle-Version"; + public static final List<String> HEADERS_AFTER_BUNDLE_VEIRSION = Arrays.asList( + //"Bundle-Version", + "DynamicImport-Package", + "Export-Package", + "Export-Service", + "Fragment-Host", + "Import-Package", + "Import-Service", + "Provide-Capability", + "Require-Bundle", + "Require-Capability"); + + private static final String DEFAULT_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"; + private static final String LICENCE_HEADER = """ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +-->"""; + + @Parameter(property = "featuresFilePath", required = true) + private String featuresFilePath; + + @Parameter(property = "targetFeature", required = false) + private String targetFeature = null; + + public String getFeaturesFilePath() { + return featuresFilePath; + } + + public void setFeaturesFilePath(String featuresFilePath) { + this.featuresFilePath = featuresFilePath; + } + + public String getTargetFeature() { + return targetFeature; + } + + public void setTargetFeature(String targetFeature) { + this.targetFeature = targetFeature; + } + + @Override + public void execute() throws MojoExecutionException { + Features featuresData = JaxbUtil.unmarshal(getFeaturesFilePath(), false); + List<Feature> features = featuresData.getFeature(); + + if (getTargetFeature() != null) { Review Comment: I agree. Now I remember that I did it when I still had the idea of modifying the original feature file and not the one in the target folder. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org