Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce usage of external content on website #606

Merged
merged 18 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 56 additions & 15 deletions codyze-v2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.gradle.kotlin.dsl.attributes

plugins {
// built-in
Expand All @@ -22,6 +23,13 @@ plugins {
kotlin("jvm") version "1.7.20"
}

// Allow access to Dokka configuration for custom assets and stylesheets
buildscript {
dependencies {
classpath("org.jetbrains.dokka:dokka-base:1.7.10")
}
}

group = "de.fraunhofer.aisec"

/* License plugin needs a special treatment, as long as the main project does not have a license yet.
Expand All @@ -35,8 +43,10 @@ gradle.startParameter.excludedTaskNames += ":codyze-v2:licenseTest"
tasks {
jar {
manifest {
attributes("Implementation-Title" to "codyze",
"Implementation-Version" to archiveVersion.getOrElse("0.0.0-dev"))
attributes(
"Implementation-Title" to "codyze",
"Implementation-Version" to archiveVersion.getOrElse("0.0.0-dev")
)
}
}
}
Expand All @@ -59,13 +69,14 @@ repositories {
mavenLocal()
mavenCentral()

maven { setUrl("https://jitpack.io") }

maven {
setUrl("https://jitpack.io")
}

// NOTE: Remove this when we "release". this is the public sonatype repo which is used to
// sync to maven central, but directly adding this repo is faster than waiting for a maven central sync,
// which takes 8 hours in the worse case. so it is useful during heavy development but should be removed
// if everything is more stable
// sync to maven central, but directly adding this repo is faster than waiting for a maven
// central sync, which takes 8 hours in the worse case. so it is useful during heavy
// development but should be removed if everything is more stable
maven {
setUrl("https://oss.sonatype.org/content/groups/public")
}
Expand Down Expand Up @@ -114,10 +125,8 @@ dependencies {
api("de.fraunhofer.aisec:cpg-core:4.6.3")
implementation("de.fraunhofer.aisec:cpg-analysis:4.6.3")

// MARK DSL (use fat jar). changing=true circumvents gradle cache
//api("de.fraunhofer.aisec.mark:de.fraunhofer.aisec.mark:1.4.0-SNAPSHOT:repackaged") { isChanging = true } // ok
//api("com.github.Fraunhofer-AISEC.codyze-mark-eclipse-plugin:de.fraunhofer.aisec.mark:bbd54a7b11:repackaged") // pin to specific commit before annotations
api("com.github.Fraunhofer-AISEC.codyze-mark-eclipse-plugin:de.fraunhofer.aisec.mark:2.0.0:repackaged") // use GitHub release via JitPack; e.g. exposed by de.fraunhofer.aisec.cpg.analysis.fsm.FSMBuilder
// MARK DSL; use GitHub release via JitPack; e.g. exposed by de.fraunhofer.aisec.cpg.analysis.fsm.FSMBuilder
api("com.github.Fraunhofer-AISEC.codyze-mark-eclipse-plugin:de.fraunhofer.aisec.mark:2.0.0:repackaged")

// Pushdown Systems
api("de.breakpointsec:pushdown:1.1") // e.g., exposed in de.fraunhofer.aisec.codyze.analysis.wpds
Expand Down Expand Up @@ -192,7 +201,6 @@ spotless {
targetExclude("build/generated/**/*.java")
eclipse().configFile(rootProject.file("formatter-settings.xml"))
}

kotlin {
ktfmt().kotlinlangStyle()
}
Expand All @@ -209,7 +217,11 @@ tasks.named<CreateStartScripts>("startScripts") {
*
* The problem doesn't seem to exist in the current version, but may reappear, so we're keeping this one around.
*/
windowsScript.writeText(windowsScript.readText().replace(Regex("set CLASSPATH=.*"), "set CLASSPATH=%APP_HOME%\\\\lib\\\\*"))
windowsScript.writeText(
windowsScript
.readText()
.replace(Regex("set CLASSPATH=.*"), "set CLASSPATH=%APP_HOME%\\\\lib\\\\*")
)
}
}

Expand All @@ -230,6 +242,35 @@ jsonSchema2Pojo {
// ... more options
}

// generate API documentation
tasks.dokkaHtml.configure {
outputDirectory.set(projectDir.resolve("..").resolve("docs").resolve("api").resolve("codyze-v2"))
// add API docs to directory used for website generation
outputDirectory.set(
project.rootDir.resolve("..").resolve("docs").resolve("api").resolve("codyze-v2")
)
// path to Dokka assets
val dokkaAssetsBaseDirectory =
project.rootDir.resolve("..").resolve("docs").resolve("assets").resolve("dokka")
// configure custom assets
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
// use custom stylesheets without external content
customStyleSheets =
listOf(
dokkaAssetsBaseDirectory.resolve("style.css"),
dokkaAssetsBaseDirectory.resolve("jetbrains-mono.css"),
)
}
// copy over font files
dokkaAssetsBaseDirectory
.resolve("JetBrainsMono")
.copyRecursively(
target = outputDirectory.get().resolve("styles").resolve("JetBrainsMono"),
overwrite = true,
)
dokkaAssetsBaseDirectory
.resolve("inter")
.copyRecursively(
target = outputDirectory.get().resolve("styles").resolve("inter"),
overwrite = true,
)
}
34 changes: 33 additions & 1 deletion codyze-v3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration

allprojects {
group = "de.fraunhofer.aisec.codyze"
version = if (version != Project.DEFAULT_VERSION) version else "0.0.0-SNAPSHOT"
Expand All @@ -7,8 +10,37 @@ plugins {
id("documented")
}

// generate API documentation for website
tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(projectDir.resolve("..").resolve("docs").resolve("api").resolve("codyze-v3"))
// add API docs to directory used for website generation
outputDirectory.set(
project.rootDir.resolve("..").resolve("docs").resolve("api").resolve("codyze-v3")
)
// path to Dokka assets
val dokkaAssetsBaseDirectory =
project.rootDir.resolve("..").resolve("docs").resolve("assets").resolve("dokka")
// configure custom assets
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
// use custom stylesheets without external content
customStyleSheets =
listOf(
dokkaAssetsBaseDirectory.resolve("style.css"),
dokkaAssetsBaseDirectory.resolve("jetbrains-mono.css"),
)
}
// copy over font files
dokkaAssetsBaseDirectory
.resolve("JetBrainsMono")
.copyRecursively(
target = outputDirectory.get().resolve("styles").resolve("JetBrainsMono"),
overwrite = true,
)
dokkaAssetsBaseDirectory
.resolve("inter")
.copyRecursively(
target = outputDirectory.get().resolve("styles").resolve("inter"),
overwrite = true,
)
}

// adapted from https://blog.mrhaki.com/2021/03/gradle-goodness-create-properties-file.html
Expand Down
3 changes: 3 additions & 0 deletions codyze-v3/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ dependencies {
implementation(libs.spotless.gradle)
implementation(libs.license.gradle)
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) // this is only there to be able to import 'LibrariesForLibs' in the convention plugins

// additional dependencies used by plugins, e.g. for configuring tasks
implementation(libs.dokka.base)
}
44 changes: 40 additions & 4 deletions codyze-v3/buildSrc/src/main/kotlin/documented.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,23 +1,59 @@
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import java.net.URL
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.dokka.gradle.DokkaTaskPartial

plugins {
id("org.jetbrains.dokka")
}

repositories {
mavenCentral()
}

// configure partial generation for multi module
tasks.withType<DokkaTaskPartial>().configureEach {
dokkaSourceSets {
configureEach {
sourceLink {
localDirectory.set(file("src/main/kotlin"))
// ensure we're including path segment to module
remoteUrl.set(URL("https://github.com/Fraunhofer-AISEC/codyze/blob/main/codyze-v3/${project.projectDir.relativeTo(project.rootDir)}/src/main/kotlin"))
remoteUrl.set(
URL(
"https://github.com/Fraunhofer-AISEC/codyze/blob/main/codyze-v3/${project.projectDir.relativeTo(project.rootDir)}/src/main/kotlin"
)
)
remoteLineSuffix.set("#L")
}
}
}
}

repositories {
mavenCentral()
// configure task for individual module
tasks.withType<DokkaTask>().configureEach {
// path to Dokka assets
val dokkaAssetsBaseDirectory = project.rootDir.resolve("..").resolve("docs").resolve("assets").resolve("dokka")
// configure custom assets
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
// use custom stylesheets without external content
customStyleSheets =
listOf(
dokkaAssetsBaseDirectory.resolve("style.css"),
dokkaAssetsBaseDirectory.resolve("jetbrains-mono.css"),
)
}
// copy over font files
dokkaAssetsBaseDirectory
.resolve("JetBrainsMono")
.copyRecursively(
target = outputDirectory.get().resolve("styles").resolve("JetBrainsMono"),
overwrite = true,
)
dokkaAssetsBaseDirectory
.resolve("inter")
.copyRecursively(
target = outputDirectory.get().resolve("styles").resolve("inter"),
overwrite = true,
)
}
4 changes: 4 additions & 0 deletions codyze-v3/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ sonarqube-gradle = { module = "org.sonarsource.scanner.gradle:sonarqube-gradle-p
spotless-gradle = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "6.11.0" }
license-gradle = { module = "com.github.hierynomus.license:com.github.hierynomus.license.gradle.plugin", version = "0.16.1" }

# additional dependencies for plugins in buildSrc
dokka-base = { module = "org.jetbrains.dokka:dokka-base", version.ref = "kotlin" }


[bundles]
cpg = ["cpg-core", "cpg-analysis"]

Expand Down
10 changes: 10 additions & 0 deletions docs/assets/dokka/JetBrainsMono/AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This is the official list of project authors for copyright purposes.
# This file is distinct from the CONTRIBUTORS.txt file.
# See the latter for an explanation.
#
# Names should be added to this file as:
# Name or Organization <email address>

JetBrains <>
Philipp Nurullin <philipp.nurullin@jetbrains.com>
Konstantin Bulenkov <kb@jetbrains.com>
93 changes: 93 additions & 0 deletions docs/assets/dokka/JetBrainsMono/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)

This Font Software is licensed under the SIL Open Font License, Version 1.1.

This license is copied below, and is also available with a FAQ at: https://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading