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

Use asm unshadowed and upgrade to 9.4 #806

Merged
merged 2 commits into from
Jan 14, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.autonomousapps.jvm

import com.autonomousapps.jvm.projects.JavaToolchainProject

import static com.autonomousapps.utils.Runner.build
import static com.google.common.truth.Truth.assertThat

final class JavaToolchainSpec extends AbstractJvmSpec {

def "does not fail with Java #javaToolchainVersion toolchain (#gradleVersion)"() {
given: "a Gradle project using Java toolchain version #javaToolchainVersion that has been built"
def project = new JavaToolchainProject(javaToolchainVersion)
gradleProject = project.gradleProject
build(gradleVersion, gradleProject.rootDir, 'build')

when: 'running buildHealth'
def result = build(gradleVersion, gradleProject.rootDir, 'buildHealth')

then: 'abiAnalysisMain and explodeByteCodeSourceMain tasks were ran'
// These two are the ones that were actually failing, sanity check that java library plugin is applied
assert result.tasks.any { (it.getPath() == ':proj:abiAnalysisMain') }
assert result.tasks.any { (it.getPath() == ':proj:explodeByteCodeSourceMain') }

and: 'the report should be empty'
assertThat(project.actualBuildHealth()).containsExactlyElementsIn(project.expectedBuildHealth)

where:
// Comment out all but the last for speed
// See https://docs.gradle.org/8.5/userguide/compatibility.html#java
gradleVersion | javaToolchainVersion
// GRADLE_7_5 | 18
// GRADLE_7_5 | 19
// GRADLE_7_6 | 18
GRADLE_7_6 | 19
// TODO(tsr): some errors running these two scenarios
// GRADLE_8_3 | 20
// GRADLE_8_5 | 21

classFileMajorVersion = javaToolchainVersion + 44 // 19 + 44 = 63, is this safe?
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.autonomousapps.jvm.projects

import com.autonomousapps.AbstractProject
import com.autonomousapps.kit.GradleProject
import com.autonomousapps.kit.Source
import com.autonomousapps.kit.SourceType
import com.autonomousapps.kit.gradle.Plugin
import com.autonomousapps.model.ProjectAdvice

import static com.autonomousapps.AdviceHelper.actualProjectAdvice
import static com.autonomousapps.AdviceHelper.emptyProjectAdviceFor
import static com.autonomousapps.kit.gradle.Dependency.annotationProcessor
import static com.autonomousapps.kit.gradle.Dependency.implementation

final class JavaToolchainProject extends AbstractProject {

final GradleProject gradleProject

JavaToolchainProject(int javaToolchainVersion) {
this.gradleProject = build(javaToolchainVersion)
}

private GradleProject build(int javaToolchainVersion) {
return newGradleProjectBuilder()
.withSubproject('proj') { s ->
s.sources = sources
s.withBuildScript { bs ->
bs.plugins(Plugin.javaLibrary)
bs.dependencies(
implementation('org.projectlombok:lombok:1.18.24'),
annotationProcessor('org.projectlombok:lombok:1.18.24'),
)
bs.withGroovy("java { toolchain { languageVersion.set(JavaLanguageVersion.of(${javaToolchainVersion})) } }")
}
}.write()
}

private List<Source> sources = [
new Source(
SourceType.JAVA, "Country", "com/example",
"""\
package com.example;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Country {
private Long id;
private String alpha2;
private String alpha3;
private String name;
private boolean active;

private Country(final String alpha2, final String alpha3, final String name) {
this.alpha2 = alpha2;
this.alpha3 = alpha3;
this.name = name;
this.active = Boolean.TRUE;
}

public static Country of(final String alpha2, final String alpha3, final String name) {
return new Country(alpha2, alpha3, name);
}

public void setActive(boolean active) {
this.active = active;
}
}
""".stripIndent()
)
]

Set<ProjectAdvice> actualBuildHealth() {
return actualProjectAdvice(gradleProject)
}

// In reality we merely hope for unsupported class file major version error
final Set<ProjectAdvice> expectedBuildHealth = [
emptyProjectAdviceFor(':proj'),
]
}