Skip to content

Document usage of esmf-sdk-parent as Maven BOM #743

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

Merged
merged 8 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ jobs:
# Milestone release: Maven deploy to Github
- name: Publish to Github
if: contains( github.event.inputs.release_version, '-M' )
run: mvn -s ./settings.xml -B clean -pl '!esmf-sdk-test-report,!documentation,!tools/samm-cli' deploy -DskipTests -Pmilestone-build,sign
run: mvn -s ./settings.xml -B clean -pl '!documentation,!tools/samm-cli' deploy -DskipTests -Pmilestone-build,sign
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PGP_KEY_PASSWORD: ${{ secrets.PGP_KEY_PASSWORD }}
Expand Down
6 changes: 2 additions & 4 deletions CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ if (someOptional != null && someOptional.isPresent()) ...
* You should be using Objects.requireNonNull() for those sort of checks (or Guava's Preconditions if you're having more types of assertions than non-null and aim for a maximum of consistency).

### Lombok
We use Lombok in the ESMF SDK. Project Lombok is a Java library that automatically plugs into your
editor and build tools. It removes the burden to write getter or equals methods, adds fully featured
builders to a class with one annotation, automates logging variables, and much more. Consider using
its features if you are in the need to do something like that.
Lombok was used in the past, but is not used anymore in the ESMF SDK. Instead of the `@Value` or
`@Data` annotations, consider using Java records.

## Documentation

Expand Down
4 changes: 0 additions & 4 deletions core/esmf-aspect-meta-model-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
27 changes: 0 additions & 27 deletions core/esmf-aspect-meta-model-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,6 @@
</executions>
</plugin>

<!-- Disable surefire report plugin. The report is created in the esmf-sdk-test-report module -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven-surefire-report-plugin-version}</version>
<configuration>
<skipFailsafeReport>true</skipFailsafeReport>
<skipSurefireReport>true</skipSurefireReport>
</configuration>
</plugin>

<!-- Disable maven site plugin. It is not required since the report is created in the
esmf-sdk-test-report module -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin-version}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
Expand All @@ -180,11 +158,6 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok-version}</version>
</path>
<path>
<groupId>io.soabase.record-builder</groupId>
<artifactId>record-builder-processor</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.stream.Stream;

import org.eclipse.esmf.aspectmodel.resolver.services.TurtleLoader;
import org.eclipse.esmf.aspectmodel.serializer.AspectSerializer;
import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn;
import org.eclipse.esmf.aspectmodel.urn.ElementType;
import org.eclipse.esmf.metamodel.vocabulary.SammNs;
Expand All @@ -39,6 +40,9 @@
import org.apache.jena.rdf.model.ResIterator;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.Statement;
import org.apache.jena.riot.RDFFormat;
import org.apache.jena.riot.RDFLanguages;
import org.apache.jena.riot.RDFWriter;
import org.apache.jena.vocabulary.RDF;
import org.apache.jena.vocabulary.XSD;

Expand Down Expand Up @@ -147,6 +151,17 @@ public static Model createModel( final String ttlRepresentation ) {
return TurtleLoader.loadTurtle( ttlRepresentation ).get();
}

/**
* Turn a an RDF model to its String representation. Note that this method should only be used where {@link AspectSerializer} can
* not be used since it does not honor Aspect Model formatting rules.
*
* @param model the input model
* @return the rendered model
*/
public static String modelToString( final Model model ) {
return RDFWriter.create().format( RDFFormat.TURTLE ).lang( RDFLanguages.TURTLE ).source( model ).asString();
}

/**
* Returns the List of named resources that transitively point to a given node. Transtively here means that the given node
* is reachable from the named resource via any number of anonymous nodes inbetween.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.eclipse.esmf.functions.ThrowingFunction;
import org.eclipse.esmf.metamodel.ModelElement;

import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -41,10 +40,8 @@ public abstract class Generator<F, I, T, C extends GenerationConfig, A extends A
/**
* The "focus" element, i.e., the main "input" for the generation process
*/
@Getter
protected final F focus;

@Getter
protected final C config;
protected final Comparator<ModelElement> uniqueByModelElementIdentifier = ( modelElementOne, modelElementTwo ) -> {
final String modelElementOneIdentifier = modelElementOne.urn().toString();
Expand Down Expand Up @@ -135,4 +132,12 @@ protected <E extends Throwable> void writeThrowing( final Artifact<I, T> artifac
LOG.error( "Failure during writing of generated artifact", exception );
}
}

public F getFocus() {
return focus;
}

public C getConfig() {
return config;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.Optional;

import org.eclipse.esmf.aspectmodel.AspectModelFile;
import org.eclipse.esmf.aspectmodel.RdfUtil;
import org.eclipse.esmf.aspectmodel.loader.AspectModelLoader;
import org.eclipse.esmf.aspectmodel.resolver.exceptions.ModelResolutionException;
import org.eclipse.esmf.aspectmodel.resolver.exceptions.ParserException;
Expand All @@ -51,8 +52,9 @@
public class AspectModelFileLoader {
public static RawAspectModelFile load( final File file ) {
try {
final RawAspectModelFile fromString = load( content( new FileInputStream( file ) ) );
return new RawAspectModelFile( fromString.sourceModel(), fromString.headerComment(), Optional.of( file.toURI() ) );
final String stringContent = content( new FileInputStream( file ) );
final RawAspectModelFile fromString = load( stringContent );
return new RawAspectModelFile( stringContent, fromString.sourceModel(), fromString.headerComment(), Optional.of( file.toURI() ) );
} catch ( final ModelResolutionException exception ) {
if ( exception.getMessage().startsWith( "Encountered invalid encoding" ) ) {
throw new ModelResolutionException( "Encountered invalid encoding in input file " + file, exception.getCause() );
Expand All @@ -71,7 +73,7 @@ public static RawAspectModelFile load( final String rdfTurtle ) {
}
final Model model = tryModel.getOrElseThrow(
() -> new ModelResolutionException( "Can not load model", tryModel.getCause() ) );
return new RawAspectModelFile( model, headerComment, Optional.empty() );
return new RawAspectModelFile( rdfTurtle, model, headerComment, Optional.empty() );
}

private static String content( final InputStream inputStream ) {
Expand All @@ -88,25 +90,25 @@ private static String content( final InputStream inputStream ) {
}

private static List<String> headerComment( final String content ) {
final List<String> list = content.lines()
return content.lines()
.dropWhile( String::isBlank )
.takeWhile( line -> line.startsWith( "#" ) )
.map( line -> line.substring( 1 ).trim() )
.toList();
return list;
}

public static RawAspectModelFile load( final InputStream inputStream ) {
return load( inputStream, Optional.empty() );
}

public static RawAspectModelFile load( final InputStream inputStream, final Optional<URI> sourceLocation ) {
final AspectModelFile fromString = load( content( inputStream ) );
return new RawAspectModelFile( fromString.sourceModel(), fromString.headerComment(), sourceLocation );
final String stringContent = content( inputStream );
final RawAspectModelFile fromString = load( stringContent );
return new RawAspectModelFile( stringContent, fromString.sourceModel(), fromString.headerComment(), sourceLocation );
}

public static RawAspectModelFile load( final Model model ) {
return new RawAspectModelFile( model, List.of(), Optional.empty() );
return new RawAspectModelFile( RdfUtil.modelToString( model ), model, List.of(), Optional.empty() );
}

public static RawAspectModelFile load( final byte[] content, final Optional<URI> sourceLocation ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.eclipse.esmf.metamodel.Namespace;

import com.google.common.collect.ImmutableList;
import lombok.Getter;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -63,7 +62,6 @@ public class NamespacePackage implements ResolutionStrategy, Artifact<URI, byte[
private static final String ASPECT_MODELS_FOLDER = "aspect-models";

// Fields that are always set
@Getter
private final String modelsRoot;
private final List<AspectModelFile> files;

Expand Down Expand Up @@ -176,7 +174,7 @@ private List<AspectModelFile> loadZipContent() {
if ( entry.getName().startsWith( modelsRoot ) && entry.getName().endsWith( ".ttl" ) ) {
final RawAspectModelFile rawFile = AspectModelFileLoader.load( inputStream,
Optional.of( constructLocationForFile( entry.getName() ) ) );
builder.add( migrate( rawFile ) );
builder.add( rawFile );
}
}
} catch ( final IOException exception ) {
Expand All @@ -186,10 +184,6 @@ private List<AspectModelFile> loadZipContent() {
return builder.build();
}

private AspectModelFile migrate( final AspectModelFile file ) {
return MetaModelVersionMigrator.INSTANCE.apply( file );
}

@Override
public Stream<URI> listContents() {
if ( content == null ) {
Expand Down Expand Up @@ -219,9 +213,19 @@ public Stream<URI> listContentsForNamespace( final AspectModelUrn namespace ) {
uri.toString().contains( pathToFilter ) );
}

/**
* Similar to {@link #loadContents()} except files are not automatically migrated to the latest SAMM version.
*
* @return The stream of files
*/
public Stream<AspectModelFile> loadLiteralFiles() {
return files.stream();
}

@Override
public Stream<AspectModelFile> loadContents() {
return files.stream();
return files.stream()
.map( MetaModelVersionMigrator.INSTANCE );
}

@Override
Expand Down Expand Up @@ -314,8 +318,11 @@ public byte[] serialize() {
*
* @return the location if set, or null
*/
@SuppressWarnings( { "LombokGetterMayBeUsed", "RedundantSuppression" } )
public URI getLocation() {
return location;
}

public String getModelsRoot() {
return modelsRoot;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn;

import lombok.Getter;

@Getter
public class ModelResolutionException extends RuntimeException {
public record LoadingFailure(
AspectModelUrn element,
Expand Down Expand Up @@ -56,4 +53,8 @@ public ModelResolutionException( final String message, final Throwable cause ) {
super( message, cause );
checkedLocations = List.of();
}

public List<LoadingFailure> getCheckedLocations() {
return checkedLocations;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.eclipse.esmf.metamodel.ModelElement;
import org.eclipse.esmf.metamodel.Namespace;

import lombok.Setter;
import org.apache.jena.rdf.model.Model;

/**
Expand All @@ -33,9 +32,7 @@ public final class DefaultAspectModelFile implements AspectModelFile {
private final Model sourceModel;
private final List<String> headerComment;
private final Optional<URI> sourceLocation;
@Setter
private List<ModelElement> elements;
@Setter
private Namespace namespace = null;

public DefaultAspectModelFile( final Model sourceModel, final List<String> headerComment, final Optional<URI> sourceLocation ) {
Expand Down Expand Up @@ -99,4 +96,12 @@ public int hashCode() {
public String toString() {
return sourceLocation().map( URI::toString ).orElse( "(unknown file)" );
}

public void setElements( final List<ModelElement> elements ) {
this.elements = elements;
}

public void setNamespace( final Namespace namespace ) {
this.namespace = namespace;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Streams;
import io.vavr.Tuple2;
import lombok.Getter;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Property;
Expand Down Expand Up @@ -71,9 +70,7 @@ public enum MetaModelFileType {
SHAPE_DEFINITION
}

@Getter
private final RdfNamespace rdfNamespace;
@Getter
private final MetaModelFileType metaModelFileType;
private final Model sourceModel;
private final String filename;
Expand Down Expand Up @@ -226,4 +223,12 @@ private URL url( final String section, final String filename ) {
throw new AspectLoadingException( "Could not resolve meta model file: " + filename );
}
}

public RdfNamespace getRdfNamespace() {
return rdfNamespace;
}

public MetaModelFileType getMetaModelFileType() {
return metaModelFileType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
@SuppressWarnings( "OptionalUsedAsFieldOrParameterType" )
@RecordBuilder
public record RawAspectModelFile(
String sourceRepresentation,
Model sourceModel,
List<String> headerComment,
Optional<URI> sourceLocation )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.esmf.aspectmodel.AspectModelFile;
import org.eclipse.esmf.aspectmodel.RdfUtil;
import org.eclipse.esmf.aspectmodel.loader.AspectModelLoader;
import org.eclipse.esmf.aspectmodel.resolver.modelfile.RawAspectModelFile;
import org.eclipse.esmf.aspectmodel.resolver.modelfile.RawAspectModelFileBuilder;
import org.eclipse.esmf.metamodel.Aspect;
import org.eclipse.esmf.metamodel.AspectModel;
Expand Down Expand Up @@ -147,6 +148,9 @@ public String aspectToString( final Aspect aspect ) {
* @return the String representation in RDF/Turtle
*/
public String aspectModelFileToString( final AspectModelFile aspectModelFile ) {
if ( aspectModelFile instanceof final RawAspectModelFile rawAspectModelFile ) {
return rawAspectModelFile.sourceRepresentation();
}
final StringWriter stringWriter = new StringWriter();
try ( final PrintWriter printWriter = new PrintWriter( stringWriter ) ) {
final PrettyPrinter prettyPrinter = new PrettyPrinter( aspectModelFile, printWriter );
Expand Down
Loading
Loading