From 0c2e714a07ffbaa0b1a76719e7bf8565c43e6471 Mon Sep 17 00:00:00 2001 From: rschoene <rene.schoene@tu-dresden.de> Date: Fri, 15 Jan 2021 20:06:40 +0100 Subject: [PATCH] Publish uses jar instead of components.java. - moved some bits to convention plugins --- ...relast2uml.java-jastadd-conventions.gradle | 4 ++ ...ast2uml.java-publishing-conventions.gradle | 40 +++++++++++++++---- dumpAst/build.gradle | 31 -------------- dumpAstWithPlantuml/build.gradle | 26 ------------ .../dumpAstWithPlantumlVersion.properties | 1 + grammar2uml/build.gradle | 40 +++---------------- testDumper/build.gradle | 4 -- 7 files changed, 43 insertions(+), 103 deletions(-) create mode 120000 dumpAstWithPlantuml/src/main/resources/dumpAstWithPlantumlVersion.properties diff --git a/buildSrc/src/main/groovy/relast2uml.java-jastadd-conventions.gradle b/buildSrc/src/main/groovy/relast2uml.java-jastadd-conventions.gradle index 99218f1..d773a87 100644 --- a/buildSrc/src/main/groovy/relast2uml.java-jastadd-conventions.gradle +++ b/buildSrc/src/main/groovy/relast2uml.java-jastadd-conventions.gradle @@ -6,3 +6,7 @@ plugins { dependencies { api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11' } + +File genSrc = file("src/gen/java") +sourceSets.main.java.srcDir genSrc +idea.module.generatedSourceDirs += genSrc diff --git a/buildSrc/src/main/groovy/relast2uml.java-publishing-conventions.gradle b/buildSrc/src/main/groovy/relast2uml.java-publishing-conventions.gradle index a161f52..0a5d763 100644 --- a/buildSrc/src/main/groovy/relast2uml.java-publishing-conventions.gradle +++ b/buildSrc/src/main/groovy/relast2uml.java-publishing-conventions.gradle @@ -15,20 +15,46 @@ dependencies { testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "${jupiter_version}" } -tasks.named('test') { - useJUnitPlatform() +jar { + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } +} + +def versionFile = "src/main/resources/${project.getName()}Version.properties" +def oldProps = new Properties() + +try { + file(versionFile).withInputStream { stream -> oldProps.load(stream) } + version = oldProps['version'] +} catch (e) { + // this happens, if either the properties file is not present, or cannot be read from + throw new GradleException("File ${versionFile} not found or unreadable. Aborting.", e) +} + +task printVersion() { + doLast { + println(version) + } +} + +task newVersion() { + doFirst { + def props = new Properties() + props['version'] = value + props.store(file(versionFile).newWriter(), null) + } } //679 publishing { publications { maven(MavenPublication) { -// artifactId = 'dumpAst | dumpAstWithPlantuml | grammar2uml' groupId = 'de.tudresden.inf.st' - from components.java -// artifact("build/libs/ragconnect-${version}.jar") { -// extension 'jar' -// } +// from components.java + artifact("build/libs/${project.getName()}-${project.getVersion()}.jar") { + extension 'jar' + } } } repositories { diff --git a/dumpAst/build.gradle b/dumpAst/build.gradle index fed51c2..b679314 100644 --- a/dumpAst/build.gradle +++ b/dumpAst/build.gradle @@ -18,37 +18,6 @@ dependencies { implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: "${mustache_java_version}" } -def versionFile = 'src/main/resources/dumpAstVersion.properties' -def oldProps = new Properties() - -try { - file(versionFile).withInputStream { stream -> oldProps.load(stream) } - version = oldProps['version'] -} catch (e) { - // this happens, if either the properties file is not present, or cannot be read from - throw new GradleException("File ${versionFile} not found or unreadable. Aborting.", e) -} - -task newVersion() { - doFirst { - def props = new Properties() - props['version'] = value - props.store(file(versionFile).newWriter(), null) - } -} - -jar { - from { - configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } - } - - archiveBaseName = 'dumpAst' -} - -File genSrc = file("src/gen/java") -sourceSets.main.java.srcDir genSrc -idea.module.generatedSourceDirs += genSrc - File dumpAstGrammar = file('./src/main/jastadd/DumpAst.relast') File mustacheGrammar = file('./src/main/jastadd/mustache/Mustache.relast') diff --git a/dumpAstWithPlantuml/build.gradle b/dumpAstWithPlantuml/build.gradle index 9105efc..03e3324 100644 --- a/dumpAstWithPlantuml/build.gradle +++ b/dumpAstWithPlantuml/build.gradle @@ -19,32 +19,6 @@ dependencies { implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: "${mustache_java_version}" } -def versionFile = '../dumpAst/src/main/resources/dumpAstVersion.properties' -def oldProps = new Properties() - -try { - file(versionFile).withInputStream { stream -> oldProps.load(stream) } - version = oldProps['version'] -} catch (e) { - // this happens, if either the properties file is not present, or cannot be read from - throw new GradleException("File ${versionFile} not found or unreadable. Aborting.", e) -} - -jar { - from { - configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } - } - - archiveBaseName = 'dumpAst-plantuml' -} - -// include resources of base dumpAst -sourceSets.main.resources.srcDirs += "../dumpAst/src/main/resources" - -File genSrc = file("src/gen/java") -sourceSets.main.java.srcDir genSrc -idea.module.generatedSourceDirs += genSrc - File dumpAstGrammar = file('../dumpAst/src/main/jastadd/DumpAst.relast') task relast(type: JavaExec) { diff --git a/dumpAstWithPlantuml/src/main/resources/dumpAstWithPlantumlVersion.properties b/dumpAstWithPlantuml/src/main/resources/dumpAstWithPlantumlVersion.properties new file mode 120000 index 0000000..19186b3 --- /dev/null +++ b/dumpAstWithPlantuml/src/main/resources/dumpAstWithPlantumlVersion.properties @@ -0,0 +1 @@ +../../../../dumpAst/src/main/resources/dumpAstVersion.properties \ No newline at end of file diff --git a/grammar2uml/build.gradle b/grammar2uml/build.gradle index c13cd21..78152a3 100644 --- a/grammar2uml/build.gradle +++ b/grammar2uml/build.gradle @@ -16,49 +16,19 @@ apply plugin: 'jastadd' application.mainClassName = 'de.tudresden.inf.st.jastadd.grammar2uml.compiler.Compiler' -dependencies { - implementation project(':relast.preprocessor') - - implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: "${mustache_java_version}" - runtime group: 'org.jastadd', name: 'jastadd', version: '2.3.4' -} - -def versionFile = 'src/main/resources/grammar2umlVersion.properties' -def oldProps = new Properties() - -try { - file(versionFile).withInputStream { stream -> oldProps.load(stream) } - version = oldProps['version'] -} catch (e) { - // this happens, if either the properties file is not present, or cannot be read from - throw new GradleException("File ${versionFile} not found or unreadable. Aborting.", e) -} - -task newVersion() { - doFirst { - def props = new Properties() - props['version'] = value - props.store(file(versionFile).newWriter(), null) - } -} - jar { manifest { attributes "Main-Class": application.mainClassName } +} - from { - configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } - // configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } - } +dependencies { + implementation project(':relast.preprocessor') - archiveBaseName = 'grammar2uml' + implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: "${mustache_java_version}" + runtime group: 'org.jastadd', name: 'jastadd', version: '2.3.4' } -File genSrc = file("src/gen/java") -sourceSets.main.java.srcDir genSrc -idea.module.generatedSourceDirs += genSrc - File preprocessorGrammar = file('../relast.preprocessor/src/main/jastadd/RelAst.relast') File grammar2umlGrammar = file('./src/main/jastadd/Grammar2Uml.relast') File intermediateGrammar = file('./src/main/jastadd/MustacheNodes.relast') diff --git a/testDumper/build.gradle b/testDumper/build.gradle index b8622c7..1c0603d 100644 --- a/testDumper/build.gradle +++ b/testDumper/build.gradle @@ -16,10 +16,6 @@ dependencies { testImplementation project(':dumpAst') } -File genSrc = file("src/gen/java") -sourceSets.main.java.srcDir genSrc -idea.module.generatedSourceDirs += genSrc - File testingGrammar = file('./src/main/jastadd/testDumper.relast') task relast(type: JavaExec) { -- GitLab