Skip to content

Commit

Permalink
fix_version (DataLinkDC#2474)
Browse files Browse the repository at this point in the history
  • Loading branch information
zackyoungh authored Nov 1, 2023
1 parent be13e0c commit e506a27
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

package org.dinky.configure;

import org.dinky.DinkyVersion;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.CorsEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementPortType;
Expand Down Expand Up @@ -61,8 +62,7 @@
@Import(BeanValidatorPluginsConfiguration.class)
public class Knife4jConfig {

@Value("${dinky.version}")
private String dinkyVersion;
private final String dinkyVersion = DinkyVersion.getVersion();

private final OpenApiExtensionResolver openApiExtensionResolver;

Expand Down
2 changes: 0 additions & 2 deletions dinky-admin/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ sa-token:
knife4j:
enable: true

dinky:
version: ${revision}
sms:
is-print: false

Expand Down
21 changes: 21 additions & 0 deletions dinky-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,25 @@
</dependency>
</dependencies>

<build>
<resources>
<!-- Replace maven global variables -->
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>common.properties</include>
</includes>
</resource>
<!-- Keep files with variables that are not replaced -->
<resource>
<filtering>false</filtering>
<directory>src/main/resources</directory>
<excludes>
<exclude>common.properties</exclude>
</excludes>
</resource>
</resources>

</build>
</project>
39 changes: 39 additions & 0 deletions dinky-common/src/main/java/org/dinky/DinkyVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
*
* 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.dinky;

import cn.hutool.setting.dialect.Props;

public final class DinkyVersion {
private DinkyVersion() {}

/**
* Return the full version string of the present Dinky codebase.
*
* @return the version of Dinky
*/
public static String getVersion() {
try {
return Props.getProp("common.properties").getProperty("version");
} catch (Exception e) {
return "${revision}";
}
}
}
1 change: 1 addition & 0 deletions dinky-common/src/main/resources/common.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=${project.version}

0 comments on commit e506a27

Please sign in to comment.