Update Preinstrumented Jars to a new version - robolectric/robolectric GitHub Wiki

Preparation

  1. Ensure you have imported the gpg signing keys, and you have signing and release credentials in your ~/.gradle/gradle.properties:

    signing.keyId=B408DBD5
    signing.password=********
    signing.secretKeyRingFile=/home/_____/.gnupg/secring.gpg
    systemProp.sonatype-login=********
    systemProp.sonatype-password=********

    Note, if you do not have $HOME/.gnupg/secring.gpg file, you may be running v2.1+ of GnuPG. If so you will need to export it using:

    gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg

Update

  1. Update PREINSTRUMENTED_VERSION inside buildSrc/src/main/groovy/AndroidSdk.groovy to the new version

    class AndroidSdk implements Comparable<AndroidSdk> {
        static final PREINSTRUMENTED_VERSION = 2
    
  2. Build the new jars and publish them to your local maven repository

    ./gradlew :preinstrumented:instrumentAll
    PUBLISH_PREINSTRUMENTED_JARS=true ./gradlew :preinstrumented:publishToMavenLocal
    

    Make sure that the new jars show up in the repository under org/robolectric/android-all-instrumented

  3. Update DefaultSdkProvider.java to use the new preinstrumented jar version

    public class DefaultSdkProvider implements SdkProvider {
    
      private static final int RUNNING_JAVA_VERSION = Util.getJavaVersion();
    
      private static final int PREINSTRUMENTED_VERSION = 2;
    
  4. Run tests locally to make sure tests pass

    ./gradlew :robolectric:test
    
  5. Upload the jars to Maven staging

    PUBLISH_PREINSTRUMENTED_JARS=true ./gradlew :preinstrumented:publish
    
  6. Log into Sonatype and close the staging repository.

  7. Use the staging repository URL to test the uploaded artifacts. Add this to the repositories section in /build.gradle:

    maven {
        url "https://oss.sonatype.org/content/repositories/orgrobolectric-____"
    }
    
  8. Once you've confirmed that everything is ok, release the staging artifacts.

  9. Wait for the new version to appear at Maven Central

  10. Push the changes to DefaultSdk.java and AndroidSdk.groovy and verify tests pass

⚠️ **GitHub.com Fallback** ⚠️