-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tools): added addons archetype (#5699)
* feat(tools): added addons archetype Signed-off-by: Marcello Rinaldo Martina <[email protected]> * fix: typo Signed-off-by: Marcello Rinaldo Martina <[email protected]> --------- Signed-off-by: Marcello Rinaldo Martina <[email protected]>
- Loading branch information
1 parent
1704b97
commit 814c706
Showing
33 changed files
with
2,588 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
!src/main/resources/archetype-resources/**/MANIFEST.MF | ||
.vscode |
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,101 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2025 Eurotech and/or its affiliates and others | ||
This program and the accompanying materials are made | ||
available under the terms of the Eclipse Public License 2.0 | ||
which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
Eurotech | ||
--> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.eclipse.kura</groupId> | ||
<artifactId>tools</artifactId> | ||
<version>6.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>kura-addon-archetype</artifactId> | ||
<packaging>maven-archetype</packaging> | ||
|
||
<properties> | ||
<kura_eth.basedir>${project.basedir}/../..</kura_eth.basedir> | ||
</properties> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
<includes> | ||
<include>archetype-resources/test/test-env/framework/kura.properties</include> | ||
<include>META-INF/maven/archetype-metadata.xml</include> | ||
</includes> | ||
</resource> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>false</filtering> | ||
<excludes> | ||
<exclude>archetype-resources/test/test-env/framework/kura.properties</exclude> | ||
<exclude>META-INF/maven/archetype-metadata.xml</exclude> | ||
</excludes> | ||
</resource> | ||
<!-- process projects versions properties in target definition --> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
<includes> | ||
<include>archetype-resources/target-definition/__artifactId__.target</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
|
||
<extensions> | ||
<extension> | ||
<groupId>org.apache.maven.archetype</groupId> | ||
<artifactId>archetype-packaging</artifactId> | ||
<version>3.0.1</version> | ||
</extension> | ||
</extensions> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.3.1</version> | ||
<configuration> | ||
<includeEmptyDirs>true</includeEmptyDirs> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>properties-maven-plugin</artifactId> | ||
<version>1.2.1</version> | ||
<executions> | ||
<execution> | ||
<phase>initialize</phase> | ||
<goals> | ||
<goal>read-project-properties</goal> | ||
</goals> | ||
<configuration> | ||
<files> | ||
<file>${basedir}/../../../target-platform/config/kura.target-platform.build.properties</file> | ||
<file>${basedir}/../../distrib/config/kura.build.properties</file> | ||
</files> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
71 changes: 71 additions & 0 deletions
71
kura/tools/kura-addon-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
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,71 @@ | ||
<!-- | ||
Copyright (c) 2025 Eurotech and/or its affiliates and others | ||
This program and the accompanying materials are made | ||
available under the terms of the Eclipse Public License 2.0 | ||
which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
Eurotech | ||
--> | ||
<archetype-descriptor | ||
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" | ||
partial="true"> | ||
|
||
<requiredProperties> | ||
<requiredProperty key="mainBundleVendor"> | ||
<defaultValue>Eclipse Kura</defaultValue> | ||
</requiredProperty> | ||
<requiredProperty key="version"> | ||
<defaultValue>1.0.0-SNAPSHOT</defaultValue> | ||
</requiredProperty> | ||
</requiredProperties> | ||
|
||
<fileSets> | ||
<fileSet filtered="true" encoding="UTF-8"> | ||
<directory>target-definition</directory> | ||
</fileSet> | ||
<fileSet filtered="true" encoding="UTF-8"> | ||
<directory>distrib</directory> | ||
</fileSet> | ||
<!-- exclude keystores from filtering, otherwise they get corrupted --> | ||
<fileSet filtered="true" encoding="UTF-8"> | ||
<directory>tests/test-env</directory> | ||
<excludes> | ||
<exclude>**/*.ks</exclude> | ||
</excludes> | ||
</fileSet> | ||
<!-- include keystores without filtering --> | ||
<fileSet filtered="false"> | ||
<directory>tests/test-env</directory> | ||
<includes> | ||
<include>**/*.ks</include> | ||
</includes> | ||
</fileSet> | ||
<!-- include bundles and tests without java file, they are selected as packaged below --> | ||
<fileSet filtered="true" encoding="UTF-8"> | ||
<directory>bundles</directory> | ||
<excludes> | ||
<exclude>**/*.java</exclude> | ||
</excludes> | ||
</fileSet> | ||
<fileSet filtered="true" encoding="UTF-8"> | ||
<directory>tests</directory> | ||
<excludes> | ||
<exclude>**/*.java</exclude> | ||
<exclude>**/src/main/java/test</exclude> | ||
</excludes> | ||
</fileSet> | ||
<fileSet filtered="true" packaged="true"> | ||
<directory>bundles/__artifactId__.bundle/src/main/java</directory> | ||
</fileSet> | ||
<fileSet filtered="true" packaged="true"> | ||
<directory>tests/__artifactId__.bundle.test/src/main/java</directory> | ||
</fileSet> | ||
</fileSets> | ||
|
||
</archetype-descriptor> |
12 changes: 12 additions & 0 deletions
12
kura/tools/kura-addon-archetype/src/main/resources/archetype-resources/.gitignore
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,12 @@ | ||
.DS_Store* | ||
*~ | ||
classes | ||
target | ||
RemoteSystemsTempFiles | ||
.metadata | ||
.recommenders | ||
.sonarlint | ||
.classpath | ||
.project | ||
.settings | ||
.vscode |
14 changes: 14 additions & 0 deletions
14
...src/main/resources/archetype-resources/bundles/__artifactId__.bundle/META-INF/MANIFEST.MF
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,14 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-SymbolicName: ${artifactId}.bundle;singleton:=true | ||
Bundle-Version: ${version.replace("-SNAPSHOT", ".qualifier")} | ||
Bundle-Vendor: ${mainBundleVendor} | ||
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=17))" | ||
Import-Package: org.eclipse.kura;version="[1.4,2.0)", | ||
org.eclipse.kura.configuration;version="[1.0,2.0)", | ||
org.eclipse.kura.configuration.metatype;version="[1.1,2.0)", | ||
org.eclipse.kura.core.configuration;version="[2.0,3.0)", | ||
org.eclipse.kura.core.configuration.metatype;version="[1.0,2.0)", | ||
org.slf4j;version="1.7" | ||
Bundle-ActivationPolicy: lazy | ||
Service-Component: OSGI-INF/*.xml |
30 changes: 30 additions & 0 deletions
30
...resources/archetype-resources/bundles/__artifactId__.bundle/OSGI-INF/ExampleComponent.xml
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2025 Eurotech and/or its affiliates and others | ||
This program and the accompanying materials are made | ||
available under the terms of the Eclipse Public License 2.0 | ||
which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
Eurotech | ||
--> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" | ||
activate="activate" | ||
deactivate="deactivate" | ||
modified="updated" | ||
configuration-policy="require" | ||
enabled="true" | ||
immediate="true" | ||
name="${package}.ExampleComponent"> | ||
|
||
<implementation class="${package}.ExampleComponent" /> | ||
|
||
<service> | ||
<provide interface="org.eclipse.kura.configuration.ConfigurableComponent" /> | ||
</service> | ||
|
||
<property name="kura.service.pid" value="${package}.ExampleComponent"/> | ||
</scr:component> |
33 changes: 33 additions & 0 deletions
33
...esources/bundles/__artifactId__.bundle/OSGI-INF/metatype/__package__.ExampleComponent.xml
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,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2025 Eurotech and/or its affiliates and others | ||
This program and the accompanying materials are made | ||
available under the terms of the Eclipse Public License 2.0 | ||
which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
Eurotech | ||
--> | ||
<MetaData xmlns="http://www.osgi.org/xmlns/metatype/v1.2.0" | ||
localization="en_us"> | ||
|
||
<OCD id="${package}.ExampleComponent" name="ExampleComponent" | ||
description="An example configurable component implementation."> | ||
|
||
<AD id="example.property" | ||
name="An example property" | ||
type="String" | ||
cardinality="0" | ||
required="true" | ||
default="foo" | ||
description="An example string property." /> | ||
|
||
</OCD> | ||
|
||
<Designate pid="${package}.ExampleComponent"> | ||
<Object ocdref="${package}.ExampleComponent" /> | ||
</Designate> | ||
</MetaData> |
4 changes: 4 additions & 0 deletions
4
...ype/src/main/resources/archetype-resources/bundles/__artifactId__.bundle/build.properties
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,4 @@ | ||
bin.includes = .,\ | ||
META-INF/,\ | ||
OSGI-INF/ | ||
source.. = src/main/java/ |
34 changes: 34 additions & 0 deletions
34
...on-archetype/src/main/resources/archetype-resources/bundles/__artifactId__.bundle/pom.xml
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,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2025 Eurotech and/or its affiliates and others | ||
This program and the accompanying materials are made | ||
available under the terms of the Eclipse Public License 2.0 | ||
which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
Eurotech | ||
--> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>${groupId}</groupId> | ||
<artifactId>${artifactId}.parent</artifactId> | ||
<version>${version}</version> | ||
</parent> | ||
|
||
<properties> | ||
<sonar.coverage.jacoco.xmlReportPaths> | ||
${project.basedir}/../../tests/*/target/site/jacoco-aggregate/jacoco.xml | ||
</sonar.coverage.jacoco.xmlReportPaths> | ||
</properties> | ||
|
||
<artifactId>${artifactId}.bundle</artifactId> | ||
<packaging>eclipse-plugin</packaging> | ||
|
||
</project> |
47 changes: 47 additions & 0 deletions
47
...ces/archetype-resources/bundles/__artifactId__.bundle/src/main/java/ExampleComponent.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,47 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech | ||
*******************************************************************************/ | ||
package ${package}; | ||
|
||
import java.util.Map; | ||
|
||
import org.eclipse.kura.configuration.ConfigurableComponent; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class ExampleComponent implements ConfigurableComponent { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(ExampleComponent.class); | ||
|
||
public void activate(final Map<String, Object> properties) { | ||
logger.info("Activating"); | ||
|
||
updated(properties); | ||
|
||
logger.info("Activated"); | ||
} | ||
|
||
public void updated(final Map<String, Object> properties) { | ||
logger.info("Updating"); | ||
|
||
logger.debug("Updating with properties: {}", properties); | ||
ExampleComponentOptions options = new ExampleComponentOptions(properties); | ||
|
||
logger.info("Updated"); | ||
} | ||
|
||
public synchronized void deactivate() { | ||
logger.info("Deactivating"); | ||
logger.info("Deactivated"); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...hetype-resources/bundles/__artifactId__.bundle/src/main/java/ExampleComponentOptions.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,31 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech | ||
*******************************************************************************/ | ||
package ${package}; | ||
|
||
import java.util.Map; | ||
|
||
class ExampleComponentOptions { | ||
|
||
private static final Property<String> EXAMPLE_PROPERTY = new Property<>("example.property", "example"); | ||
|
||
private final String exampleProperty; | ||
|
||
public ExampleComponentOptions(final Map<String, Object> properties) { | ||
this.exampleProperty = EXAMPLE_PROPERTY.getOrDefault(properties); | ||
} | ||
|
||
public String getExampleProperty() { | ||
return exampleProperty; | ||
} | ||
|
||
} |
Oops, something went wrong.