Skip to content

Commit

Permalink
Hadoop: change so ver to git hash (#4866)
Browse files Browse the repository at this point in the history
  • Loading branch information
tangyoupeng authored May 17, 2024
1 parent d10c26b commit a4d967d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/sdktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ jobs:
cd sdk/java
sudo mvn test -B
sudo mvn package -B -Dmaven.test.skip=true --quiet -Dmaven.javadoc.skip=true
expect=$(git rev-parse --short HEAD | cut -b 1-7)
ls /tmp/libjfs* | grep $expect
- name: Send Slack Notification
if: failure()
Expand Down
23 changes: 23 additions & 0 deletions sdk/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,29 @@
</avoidCallsTo>
</configuration>
</plugin>
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>4.9.9</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/juicefs-ver.properties</generateGitPropertiesFilename>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
Expand Down
17 changes: 14 additions & 3 deletions sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@
public class JuiceFileSystemImpl extends FileSystem {

public static final Logger LOG = LoggerFactory.getLogger(JuiceFileSystemImpl.class);
public static final String gitVer = loadVersion();

static String loadVersion() {
try (InputStream in = JuiceFileSystemImpl.class.getClassLoader().getResourceAsStream("juicefs-ver.properties")) {
Properties prop = new Properties();
prop.load(in);
return prop.getProperty("git.commit.id.abbrev");
} catch (IOException e) {
LOG.warn("Failed to load juicefs-ver.properties", e);
return "unknown";
}
}

private Path workingDir;
private String name;
Expand Down Expand Up @@ -611,11 +623,10 @@ public static Libjfs loadLibrary() {
LibraryLoader<Libjfs> libjfsLibraryLoader = LibraryLoader.create(Libjfs.class);
libjfsLibraryLoader.failImmediately();

int soVer = 7;
String osId = "so";
String archId = "amd64";
String resourceFormat = "libjfs-%s.%s.gz";
String nameFormat = "libjfs-%s.%d.%s";
String nameFormat = "libjfs-%s.%s.%s";

File dir = new File("/tmp");
String os = System.getProperty("os.name");
Expand All @@ -631,7 +642,7 @@ public static Libjfs loadLibrary() {
}

String resource = String.format(resourceFormat, archId, osId);
String name = String.format(nameFormat, archId, soVer, osId);
String name = String.format(nameFormat, archId, gitVer, osId);

File libFile = new File(dir, name);

Expand Down

0 comments on commit a4d967d

Please sign in to comment.