Skip to content

Commit

Permalink
Made build gradle 7.0 compatible #1085
Browse files Browse the repository at this point in the history
  • Loading branch information
de-jcup committed Feb 28, 2022
1 parent 4d440d2 commit 61f2938
Show file tree
Hide file tree
Showing 36 changed files with 205 additions and 152 deletions.
1 change: 1 addition & 0 deletions build-java.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ subprojects{
}

apply plugin: 'java'
apply plugin: 'java-library'

/* Setup UTF-8 for compile AND test compilation*/
[ compileJava, compileTestJava ]*.options*.encoding = 'UTF-8'
Expand Down
5 changes: 1 addition & 4 deletions build-maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

subprojects {

apply plugin: 'maven'

group = "com.mercedesbenz.sechub"


if (!projectType.publishedLibraries.contains(project)){
return;
Expand Down Expand Up @@ -75,7 +72,7 @@ subprojects {
}
}
}
}
}
}

}
Expand Down
36 changes: 17 additions & 19 deletions build-spring.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,51 +28,49 @@ subprojects {

dependencies {

testCompile(library.springboot_starter_test)
compile(library.springboot_starter_json)
testImplementation(library.springboot_starter_test)
implementation(library.springboot_starter_json)


if (projectType.springBootAdapterProjects.contains(project)){
// next line: compile only, because spring boot does add android-json on test compile as lightweight imp
//compile(library.openjson)

/* REST */
compile(library.jackson_JDK8)
compile(library.springboot_starter_web)
implementation(library.jackson_JDK8)
implementation(library.springboot_starter_web)


if (! project.name.equals('sechub-adapter')){
compile project(':sechub-adapter')
api project(':sechub-adapter')
}

testCompile library.wiremock
testCompile project(':sechub-testframework')
testImplementation library.wiremock
testImplementation project(':sechub-testframework')

}

if (projectType.springBootSecHubServerProjects.contains(project)){
compile(library.springboot_starter_web)
compile(library.springboot_starter_validation)
testCompile project(':sechub-testframework')
api(library.springboot_starter_web)
api(library.springboot_starter_validation)
testImplementation project(':sechub-testframework')

/* REST */
compile(library.jackson_JDK8)
implementation(library.jackson_JDK8)

/* database */
compile(library.database_postgres)
compile(library.database_h2)
compile(library.springboot_starter_data_jpa)
implementation(library.database_postgres)
implementation(library.database_h2)
api(library.springboot_starter_data_jpa)
//compile(library.springboot_starter_actuator)

/* security */
compile(library.springboot_starter_security)
testCompile(library.springframework_security_test)
api(library.springboot_starter_security)
testImplementation(library.springframework_security_test)

/* develop */
// currently deactivated: compile(library.springboot_devtoolssf)
}
if (projectType.springDocProjects.contains(project)){
compile(library.springboot_starter_web)
api(library.springboot_starter_web)
}
}
}
1 change: 1 addition & 0 deletions buildDoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e
cd `dirname $0`

# This script build full documentation and also creates all precondition parts
Expand Down
4 changes: 3 additions & 1 deletion libraries.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ ext {

/* autark JUnit parts, with same versions like current used spring boot version */
// https://mvnrepository.com/artifact/junit/junit
junit: "junit:junit:4.13.1",
junit4: "junit:junit:4.13.1",
junit5_impl: 'org.junit.jupiter:junit-jupiter-api:${libraryVersion.junit5Version}',
junit5_runtime: 'org.junit.jupiter:junit-jupiter-engine:${libraryVersion.junit5Version}',
junit5_params: 'org.junit.jupiter:junit-jupiter-params:${libraryVersion.junit5Version}',

amazonaws_sdk: 'com.amazonaws:aws-java-sdk-s3:1.12.30',

// Adopting existing Junit4 to Junit5 tests:
// currently we keep our exting Junit4 tests and do NOT transform them.
// If we start this, please refer:
Expand Down
2 changes: 1 addition & 1 deletion sechub-adapter-checkmarx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
*/
dependencies {

compile project(':sechub-adapter')
api project(':sechub-adapter')
}

2 changes: 1 addition & 1 deletion sechub-adapter-nessus/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
*/
dependencies {

compile project(':sechub-adapter')
api project(':sechub-adapter')
}

4 changes: 2 additions & 2 deletions sechub-adapter-netsparker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
* ============================================================================
*/
dependencies {
compile library.apache_commons_lang3
compile project(':sechub-adapter')
api project(':sechub-adapter')
implementation library.apache_commons_lang3
}
7 changes: 4 additions & 3 deletions sechub-adapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* ============================================================================
*/
dependencies {
compile library.apache_httpcomponents_core
compile library.apache_httpcomponents_client
compile project(':sechub-commons-model')
api project(':sechub-commons-model')

implementation library.apache_httpcomponents_core
implementation library.apache_httpcomponents_client
}

6 changes: 3 additions & 3 deletions sechub-analyzer-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
implementation library.jackson_jr_all
implementation library.google_re2j

testImplementation library.junit
testImplementation library.junit4
testImplementation library.mockito
testImplementation library.mockito_inline
testImplementation library.hamcrest
Expand All @@ -21,14 +21,14 @@ dependencies {
task buildAnalyzerCLI(type: Jar) {
group 'sechub'
description 'Builds the SecHub Analyzer CLI tool.'
baseName = 'analyzer'
archiveBaseName = 'analyzer'

manifest {
attributes 'Main-Class': 'com.mercedesbenz.sechub.analyzer.cli.SecHubAnalyzerApplication'
}

from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}

with jar
Expand Down
7 changes: 4 additions & 3 deletions sechub-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ task genGo(type: Exec) {
commandLine "${projectDir}/gen_go.sh"
}
}
apply plugin: 'base' // necessary to have assenble parts working without maven-publish

assemble.dependsOn(tasks.genGo)
tasks.eclipse.dependsOn(tasks.genGo)
Expand Down Expand Up @@ -75,11 +76,11 @@ task linterGo(type:Exec) {
}

task assembleArtifact(type: Zip, group: 'client') {
archiveName "sechub-client-${project.version}.zip"
destinationDir file("$buildDir/zip/")
archiveFileName= "sechub-client-${project.version}.zip"
destinationDirectory=file("$buildDir/zip/")
from "${projectDir}/build/go/"
from "${rootProject.projectDir}/sechub-doc/build/asciidoc/sechub-client.pdf" // we add the documentation into zip
description "Assemble archive $archiveName into ${relativePath(destinationDir)}"
description "Assemble archive $archiveName into ${relativePath(destinationDirectory)}"
}

version = VersionData.getClientVersion()
Expand Down
4 changes: 2 additions & 2 deletions sechub-developertools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
implementation project(':sechub-scan')

implementation project(':sechub-commons-pds')

}

task startIntegrationTestAdminUI(type: JavaExec){
Expand All @@ -38,7 +38,7 @@ task startIntegrationTestAdminUI(type: JavaExec){
task buildDeveloperAdminUI(type: Jar, dependsOn: build) {
group 'sechub'
description 'Builds the SecHub Developer Admin tool as standalone executable jar. Use launch-developer-admin-ui script to execute'
baseName = 'sechub-developer-admin-ui'
archiveBaseName = 'sechub-developer-admin-ui'

manifest {
attributes 'Main-Class': 'com.mercedesbenz.sechub.developertools.admin.ui.DeveloperAdministrationUI'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import java.io.File;

import com.mercedesbenz.sechub.developertools.TextFileWriter;
import com.mercedesbenz.sechub.integrationtest.TextFileReader;
import com.mercedesbenz.sechub.integrationtest.TextFileWriter;

/**
* How to use ? Why this generator?
Expand Down
43 changes: 39 additions & 4 deletions sechub-doc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,45 @@ apply plugin: 'org.asciidoctor.jvm.convert'
apply plugin: 'org.asciidoctor.jvm.pdf'

dependencies {
implementation project(':sechub-server') // we want to expect server and all dependencies for documentation
implementation project(':sechub-pds') // we want to expect pds and all dependencies for documentation
def wanted = []
def unwanted = [
'sechub-cli', /* go only, no library dependency here*/
'sechub-doc',/* itself ... */
'sechub-developertools',/* only tests or tools */
'sechub-other',/* not java */
'sechub-pds-solutions', /* only pds scripts*/

]
/* fetch all sub projects, except unwanted and all only used for testing */
for (Project inspectedProject: rootProject.allprojects){
if (rootProject.equals(inspectedProject)){
// root project is always not wanted
continue
}
def projectName = inspectedProject.name
if (projectName.endsWith('test')){
// test projects are always not wanted
continue
}
if (projectName.endsWith('testframework')){
// testframework projects are always not wanted
continue
}
if (unwanted.contains(projectName)){
// special unwanted - so inore
continue
}
wanted << projectName
//println ">>$projectName"
}
/* all projects are added as implementation, so can be inspected by Reflections */
for (String wantedProjectName: wanted){
implementation project(":${wantedProjectName}")
}
implementation library.apache_commons_io

testImplementation library.epages_restdoc_api_spec_mockmvc
testImplementation project(':sechub-commons-model-testframework')
testImplementation project(':sechub-commons-model-testframework')

/* next parts are necessary for rest doc generation in conjunction
with reflection annoation scanning done wiht @UsecaseRestDoc
Expand Down Expand Up @@ -152,7 +186,8 @@ asciidoctorj {

task convertSecHubHTMLPages(type: Copy){

/* Albert: Why those replace pattern stuff ?
/* Why those replace pattern stuff ?
* ----------------------------------
* Because of PDF problems with rendered images, we were forced to use absolute image pathes so
* PDF documented has got content inside (see build.gradle in sechub-doc for info)
*
Expand Down
11 changes: 7 additions & 4 deletions sechub-integrationtest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ plugins {
}
dependencies {

/* why as API? because to provide all parts here to developer tools */
api project(':sechub-testframework')
api project(':sechub-adapter') // we reuse trustall approach from adapters
api project(':sechub-shared-kernel')
api project(':sechub-scan-product-pds') // we want configuration entries available
api project(':sechub-commons-pds')
api library.springboot_starter_mail // to have easier access to email parts

api project(':sechub-commons-pds')
api project(':sechub-adapter') // we reuse trustall approach from adapters
api project(':sechub-adapter-pds')
api project(':sechub-administration')

api library.junit4
}
import java.nio.file.Files;
import java.nio.file.Paths;
Expand Down Expand Up @@ -244,8 +249,6 @@ class IntegrationTestScriptAccess extends CmdExecutor{
exec.getCommand().add("$sharedVolumeBaseDir");

}


exec.execute(workingDir)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.developertools;
package com.mercedesbenz.sechub.integrationtest;

import java.io.BufferedWriter;
import java.io.File;
Expand All @@ -15,7 +15,15 @@ public class TextFileWriter {

private static final Logger LOG = LoggerFactory.getLogger(TextFileWriter.class);

public void save(String text, File targetFile, Charset charset) throws IOException {
internalSave(targetFile, text, true, charset);
}

public void save(File targetFile, String text, boolean overwrite) throws IOException {
internalSave(targetFile, text, overwrite, Charset.forName("UTF-8"));
}

private void internalSave(File targetFile, String text, boolean overwrite, Charset charset) throws IOException {
if (targetFile == null) {
throw new IllegalArgumentException("null not allowed as file!");
}
Expand All @@ -42,9 +50,10 @@ public void save(File targetFile, String text, boolean overwrite) throws IOExcep
throw new IllegalStateException("was not able to create new file:" + targetFile);
}
}
try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(targetFile), Charset.forName("UTF-8")))) {
try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(targetFile), charset))) {
bw.write(text);
}
LOG.info("Written:" + targetFile);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import wiremock.com.google.common.io.Files;

import com.mercedesbenz.sechub.commons.model.TrafficLight;
import com.mercedesbenz.sechub.integrationtest.TextFileWriter;
import com.mercedesbenz.sechub.integrationtest.api.IntegrationTestSetup;
import com.mercedesbenz.sechub.integrationtest.api.TestUser;
import com.mercedesbenz.sechub.integrationtest.api.WithSecHubClient.ApiTokenStrategy;
Expand Down Expand Up @@ -373,7 +372,8 @@ private File ensureExampleContentFoldersExist() {
File testFile1 = new File(projectResourceFoldder, "TestMeIfYouCan.java");
if (!testFile1.exists()) {
try {
Files.write("class TestMeifYouCan {}", testFile1, Charset.forName("UTF-8"));
TextFileWriter writer = new TextFileWriter();
writer.save("class TestMeifYouCan {}", testFile1, Charset.forName("UTF-8"));
} catch (IOException e) {
throw new IllegalStateException("Cannot create test output!", e);
}
Expand Down
8 changes: 4 additions & 4 deletions sechub-notification/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/
dependencies {

compile project(':sechub-shared-kernel')
compile library.springboot_starter_mail
compile library.apache_commons_lang3
implementation project(':sechub-shared-kernel')
implementation library.springboot_starter_mail
implementation library.apache_commons_lang3

testCompile project(':sechub-testframework')
testImplementation project(':sechub-testframework')

}
Loading

0 comments on commit 61f2938

Please sign in to comment.