Skip to content

Replace deprecated Jar.classifier with archiveClassifier#192

Open
Tuguberk wants to merge 1 commit into
eProsima:masterfrom
Tuguberk:fix/gradle-archiveclassifier-deprecation
Open

Replace deprecated Jar.classifier with archiveClassifier#192
Tuguberk wants to merge 1 commit into
eProsima:masterfrom
Tuguberk:fix/gradle-archiveclassifier-deprecation

Conversation

@Tuguberk

Copy link
Copy Markdown

Problem

Building IDL-Parser with Gradle 7.0 or later fails during configuration:

A problem occurred evaluating project ':idl-parser'.
> Could not set unknown property 'classifier' for task ':idl-parser:sourceJar'
  of type org.gradle.api.tasks.bundling.Jar.

This blocks consumers of IDL-Parser (notably Fast-DDS-Gen) from upgrading their Gradle wrapper beyond 6.x, which in turn prevents building on systems running Java 11+ as the primary JDK.

Root cause

The classifier property on Jar tasks was deprecated in Gradle 5.1 and removed in Gradle 7.0. Two usages remain in build.gradle:

// line 74 — task declaration
task sourceJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'   // ← removed in Gradle 7
    ...
}

// line 94 — artifact block inside publishing
artifact sourceJar {
    classifier 'sources'     // ← removed in Gradle 7
}

Fix

Replace both with archiveClassifier, the supported API since Gradle 5.1:

task sourceJar(type: Jar, dependsOn: classes) {
    archiveClassifier = 'sources'
    ...
}

artifact sourceJar {
    archiveClassifier = 'sources'
}

Impact

  • No behaviour change — the produced artifact still carries the sources classifier.
  • Unblocks Gradle wrapper upgrades to 7.x / 8.x in dependent projects.
  • Backwards compatible: archiveClassifier is available from Gradle 5.1 onward.

Testing

Verified that IDL-Parser builds cleanly under Gradle 8.5 with Java 21 after this change, as part of a full Fast-DDS-Gen build on macOS arm64.

The Jar task property `classifier` was deprecated in Gradle 5.1 and
removed in Gradle 7.0. Builds using Gradle 7+ fail with:

  Could not set unknown property 'classifier' for task ':idl-parser:sourceJar'
  of type org.gradle.api.tasks.bundling.Jar.

Replace both usages with the current `archiveClassifier` property,
which has been available since Gradle 5.1 and is the supported API
going forward.

This unblocks projects that depend on IDL-Parser (e.g. Fast-DDS-Gen)
from upgrading their Gradle wrapper to 7.x or later.

Signed-off-by: Tuguberk <akbulut.tugberk@gmail.com>
@Tuguberk Tuguberk force-pushed the fix/gradle-archiveclassifier-deprecation branch from ff3ea48 to 73cd0eb Compare May 12, 2026 10:48
Tuguberk added a commit to Tuguberk/Fast-DDS-Gen that referenced this pull request May 12, 2026
Gradle 7.6 supports Java up to version 19. Building Fast-DDS-Gen on
systems where Java 21 is the default JDK fails with:

  BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_'
  Unsupported class file major version 65

Class file major version 65 corresponds to Java 21. Gradle 8.5
introduced official Java 21 support.

This change upgrades the Gradle wrapper to 8.5, which supports
Java 11 through 21. The build itself continues to compile sources to
Java 8 bytecode (sourceCompatibility/targetCompatibility = 1.8 in
build.gradle), so the produced fastddsgen.jar remains compatible with
any Java 8+ runtime.

Note: this change depends on eProsima/IDL-Parser#192, which replaces
the deprecated Jar.classifier property (removed in Gradle 7) with
archiveClassifier. Without that fix, the IDL-Parser submodule build
fails under Gradle 7+.

Signed-off-by: Tuguberk <akbulut.tugberk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant