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

OD-17088_Groovy_4_upgrade_without_gradle_update #980

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
23 changes: 11 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
jettyVersion = '10.0.7'
mariadbVersion = '2.7.4'
googleGuiceVersion = '4.2.2'
groovyVersion = '2.5.15'
groovyVersion = '4.0.2'
bouncycastleVersion = '1.67'
bootiqueVersion = '1.2'
cfxVersion = '3.3.5'
Expand Down Expand Up @@ -72,15 +72,14 @@ subprojects {
api "org.apache.logging.log4j:log4j-slf4j-impl:$log4j2Version"
api "org.apache.logging.log4j:log4j-jcl:$log4j2Version"

api "org.codehaus.groovy:groovy:$groovyVersion"
api "org.codehaus.groovy:groovy-datetime:$groovyVersion"
api "org.codehaus.groovy:groovy-json:$groovyVersion"
api "org.codehaus.groovy:groovy-jsr223:$groovyVersion"
api "org.codehaus.groovy:groovy-macro:$groovyVersion"
api "org.codehaus.groovy:groovy-xml:$groovyVersion"
api "org.codehaus.groovy:groovy-templates:$groovyVersion"
api "org.codehaus.groovy:groovy-xml:$groovyVersion"
api "org.codehaus.groovy:groovy-dateutil:$groovyVersion"
api "org.apache.groovy:groovy:$groovyVersion"
api "org.apache.groovy:groovy-datetime:$groovyVersion"
api "org.apache.groovy:groovy-json:$groovyVersion"
api "org.apache.groovy:groovy-jsr223:$groovyVersion"
api "org.apache.groovy:groovy-macro:$groovyVersion"
api "org.apache.groovy:groovy-templates:$groovyVersion"
api "org.apache.groovy:groovy-xml:$groovyVersion"
api "org.apache.groovy:groovy-dateutil:$groovyVersion"

implementation 'javax.annotation:javax.annotation-api:1.3.2'

Expand All @@ -91,8 +90,8 @@ subprojects {
testImplementation 'org.junit.vintage:junit-vintage-engine:5.8.0' // needed for dbunit https://sourceforge.net/p/dbunit/feature-requests/222/
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testImplementation 'org.dbunit:dbunit:2.7.0'
testImplementation "org.codehaus.groovy:groovy-test-junit5:$groovyVersion"
testImplementation "org.codehaus.groovy:groovy-sql:$groovyVersion"
testImplementation "org.apache.groovy:groovy-test-junit5:$groovyVersion"
testImplementation "org.apache.groovy:groovy-sql:$groovyVersion"
}
// uncomment when dbunit is detached from junit
// configurations {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} implements
{{#vendorExtensions.extraAnnotation}}
{{{vendorExtensions.extraAnnotation}}}
{{/vendorExtensions.extraAnnotation}}
{{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
{{{datatypeWithEnum}}} {{#isBoolean}}get{{/isBoolean}}{{getter}}() {
return {{name}}
}

Expand Down
9 changes: 8 additions & 1 deletion server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ dependencies {
implementation group: 'net.coobird', name: 'thumbnailator', version: '0.4.18'

testImplementation "org.apache.cayenne:cayenne-dbsync:$cayenneVersion"
testImplementation 'org.mockito:mockito-core:2.18.3'
testImplementation 'org.mockito:mockito-core:3.12.4'
testImplementation 'commons-dbcp:commons-dbcp:1.4'
testImplementation 'xmlunit:xmlunit:1.6' //used for xml export validation tests
testImplementation 'org.kohsuke:wordnet-random-name:1.3'
Expand All @@ -171,6 +171,13 @@ application {

compileGroovy.groovyOptions.configurationScript = file("${rootDir}/gradle/groovyConfig.groovy")

// Increased maximum heap size to 4 GB instead of 128 MB by default, this is necessary to build onCourse with Groovy 4.0.2 and to run tests
tasks.withType(GroovyCompile) {
configure(groovyOptions.forkOptions) {
jvmArgs = ['-Xmx4g']
}
}

jar {
manifest {
from sharedManifest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ class InvoiceApiService extends TaggableApiService<InvoiceDTO, AbstractInvoice,
if (abstractInvoice.newRecord || abstractInvoice instanceof Quote) {
abstractInvoice.type = invoiceDTO.type.getDbType()
abstractInvoice.lead = leadDao.getById(abstractInvoice.context, invoiceDTO.leadId)
abstractInvoice.contact = contactDao.getById(abstractInvoice.context, invoiceDTO.contactId)
// Groovy 4.0.2 tries to cast AbstractInvoice to Quote, because it see 'abstractInvoice instanceof Quote'. This fix helps.
((AbstractInvoice) abstractInvoice).contact = contactDao.getById(abstractInvoice.context, invoiceDTO.contactId)
abstractInvoice.invoiceDate = invoiceDTO.invoiceDate
abstractInvoice.source = SOURCE_ONCOURSE
abstractInvoice.createdByUser = abstractInvoice.context.localObject(systemUserService.currentUser)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@

package ish.oncourse.server.api.service

import groovy.transform.CompileDynamic
import ish.oncourse.server.api.dao.CayenneLayer
import static ish.oncourse.server.api.function.CayenneFunctions.getRecordById
import ish.oncourse.server.api.traits._DTOTrait
import ish.oncourse.server.cayenne.Tag
import ish.oncourse.server.cayenne.glue.TaggableCayenneDataObject

@CompileDynamic
abstract class TaggableApiService <T extends _DTOTrait, K extends TaggableCayenneDataObject, M extends CayenneLayer<K>> extends EntityApiService<T, K, M> {

Closure getAction(String key, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

package ish.oncourse.server.api.v1.function.export

import groovy.transform.CompileDynamic
import ish.oncourse.aql.AqlService
import ish.oncourse.server.api.service.ReportApiService
import ish.oncourse.server.api.v1.model.SortingDTO
Expand All @@ -32,6 +33,7 @@ import static ish.print.AdditionalParameters.*
import static ish.print.PrintRequestTransformationsFiller.fillWithTransformations
import static ish.util.LocalDateUtils.*

@CompileDynamic
class PrintRequestBuilder {

private ObjectContext context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class CheckoutApiImpl implements CheckoutApi {
result
}

private static CheckoutSaleRelationDTO createCourseCheckoutSaleRelation(Long id, String entityName, Course course, EntityRelationType relationType) {
private CheckoutSaleRelationDTO createCourseCheckoutSaleRelation(Long id, String entityName, Course course, EntityRelationType relationType) {
new CheckoutSaleRelationDTO().with {saleRelation ->
saleRelation.fromItem = new SaleDTO(id: id, type: SaleTypeDTO.values()[0].getFromCayenneClassName(entityName))
saleRelation.toItem = new SaleDTO(id: course.id, type: SaleTypeDTO.COURSE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class Document extends _Document implements DocumentTrait, Queueable {
}

@API
Boolean isActive() {
Boolean getActive() {
return !super.isRemoved
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ReportOverlay extends _ReportOverlay {
}

@API
Boolean isPortrait() {
Boolean getPortrait() {
ImageHelper.isPortrait(this.overlay)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private ReportDTO toRestModel(Report dbReport, String entityName) {
@Override
public Report toCayenneModel(ReportDTO dto, Report cayenneModel) {
cayenneModel = super.toCayenneModel(dto, cayenneModel);
cayenneModel.setIsVisible(dto.isSubreport());
cayenneModel.setIsVisible(dto.getSubreport());
cayenneModel.setSortOn(dto.getSortOn() != null ? dto.getSortOn() : "");
if (dto.getBackgroundId() != null) {
cayenneModel.setBackground(overlayDao.getById(cayenneModel.getContext(), dto.getBackgroundId()));
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/ish/util/ThumbnailGenerator.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.awt.image.BufferedImage

import static ish.util.ImageHelper.*

def class Size {
class Size {
private int weight
private int height

Expand Down
22 changes: 11 additions & 11 deletions server/src/test/groovy/org/eclipse/jetty/testing/HttpTester.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class HttpTester {
}

void setHeader(String name, String value) {
build().put(name, value)
super.build().put(name, value)
}

@Override
Expand All @@ -224,27 +224,27 @@ class HttpTester {

@Override
Immutable asImmutable() {
return build().asImmutable()
return super.build().asImmutable()
}

@Override
HttpField getField(int index) {
return build().getField(index)
return super.build().getField(index)
}

@Override
int size() {
return build().size()
return super.build().size()
}

@Override
Stream<HttpField> stream() {
return build().stream()
return super.build().stream()
}

@Override
Iterator<HttpField> iterator() {
return build().iterator()
return super.build().iterator()
}
}

Expand Down Expand Up @@ -302,27 +302,27 @@ class HttpTester {

@Override
Immutable asImmutable() {
return build().asImmutable()
return super.build().asImmutable()
}

@Override
HttpField getField(int index) {
return build().getField(index)
return super.build().getField(index)
}

@Override
int size() {
return build().size()
return super.build().size()
}

@Override
Stream<HttpField> stream() {
return build().stream()
return super.build().stream()
}

@Override
Iterator<HttpField> iterator() {
return build().iterator()
return super.build().iterator()
}
}
}