Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
 - build dependencies (plugins)
 - project dependencies
 - javaparser 3.6 broke compatibility by removing static configuration in favor of instance configuration
  • Loading branch information
aalmiray authored and paulbakker committed Apr 4, 2019
1 parent bdf09c4 commit 05f8f16
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
22 changes: 11 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'com.gradle.build-scan' version '2.1'
id 'com.gradle.build-scan' version '2.2.1'
id 'eclipse'
id 'java'
id 'java-gradle-plugin'
id 'com.gradle.plugin-publish' version '0.10.0'
id 'maven-publish' // used for publishing to local maven repository
id 'com.github.johnrengelman.shadow' version '4.0.4'
id 'com.gradle.plugin-publish' version '0.10.1'
id 'com.github.johnrengelman.shadow' version '5.0.0'
id 'com.github.ben-manes.versions' version '0.21.0'
}

buildScan {
Expand All @@ -24,18 +24,18 @@ repositories {
}

configurations {
plugin.description = 'Plugin\'s dependencies'
plugin.description = "Plugin's dependencies"
compile.extendsFrom plugin
}

dependencies {
implementation gradleApi()
plugin 'com.github.javaparser:javaparser-symbol-solver-core:3.6.23'
plugin 'com.github.javaparser:javaparser-symbol-solver-core:3.13.5'

testImplementation gradleTestKit()
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.1'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.4.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.1'
}

shadowJar {
Expand Down Expand Up @@ -63,14 +63,14 @@ test {
}

task createClasspathManifest {
def outputDir = file("$buildDir/$name")
File outputDir = file("$buildDir/$name")

inputs.files sourceSets.main.runtimeClasspath
outputs.dir outputDir

doLast {
outputDir.mkdirs()
file("$outputDir/plugin-classpath.txt").text = sourceSets.main.runtimeClasspath.join("\n")
file("$outputDir/plugin-classpath.txt").text = sourceSets.main.runtimeClasspath.join('\n')
}
}

Expand Down
22 changes: 15 additions & 7 deletions src/main/java/org/javamodularity/moduleplugin/ModuleName.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.javaparser.JavaParser;
import com.github.javaparser.ParserConfiguration;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.expr.Name;
import com.github.javaparser.ast.modules.ModuleDeclaration;
import org.gradle.api.Project;
Expand Down Expand Up @@ -39,14 +40,21 @@ Optional<String> findModuleName(Project project) {
if (moduleInfoSrcDir.isPresent()) {
Path moduleInfoJava = moduleInfoSrcDir.get().toPath().resolve("module-info.java");
try {
JavaParser.getStaticConfiguration().setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_11);
Optional<ModuleDeclaration> module = JavaParser.parse(moduleInfoJava).getModule();
if (module.isPresent()) {
Name name = module.get().getName();
LOGGER.lifecycle("Found module name '{}'", name);
return Optional.of(name.toString());
JavaParser parser = new JavaParser();
parser.getParserConfiguration().setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_11);
Optional<CompilationUnit> compilationUnit = parser.parse(moduleInfoJava).getResult();
if (compilationUnit.isPresent()) {
Optional<ModuleDeclaration> module = compilationUnit.get().getModule();
if (module.isPresent()) {
Name name = module.get().getName();
LOGGER.lifecycle("Found module name '{}'", name);
return Optional.of(name.toString());
} else {
LOGGER.warn("module-info.java found, but module name could not be parsed");
return Optional.empty();
}
} else {
LOGGER.warn("module-info.java found, but module name could not be parsed");
LOGGER.debug("Compilation unit is empty");
return Optional.empty();
}
} catch (IOException e) {
Expand Down

0 comments on commit 05f8f16

Please sign in to comment.