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

Can't build project when building for Java instead of Kotlin with Gradle #461

Open
Mareng98 opened this issue Jan 18, 2025 · 1 comment
Open

Comments

@Mareng98
Copy link

Mareng98 commented Jan 18, 2025

I included this code at the top of the file:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'com.guardsquare:proguard-gradle:7.6.1'
  }
}

I included this code after the plugins and dependencies:

tasks.register('proguard', ProGuardTask) {
  configuration file('proguard.pro')

  injars(tasks.named('jar', Jar).flatMap { it.archiveFile })

  // Automatically handle the Java version of this build.
  if (System.getProperty('java.version').startsWith('1.')) {
    // Before Java 9, the runtime classes were packaged in a single jar file.
    libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
  } else {
    // As of Java 9, the runtime classes are packaged in modular jmod files.
    libraryjars "${System.getProperty('java.home')}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
    //libraryjars "${System.getProperty('java.home')}/jmods/....."
  }

  verbose

  outjars(layout.buildDirectory.file("libs/${baseCoordinates}-minified.jar"))
}

And when reloading the build.gradle I get this error:

Build file 'D:\MasterThesis\testSubjects\proguard\spring-petclinic-main\build.gradle' line: 72

A problem occurred evaluating root project 'spring-petclinic'.
> Could not get unknown property 'ProGuardTask' for root project 'spring-petclinic' of type org.gradle.api.Project.

Also there doesn't seem to be any instructions on how to use it for pure Java projects. Is it not possible to use Proguard for non-android applications?

@piazzesiNiccolo-GS
Copy link
Contributor

Hello,

the instructions for pure java projects can be found at this link: https://www.guardsquare.com/manual/setup/gradle

The setup looks fine, are you correctly importing ProGuardTask at the top of your gradle file?
import proguard.gradle.ProGuardTask

Can you also try by using the fully qualified name?

tasks.register('proguard', proguard.gradle.ProGuardTask) {
...
}

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

No branches or pull requests

2 participants