Skip to content

Commit

Permalink
fix: Move filtered Constants to hawkeye-core (#88)
Browse files Browse the repository at this point in the history
This closes #85.

Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun authored Aug 28, 2023
1 parent e75b11d commit f4aec05
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ jobs:
tags: ${{matrix.name}}:ci
outputs: type=docker
- name: Sanity check
run: docker run --rm -v $(pwd):/github/workspace ${{matrix.name}}:ci check
run: |
docker run --rm -v $(pwd):/github/workspace ${{matrix.name}}:ci -V
docker run --rm -v $(pwd):/github/workspace ${{matrix.name}}:ci check
required:
name: Required
Expand Down
9 changes: 0 additions & 9 deletions hawkeye-command/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,4 @@
<artifactId>slf4j-simple</artifactId>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@
public class CommandOptions {
@CommandLine.Option(names = "--config", description = "path to the config file", defaultValue = "licenserc.toml")
public File config;

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

package io.korandoru.hawkeye.command;

import io.korandoru.hawkeye.core.Constants;
import picocli.CommandLine;

public class HawkEyeVersionProvider implements CommandLine.IVersionProvider {
@Override
public String[] getVersion() {
return new String[] { CommandConstants.VERSION };
return new String[] { Constants.VERSION };
}
}
12 changes: 12 additions & 0 deletions hawkeye-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,16 @@
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources-filtered</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@
* limitations under the License.
*/

package io.korandoru.hawkeye.command;
package io.korandoru.hawkeye.core;

import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.util.Properties;
import lombok.experimental.UtilityClass;

public final class CommandConstants {
@UtilityClass
public class Constants {
public static final String UNKNOWN = "<unknown>";
public static final String VERSION;

static {
ClassLoader classLoader = CommandConstants.class.getClassLoader();
ClassLoader classLoader = Constants.class.getClassLoader();
try (InputStream is = classLoader.getResourceAsStream("hawkeye.properties")) {
final Properties properties = new Properties();
properties.load(is);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"includes": [
{
"pattern": ".*\\.txt"
},
{
"pattern": "hawkeye.properties"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2023 Korandoru Contributors
*
* Licensed 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 io.korandoru.hawkeye.core;

import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;

class ConstantsTest {
@Test
void testVersion() {
assertThat(Constants.VERSION).isNotEqualTo(Constants.UNKNOWN);
}
}

0 comments on commit f4aec05

Please sign in to comment.