Skip to content

Commit

Permalink
support 'requires static' and 'requires transitive'
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo committed Apr 21, 2022
1 parent 27452f1 commit be47a3f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ Maven:
<dependency>
<groupId>org.glavo</groupId>
<artifactId>module-info-compiler</artifactId>
<version>1.3</version>
<version>1.5</version>
</dependency>
```

Gradle:

```kotlin
implementation("org.glavo:module-info-compiler:1.3")
implementation("org.glavo:module-info-compiler:1.5")
```

### Gradle Task (`CompileModuleInfo`)
Expand All @@ -58,7 +58,7 @@ buildscript {
}

dependencies {
classpath("org.glavo:module-info-compiler:1.3")
classpath("org.glavo:module-info-compiler:1.5")
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ allprojects {
}

group = "org.glavo"
version = "1.4"// + "-SNAPSHOT"
version = "1.5"// + "-SNAPSHOT"

repositories {
mavenCentral()
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/glavo/mic/ModuleInfoCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.javaparser.ParseProblemException;
import com.github.javaparser.StaticJavaParser;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.Modifier;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.expr.Name;
import com.github.javaparser.ast.modules.*;
Expand Down Expand Up @@ -102,7 +103,16 @@ public void compile(Reader source, OutputStream target) throws IOException {
} else if (directive.isModuleRequiresDirective()) {
ModuleRequiresDirective requires = directive.asModuleRequiresDirective();
if (!requires.getNameAsString().equals("java.base")) {
moduleVisitor.visitRequire(requires.getNameAsString(), 0, null);
int access = 0;
for (Modifier modifier : requires.getModifiers()) {
if (modifier.getKeyword() == Modifier.Keyword.STATIC) {
access |= Opcodes.ACC_STATIC_PHASE;
} else if (modifier.getKeyword() == Modifier.Keyword.TRANSITIVE) {
access |= Opcodes.ACC_TRANSITIVE;
}
}

moduleVisitor.visitRequire(requires.getNameAsString(), access, null);
}
} else if (directive.isModuleUsesDirective()) {
ModuleUsesDirective uses = directive.asModuleUsesDirective();
Expand Down

0 comments on commit be47a3f

Please sign in to comment.