-
Notifications
You must be signed in to change notification settings - Fork 1
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
Generate Dash License Report #3
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Checking dependencies with dash-license tool | ||
description: Check an input file via dash, and archive report. Print output in build step summary. Requires wget and an JRE on the runner | ||
|
||
inputs: | ||
dashinput: | ||
required: true | ||
type: string | ||
description: "Dash Input file" | ||
|
||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "Run Dash" | ||
shell: bash | ||
run: | | ||
wget -O dash.jar "https://repo.eclipse.org/service/local/artifact/maven/redirect?r=dash-licenses&g=org.eclipse.dash&a=org.eclipse.dash.licenses&v=LATEST" | ||
java -jar dash.jar -summary ${{ inputs.dashinput }}.report ${{ inputs.dashinput }} > ${{ inputs.dashinput }}.out 2>&1 || true | ||
echo -e "Dash output: \n\`\`\` " >> $GITHUB_STEP_SUMMARY | ||
cat ${{ inputs.dashinput }}.out >> $GITHUB_STEP_SUMMARY | ||
echo -e "\n\`\`\`" | ||
|
||
- name: "Archive dash artifacts" | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: "Dash data" | ||
path: | | ||
${{ inputs.dashinput }} | ||
${{ inputs.dashinput }}.report | ||
${{ inputs.dashinput }}.out |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
/* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
import org.jetbrains.kotlin.incremental.createDirectory | ||
|
||
plugins { | ||
base | ||
detekt | ||
|
@@ -6,6 +27,7 @@ plugins { | |
subprojects { | ||
apply { | ||
plugin("ktlint") | ||
from("$rootDir/dash.gradle.kts") | ||
} | ||
afterEvaluate { | ||
tasks.check { | ||
|
@@ -22,3 +44,40 @@ subprojects { | |
systemProperties = systemPropertiesMap | ||
} | ||
} | ||
|
||
tasks.register("mergeDashFiles") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would have prefered to put this into "dash.gradle.kts" to make it "re-usable" but unfortunately this task is only needed by the root project,... maybe it makes sense to think about a convention like naming this like dash.root.gradle.kts or so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree as soon as it makes sense to extract this one. Currently it is still pretty clean. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
execute it using ./gradlew clean mergeDashFiles There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like this could be a good code comment. Maybe add something like this in the next PR. |
||
group = "oss" | ||
|
||
dependsOn( | ||
subprojects.map { subproject -> | ||
subproject.tasks.getByName("createDashFile") | ||
}, | ||
) | ||
|
||
doLast { | ||
val sortedLinesSet = sortedSetOf<String>() | ||
files("build/oss").asFileTree.forEach { file -> | ||
if (file.name != "dependencies.txt") return@forEach | ||
|
||
file.useLines { | ||
sortedLinesSet.addAll(it) | ||
} | ||
} | ||
|
||
val folder = File("$rootDir/build/oss/all") | ||
folder.createDirectory() | ||
|
||
val file = File("$folder/all-dependencies.txt") | ||
if (file.exists()) { | ||
file.delete() | ||
} | ||
file.createNewFile() | ||
|
||
val bufferedWriter = file.bufferedWriter() | ||
bufferedWriter.use { writer -> | ||
sortedLinesSet.forEach { line -> | ||
writer.write(line + System.lineSeparator()) | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# | ||
# Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# | ||
|
||
projectName=$1 | ||
folder=build/oss/"$projectName" | ||
fileName=dependencies.txt | ||
|
||
mkdir -p "$folder" | ||
|
||
# dependencies may look like the following: | ||
# androidx.compose.ui:ui-test-manifest -> 1.5.0 | ||
# org.jetbrains.kotlin:kotlin-stdlib:1.9.0 | ||
# androidx.activity:activity:1.2.1 -> 1.7.2 (*) | ||
# androidx.compose.ui:ui:1.5.0 (c) | ||
# androidx.compose.ui:ui-tooling (n) | ||
# androidx.compose.ui:ui-tooling FAILED | ||
|
||
# https://github.com/eclipse/dash-licenses#example-gradle | ||
|
||
# the following adaptions were done: | ||
# - filter entries marked with (n) = not resolvable | ||
# - filter entries marked FAILED | ||
# - filter entries referencing a (sub-)project | ||
# - change normalization step to be compatible with jetpack compose (androidx.compose.ui:ui-test-manifest -> 1.5.0) | ||
|
||
unameOut="$(uname -s)" | ||
case "${unameOut}" in | ||
Linux*) GREP="grep";; # Linux | ||
Darwin*) GREP="ggrep";; # Mac | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To test this on Mac ggrep needs to be installed |
||
*) GREP="UNKNOWN:${unameOut}" | ||
esac | ||
echo "${GREP}" | ||
|
||
./gradlew "$projectName":dependencies \ | ||
| ${GREP} -Poh "(?<=\-\-\- ).*" \ | ||
| ${GREP} -Pv "\([nc\*]\)" \ | ||
| ${GREP} -Pv "FAILED" \ | ||
| ${GREP} -Pv "project :[a-zA-Z0-9]+" \ | ||
| perl -pe 's/([\w\.\-]+):([\w\.\-]+):(?:[\w\.\-]+ -> )?([\w\.\-]+).*$/$1:$2:$3/gmi;t' \ | ||
| perl -pe 's/([\w\.\-]+):([\w\.\-]+) -> ([\w\.\-]+).*$/$1:$2:$3/gmi;t' \ | ||
| sort -u \ | ||
Comment on lines
+50
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is most probably a lot of potential to "optimize"/"shrink" these terms / number of lines. I tried some stuff, but always lead to something breaking. Reducing number of lines obviously also means increasing the complexity to understand each terms, so I left it for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine for me for now :) |
||
> "$folder"/"$fileName" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
tasks.register<Exec>("createDashFile") { | ||
group = "oss" | ||
|
||
workingDir("$rootDir") | ||
commandLine("buildscripts/dash.sh") | ||
args(project.name) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken from here: https://github.com/eclipse/kuksa.val/blob/master/.github/actions/check-dash/action.yml