Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Add version template #24

Merged
merged 3 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
43 changes: 16 additions & 27 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,18 @@
<maven.compiler.target>11</maven.compiler.target>
</properties>

<profiles>
<profile>
<id>release</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven.javadoc.version}</version>
<executions>
<execution>
<id>javadoc-aggregate-jar</id>
<phase>package</phase>
<inherited>false</inherited>
<goals>
<goal>aggregate-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -110,6 +95,10 @@
<groupId>com.powsybl</groupId>
<artifactId>powsybl-commons</artifactId>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-tools</artifactId>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright (c) 2021, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.nad.util;

import com.google.auto.service.AutoService;
import com.powsybl.tools.*;

/**
* @author Florian Dupuy <florian.dupuy at rte-france.com>
*/
@AutoService(Version.class)
public class PowsyblNetworkAreaDiagramVersion extends AbstractVersion {

public PowsyblNetworkAreaDiagramVersion() {
super("powsybl-network-area-diagram", "${project.version}", "${buildNumber}", "${scmBranch}", Long.parseLong("${timestamp}"));
}
}
9 changes: 8 additions & 1 deletion src/main/java/com/powsybl/nad/NetworkAreaDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@

import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.VoltageLevel;
import com.powsybl.nad.build.iidm.VoltageLevelFilter;
import com.powsybl.nad.build.iidm.IdProvider;
import com.powsybl.nad.build.iidm.IntIdProvider;
import com.powsybl.nad.build.iidm.NetworkGraphBuilder;
import com.powsybl.nad.build.iidm.VoltageLevelFilter;
import com.powsybl.nad.layout.BasicForceLayoutFactory;
import com.powsybl.nad.layout.LayoutFactory;
import com.powsybl.nad.layout.LayoutParameters;
import com.powsybl.nad.model.Graph;
import com.powsybl.nad.svg.*;
import com.powsybl.nad.util.PowsyblNetworkAreaDiagramVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.StringWriter;
Expand All @@ -31,6 +34,8 @@
*/
public class NetworkAreaDiagram {

private static final Logger LOGGER = LoggerFactory.getLogger(NetworkAreaDiagram.class);

private final Network network;
private final Predicate<VoltageLevel> voltageLevelFilter;

Expand Down Expand Up @@ -84,6 +89,8 @@ public void draw(Path svgFile, SvgParameters svgParameters, LayoutParameters lay
Objects.requireNonNull(layoutFactory);
Objects.requireNonNull(idProvider);

LOGGER.info("Version: {}", new PowsyblNetworkAreaDiagramVersion());
Copy link
Member

Choose a reason for hiding this comment

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

I would not write it here. That would be done by for instance network-area-diagram-server at startup so just one time.


Graph graph = new NetworkGraphBuilder(network, voltageLevelFilter, idProvider).buildGraph();
layoutFactory.create().run(graph, layoutParameters);
new SvgWriter(svgParameters, styleProvider, labelProvider).writeSvg(graph, svgFile);
Expand Down