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

你好 #8

Closed
sky-lijinbo opened this issue Oct 16, 2017 · 1 comment
Closed

你好 #8

sky-lijinbo opened this issue Oct 16, 2017 · 1 comment

Comments

@sky-lijinbo
Copy link

    private static void saveModifiedJarForCheck(File optJar) {
        File dir = DataHelper.ext.pluginTmpDir;
        File checkJarFile = new File(dir, optJar.getName());
        if (checkJarFile.exists()) {
            checkJarFile.delete();
        }
        FileUtils.copyFile(optJar, checkJarFile);
    }

请问这段代码,只是用来检查修改的jar包的对吗

@nailperry-zd
Copy link
Owner

是的,是为了将成功注入的java类或jar包单独输出到build的目录LazierTracker目录下。分析如下:

private static void saveModifiedJarForCheck(File optJar) {
        File dir = com.codeless.plugin.utils.DataHelper.ext.pluginTmpDir;
        File checkJarFile = new File(dir, optJar.getName());
        if (checkJarFile.exists()) {
            checkJarFile.delete();
        }
        FileUtils.copyFile(optJar, checkJarFile);
}

从上述saveModifiedJarForCheck函数可知,这些文件被写入的目录为com.codeless.plugin.utils.DataHelper.ext.pluginTmpDir,通过查找,可知这个变量在initDir函数中被赋值。

从下面的initDir函数可知,pluginTmpDir赋值为project.buildDir/LazierTracker,因此,你会在app/build/LazierTracker目录下找到这些修改后的文件。

static void initDir(Project project) {
        File pluginTmpDir = new File(project.buildDir, 'LazierTracker')
        if (!pluginTmpDir.exists()) {
            pluginTmpDir.mkdir()
        }
        com.codeless.plugin.utils.DataHelper.ext.pluginTmpDir = pluginTmpDir
}

效果如下:

image

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