Configure Play! 2.0 to copy html files from assets folder to public folder?
Tag : scala , By : semicolonth
Date : March 29 2020, 07:55 AM
wish helps you I was able to figure out how to do this in a Scalatra test project, so I just need to modify the following code to adapt it to Play's folder structure. It does, however, work. What it does is defines a new sbt "Plugin" and, at compile time, copies any files in /src/main/html to /resource_managed/main/views. Hopefully someone will find this useful! import sbt._
import Keys._
import java.io.File
import org.apache.commons.io.FileUtils._
object CopyViews extends sbt.Plugin {
import CopyViewsKeys._
object CopyViewsKeys {
val copy = TaskKey[Unit]("copy-views", "Copy views into resourceManaged.")
}
private def copyViewsTask = (streams, sourceDirectory in copy, resourceManaged in copy) map {
(out, source, destination) =>
out.log.info("Copying Views to " + destination.getAbsolutePath())
copyDirectory(source, destination)
}
def copyViewsSettingsIn(c: Configuration): Seq[Setting[_]] =
inConfig(c)(Seq(
sourceDirectory in copy <<= (sourceDirectory in c) { _ / "html" },
resourceManaged in copy <<= (resourceManaged in c) { _ / "views" },
copy <<= copyViewsTask
)) ++ Seq(
compile in c <<= (compile in c).dependsOn(copy in c)
)
def copyViewsSettings: Seq[Setting[_]] =
copyViewsSettingsIn(Compile)
}
object ModFallBuild extends Build {
import CopyViews._ // Import in our Build so we can use in our build.sbt file.
lazy val modfall = Project("modfall", file("."))
}
seq(copyViewsSettings:_*)
|
Rendering HTML files from assets folder in Android Studio
Date : March 29 2020, 07:55 AM
will be helpful for those in need I am an Android newbie and have been futzing around with trying to render an html file in my assets folder and getting a blank webView screen when my app runs in the emulator. Here is my code: , Try: String filePath = "file:///android_asset/www/index.html";
String filePath = "file///android_asset/www/index.html";
|
local (html /js) files in assets folder with android WebView?
Date : March 29 2020, 07:55 AM
wish of those help this is my OnCreate method . , alert is not supported by android WebView .
|
Create pre build event to copy files to assets folder in Android application
Date : March 29 2020, 07:55 AM
may help you . I have this project structure: ProjectFolder/IosFolder,AndroidFolder,CommonFolder Now android app uses files from it's assets folder. But we decide to make Common folder for the same files. , Can you try this configuration: gradle.projectsEvaluated {
preBuild.dependsOn(copyFiles)
}
task anotherCopyTask(type: Copy) {
// Copy everything under src/main/webapp
from 'src/main/webapp'
// Copy a single file
from 'src/staging/index.html'
// Copy the output of a task
from copyTask
// Copy the output of a task using Task outputs explicitly.
from copyTaskWithPatterns.outputs
// Copy the contents of a Zip file
from zipTree('src/main/assets.zip')
// Determine the destination directory later
into { getDestDir() }
task copyFiles(type: Copy) {
from 'pathToMyAssets'
into 'AndroidStudioAssetsFolderPath'
}
task copyFiles(type: Copy) {
from 'Users/kostya/repo_amc_mobile_promo/Common/'
into 'Users/kostya/repo_amc_mobile_promo/Android/AMC_Mobile_Promo2/app/src/main/assets'
}
preBuild.dependsOn(copyFiles)
|
.How to copy files from project assets folder to device data folder in android studio?
Date : March 29 2020, 07:55 AM
This might help you So, are the files supposed to be automatically copied over to device? If not, how can I copy the files? public class DatabaseHelper extends SQLiteAssetHelper {
public static final String DATABASENAME = "databasename.db"; //<<<<<<<<< MUST match file name in assets/databases
public static final int DATABASEVERSION = 1;
public DatabaseHelper(Context context) {
super(context, DATABASENAME, null, DATABASEVERSION);
this.getWritableDatabase(); //<<<<< will force database access and thus copy database from assets
}
}
public class MainActivity extends AppCompatActivity {
DatabaseHelper mDBHelper; //<<<<< declares the database helper
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDBHelper = new DatabaseHelper(this); // instantiates the database helper
}
}
|