Skip to content

Commit 737154f

Browse files
committed
Merge branch 'main' into 246-improve-java-model
2 parents 5e57e95 + 9d808b7 commit 737154f

File tree

20 files changed

+1151
-225
lines changed

20 files changed

+1151
-225
lines changed

.github/workflows/pull_request_check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
steps:
1111
- name: Checkout
1212
uses: actions/[email protected]
13-
- name: Set up JDK 11
13+
- name: Set up JDK 17
1414
uses: actions/setup-java@v2
1515
with:
1616
distribution: 'temurin'
1717
java-version: '17'
1818
- name: Run tests
19-
run: mvn -B clean install
19+
run: mvn -B clean install -Dgpg.skip=true

.github/workflows/release-workflow.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
git push origin ${{ env.release_branch_name }}
6868
fi
6969
- name: Run tests and build
70-
run: mvn -B clean install
70+
run: mvn -B clean install -Dgpg.skip=true
7171

7272
# release-build
7373
- name: Create GitHub release
@@ -91,6 +91,9 @@ jobs:
9191
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
9292
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
9393
PGP_KEY_PASSWORD: ${{ secrets.PGP_KEY_PASSWORD }}
94+
# Workaround for https://issues.sonatype.org/browse/OSSRH-66257
95+
# as described in https://stackoverflow.com/a/70157413
96+
MAVEN_OPTS: --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED
9497

9598
# milestone-build
9699
- name: Create GitHub release

core/sds-aspect-meta-model-java/src/main/java/io/openmanufacturing/sds/metamodel/loader/instantiator/PropertyInstantiator.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,16 @@ public Property apply( final Resource property ) {
5959
final boolean isAbstract = property.getModel().contains( property, RDF.type, bamm.AbstractProperty() );
6060

6161
final MetaModelBaseAttributes metaModelBaseAttributes = buildBaseAttributes( property );
62-
final DefaultPropertyWrapper defaultPropertyWrapper = new DefaultPropertyWrapper( metaModelBaseAttributes);
62+
final DefaultPropertyWrapper defaultPropertyWrapper = new DefaultPropertyWrapper( metaModelBaseAttributes );
6363

6464
if ( resourcePropertyMap.containsKey( property ) ) {
6565
final Property propertyInstance = resourcePropertyMap.get( property );
66-
resourcePropertyMap.remove( property );
6766
return propertyInstance;
6867
}
6968
resourcePropertyMap.put( property, defaultPropertyWrapper );
70-
DefaultProperty defProperty;
69+
final DefaultProperty defProperty;
7170
if ( isAbstract ) {
72-
defProperty = new DefaultProperty( metaModelBaseAttributes, Optional.of( fallbackCharacteristic), Optional.empty(), isOptional,
71+
defProperty = new DefaultProperty( metaModelBaseAttributes, Optional.of( fallbackCharacteristic ), Optional.empty(), isOptional,
7372
isNotInPayload, payloadName, isAbstract, extends_ );
7473
} else {
7574
final Resource characteristicResource = attributeValue( property, bamm.characteristic() ).getResource();
@@ -90,7 +89,7 @@ public Property apply( final Resource property ) {
9089
return new DefaultScalarValue( value, type );
9190
} ) );
9291

93-
defProperty = new DefaultProperty( metaModelBaseAttributes, Optional.of( characteristic), exampleValue, isOptional,
92+
defProperty = new DefaultProperty( metaModelBaseAttributes, Optional.of( characteristic ), exampleValue, isOptional,
9493
isNotInPayload, payloadName, isAbstract, extends_ );
9594
}
9695
defaultPropertyWrapper.setProperty( defProperty );

core/sds-aspect-meta-model-resolver/pom.xml

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
<name>SDS Aspect Meta Model Resolver</name>
2929
<packaging>jar</packaging>
3030

31+
<properties>
32+
<bamm-revision>https://raw.githubusercontent.com/OpenManufacturingPlatform/sds-bamm-aspect-meta-model/5c097dd7357b129ba1771985a9ab1d29fcc32bcd</bamm-revision>
33+
</properties>
34+
3135
<dependencies>
3236
<dependency>
3337
<groupId>io.openmanufacturing</groupId>
@@ -126,10 +130,10 @@
126130
<artifactId>sds-aspect-meta-model</artifactId>
127131
<version>${aspect-meta-model-version}</version>
128132
<type>jar</type>
129-
<overWrite>true</overWrite>
133+
<overWrite>false</overWrite>
130134
<outputDirectory>${project.build.directory}/classes</outputDirectory>
131135
<excludes>
132-
bamm/meta-model/2.0.0/aspect-meta-model-shapes.ttl,bamm/characteristic/2.0.0/characteristic-shapes.ttl
136+
bamm/meta-model/1.0.0/aspect-meta-model-shapes.ttl,bamm/characteristic/1.0.0/characteristic-shapes.ttl,bamm/meta-model/2.0.0/aspect-meta-model-shapes.ttl,bamm/characteristic/2.0.0/characteristic-shapes.ttl
133137
</excludes>
134138
</artifactItem>
135139
</artifactItems>
@@ -146,31 +150,71 @@
146150
<version>${download-maven-plugin-version}</version>
147151
<executions>
148152
<execution>
149-
<id>download-meta-model-shapes</id>
153+
<id>download-meta-model-shapes-1-0-0</id>
154+
<phase>process-resources</phase>
155+
<goals>
156+
<goal>wget</goal>
157+
</goals>
158+
<configuration>
159+
<url>
160+
${bamm-revision}/src/main/resources/bamm/meta-model/1.0.0/aspect-meta-model-shapes.ttl
161+
</url>
162+
<outputFileName>aspect-meta-model-shapes.ttl</outputFileName>
163+
<outputDirectory>${project.build.directory}/classes/bamm/meta-model/1.0.0</outputDirectory>
164+
<overwrite>true</overwrite>
165+
<followRedirects>true</followRedirects>
166+
<skipCache>true</skipCache>
167+
</configuration>
168+
</execution>
169+
<execution>
170+
<id>download-meta-model-shapes-2-0-0</id>
150171
<phase>process-resources</phase>
151172
<goals>
152173
<goal>wget</goal>
153174
</goals>
154175
<configuration>
155176
<url>
156-
https://raw.githubusercontent.com/OpenManufacturingPlatform/sds-bamm-aspect-meta-model/159ced3e69e5d694e5158f2942cb3182941cf032/src/main/resources/bamm/meta-model/2.0.0/aspect-meta-model-shapes.ttl
177+
${bamm-revision}/src/main/resources/bamm/meta-model/2.0.0/aspect-meta-model-shapes.ttl
157178
</url>
158179
<outputFileName>aspect-meta-model-shapes.ttl</outputFileName>
159180
<outputDirectory>${project.build.directory}/classes/bamm/meta-model/2.0.0</outputDirectory>
181+
<overwrite>true</overwrite>
182+
<followRedirects>true</followRedirects>
183+
<skipCache>true</skipCache>
184+
</configuration>
185+
</execution>
186+
<execution>
187+
<id>download-characteristics-shapes-1-0-0</id>
188+
<phase>process-resources</phase>
189+
<goals>
190+
<goal>wget</goal>
191+
</goals>
192+
<configuration>
193+
<url>
194+
${bamm-revision}/src/main/resources/bamm/characteristic/1.0.0/characteristic-shapes.ttl
195+
</url>
196+
<outputFileName>characteristic-shapes.ttl</outputFileName>
197+
<outputDirectory>${project.build.directory}/classes/bamm/characteristic/1.0.0</outputDirectory>
198+
<overwrite>true</overwrite>
199+
<followRedirects>true</followRedirects>
200+
<skipCache>true</skipCache>
160201
</configuration>
161202
</execution>
162203
<execution>
163-
<id>download-characteristics-shapes</id>
204+
<id>download-characteristics-shapes-2-0-0</id>
164205
<phase>process-resources</phase>
165206
<goals>
166207
<goal>wget</goal>
167208
</goals>
168209
<configuration>
169210
<url>
170-
https://raw.githubusercontent.com/OpenManufacturingPlatform/sds-bamm-aspect-meta-model/159ced3e69e5d694e5158f2942cb3182941cf032/src/main/resources/bamm/characteristic/2.0.0/characteristic-shapes.ttl
211+
${bamm-revision}/src/main/resources/bamm/characteristic/2.0.0/characteristic-shapes.ttl
171212
</url>
172213
<outputFileName>characteristic-shapes.ttl</outputFileName>
173214
<outputDirectory>${project.build.directory}/classes/bamm/characteristic/2.0.0</outputDirectory>
215+
<overwrite>true</overwrite>
216+
<followRedirects>true</followRedirects>
217+
<skipCache>true</skipCache>
174218
</configuration>
175219
</execution>
176220
</executions>

core/sds-aspect-meta-model-resolver/src/main/java/io/openmanufacturing/sds/aspectmodel/resolver/services/MetaModelUrls.java

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
33
*
44
* See the AUTHORS file(s) distributed with this work for additional
5-
* information regarding authorship.
5+
* information regarding authorship.
66
*
77
* This Source Code Form is subject to the terms of the Mozilla Public
88
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -13,12 +13,16 @@
1313

1414
package io.openmanufacturing.sds.aspectmodel.resolver.services;
1515

16+
import java.io.IOException;
1617
import java.net.URL;
18+
import java.util.List;
1719
import java.util.Optional;
1820

1921
import org.slf4j.Logger;
2022
import org.slf4j.LoggerFactory;
2123

24+
import com.google.common.collect.ImmutableList;
25+
2226
import io.openmanufacturing.sds.aspectmetamodel.KnownVersion;
2327

2428
/**
@@ -40,10 +44,36 @@ private MetaModelUrls() {
4044
*/
4145
public static Optional<URL> url( final String part, final KnownVersion version, final String fileName ) {
4246
final String spec = String.format( "bamm/%s/%s/%s", part, version.toVersionString(), fileName );
43-
final URL result = MetaModelUrls.class.getClassLoader().getResource( spec );
44-
if ( result == null ) {
45-
LOG.warn( "Could not resolve meta model resource {}", spec );
47+
try {
48+
final List<URL> urls = ImmutableList.copyOf( MetaModelUrls.class.getClassLoader().getResources( spec ).asIterator() );
49+
if ( urls.size() == 1 ) {
50+
return Optional.of( urls.get( 0 ) );
51+
}
52+
if ( urls.isEmpty() ) {
53+
return nothingFound( spec );
54+
}
55+
56+
// If multiple resources with the given spec are found:
57+
// - return the one from the file system, if it exists
58+
// - otherwise, the one from jar
59+
// - otherwise, any of the found resources
60+
URL jarUrl = null;
61+
for ( final URL url : urls ) {
62+
if ( url.getProtocol().equals( "file" ) ) {
63+
return Optional.of( url );
64+
}
65+
if ( url.getProtocol().equals( "jar" ) ) {
66+
jarUrl = url;
67+
}
68+
}
69+
return Optional.of( jarUrl == null ? urls.get( 0 ) : jarUrl );
70+
} catch ( final IOException e ) {
71+
return nothingFound( spec );
4672
}
47-
return Optional.ofNullable( result );
73+
}
74+
75+
private static Optional<URL> nothingFound( final String spec ) {
76+
LOG.warn( "Could not resolve meta model resource {}", spec );
77+
return Optional.empty();
4878
}
4979
}

core/sds-aspect-model-aas-generator/src/test/java/io/openmanufacturing/sds/aspectmodel/aas/AspectModelAASGeneratorTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
*/
1313
package io.openmanufacturing.sds.aspectmodel.aas;
1414

15-
import static org.junit.jupiter.api.Assertions.assertEquals;
16-
import static org.junit.jupiter.api.Assertions.assertFalse;
17-
import static org.junit.jupiter.api.Assertions.assertTrue;
15+
import static org.junit.jupiter.api.Assertions.*;
1816

1917
import java.io.ByteArrayInputStream;
2018
import java.io.ByteArrayOutputStream;
@@ -227,7 +225,9 @@ void testGenerateAasxFromBammAspectWithEnumeration() throws IOException, Deseria
227225
value = TestAspect.class,
228226
mode = EnumSource.Mode.EXCLUDE,
229227
names = {
230-
"ASPECT_WITH_STRING_ENUMERATION"
228+
"ASPECT_WITH_STRING_ENUMERATION",
229+
"MODEL_WITH_CYCLES",
230+
"MODEL_WITH_BROKEN_CYCLES"
231231
} )
232232
// anonymous enumeration in test has no urn for enum values but is required for Concept
233233
// Description referencing

0 commit comments

Comments
 (0)