Coder Social home page Coder Social logo

Comments (11)

vanniktech avatar vanniktech commented on June 28, 2024 1

See which class was annotated with @RemoveThis and then get the package name of it. Then for each segment try getting the BuildConfig.

Imagine MyClass is annotated:
com.my.package.name.feature.ui.view.MyClass

then just try getting Buildconfig via:

com.my.package.name.feature.ui.view.BuildConfig
com.my.package.name.feature.ui.BuildConfig
com.my.package.name.feature.BuildConfig
com.my.package.name.BuildConfig
com.my.package.BuildConfig

at some point you'll get it and then you can go and use it.

from papercut.

vanniktech avatar vanniktech commented on June 28, 2024 1

There is also this which is something they might work on and with it you'll get the application id

from papercut.

Stuie avatar Stuie commented on June 28, 2024

I believe this would require making a gradle plugin. I need to look into it before committing to it.

from papercut.

vanniktech avatar vanniktech commented on June 28, 2024

Read it from the BuildConfig ;)

from papercut.

Jawnnypoo avatar Jawnnypoo commented on June 28, 2024

@vanniktech Would he be able to read the BuildConfig of the app, and not just the library's BuildConfig?

from papercut.

Jawnnypoo avatar Jawnnypoo commented on June 28, 2024

Heh, that could work. Although it would be problematic for if you have a seperate package name from your appId (such as if you were using an imported third party library or something).

Possibly you could also do something like context.getPackageName() since that will give you the apps package name and then assume the BuildConfig is under the same package name, though this is sometimes not true also if you are doing something like appending release or debug to the end of the package name on build flavors.

from papercut.

Stuie avatar Stuie commented on June 28, 2024

At this point the library works for non-Android projects. The BuildConfig logic is something I thought of when @adesrosiers raised this issue, but wouldn't work for non-Android projects.

Potentially I could create an Android-specific package to provide version number support.

from papercut.

Stuie avatar Stuie commented on June 28, 2024

I added support for self-managed milestones in version 0.0.3. I still need to investigate an Android-specific solution. I'm not entirely sure that the BuildConfig class is available at the point the annotationProcessor gets run, so it's not a trivial matter.

A gradle plugin may be worth looking into.

from papercut.

Stuie avatar Stuie commented on June 28, 2024

Gradle supports annotationProcessorOptions, which allows you to pass arguments from your build.gradle to the annotationProcessor. The information I've found seems to talk about the JACK build chain for Android projects, which not everyone will have moved to by now.

I'm going to be away for a week, so I'm leaving this note for myself as a reminder of what I should look at when I return.

javaCompileOptions {
    annotationProcessorOptions {
        arguments = ['versionCode' : 'YOUR_VERSION_HERE']
    }
}

The GreenRobot EventBus supports such options.

from papercut.

Stuie avatar Stuie commented on June 28, 2024

I got bored on my flight, so I had a quick go at implementing version code support. I've published 0.0.4-SNAPSHOT to the snapshot repository. The code is also available here on Github in the version-code branch.

If you're using this library in an Android project then you'll have to add the javaCompileOptions and annotationProcessorOptions sections to your build.gradle file, if you haven't already, in the defaultConfig section, as below:

android {
    defaultConfig {
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["versionCode" : "YOUR_VERSION_CODE_HERE"]
            }
        }
    }
}

Support for versionName is a bit more complicated. Some people use semantic versioning (e.g. 3.0.1), which shouldn't be too complicated, but people also use codenames, etc. which makes it very difficult to tell if a specific version is newer or older than another. @Milestones are better suited for that.

from papercut.

Stuie avatar Stuie commented on June 28, 2024

Just pushed version 0.0.4 with support for versionCode and versionName in the @RemoveThis and @Refactor annotations.

For Android projects you need to follow the instructions in the README. They're similar to my previous update on this issue, but I'll include a more complete version below for the sake of completeness.

android {
    defaultConfig {
        versionCode 4
        versionName "0.4.0"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ['versionCode': String.valueOf(defaultConfig.versionCode),
                             'versionName': defaultConfig.versionName]
            }
        }
    }
}

You have to have a versionCode that can be parsed to an Integer, and the versionName has to adhere to the semantic versioning schema. This may not match up with what Android defaults to.

If there are problems then I may look to support other versioning schemas, but that complicates things a bit more than I'd like.

from papercut.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.