<dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${springframework.version}</version> <type>jar</type> <scope>compile</scope> </dependency>
groupId,必选,实际隶属项目
artifactId,必选,其中的模块
version必选,版本号
type可选,依赖类型,默认jar
scope可选,依赖范围,默认compile
optional可选,标记依赖是否可选,默认false
exclusion可选,排除传递依赖性,默认空
2.依赖范围maven项目又三种classpath(编译,测试,运行)
scope用来表示与classpath的关系,总共有五种
compile:编译,测试,运行
test:测试
provided:编译,测试
runtime:运行
system:编译,测试,同provided,但必须指定systemPath,慎用
3.传递性依赖顾名思义,你懂的,但是传递的范围会发生改变,这个由maven自身处理,只要理解下即可
第一列为第一依赖,第二列为第二依赖,单元格为传递范围
compiletestprovidedruntimecompilecompile__runtimetesttest__testprovidedprovided_providedprovidedruntimeruntime__runtime
4.依赖调解传递路径长度取最短原则,传递路径长度相等时,采取最先申明原则
5.可选依赖尽量少用,可选依赖不会被传递,需要显式申明
6.排除依赖发现依赖包里有些包不稳定,可以排除依赖,显式的申明文档的包
<dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.1</version> <exclusions> <exclusion> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> <version>1.1</version> </dependency>7.分类依赖
当同一个模块,所依赖的几个模块版本都相同时,可以使用maven里的属性做分类依赖,依赖版本升级时改一处即可
<properties> <springframework.version>2.5.6</springframework.version> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${springframework.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${springframework.version}</version> <type>pom</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${springframework.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${springframework.version}</version> <type>jar</type> <scope>compile</scope> </dependency> </dependencies>8.优化依赖
可概括为三个命令
mvn dependency:list表示依赖列表,maven eclipse插件已经实现,有图形化显示,在pom.xml的dependencies页
表示依赖列表,maven eclipse插件已经实现,有图形化显示,在pom.xml的dependency hierarchy页
mvn dependency:analyze查找出在编译和测试中未使用但显示声明的依赖
我们在读写例如XML和TXT文件的时候,在电脑上和手机上路径不一致,造成了很多麻烦,其实有个简单的方法,在项目工程中新建一个StreamingAssets文件夹,把你的XML和TXT文件放到这里。
using UnityEngine; using System.Collections; using System.Xml; using System.Xml.Serialization; using System.IO; using System.Text; public class Reward { public int taskNo; public Task[] task = new Task[15]; public Attribute attribute; public Reward () {} public struct Task { [XmlAttribute("taskReward")] public string taskReward{ get; set;} public Id id1; public Id id2; public Id id3; } public struct Id { [XmlAttribute("flag")] public bool flag{ get; set;} [XmlAttribute("name")] public string name{ get; set;} [XmlText()] public string description{get;set;} } } public class AchievementManager: MonoBehaviour { Reward reward ; FileInfo fileInfo; string _data; void Start () { reward = new Reward(); LoadXML(); } void LoadXML() { if(Application.platform == RuntimePlatform.IPhonePlayer) { fileInfo = new FileInfo(Application.dataPath + "/Raw/" + "Achievement.xml"); StreamReader r = fileInfo.OpenText(); _data = r.ReadToEnd(); r.Close(); } else if(Application.platform == RuntimePlatform.Android) { fileInfo = new FileInfo(Application.streamingAssetsPath+"/Achievement.xml"); StartCoroutine("LoadWWW"); } else { fileInfo = new FileInfo(Application.dataPath + "/StreamingAssets/"+ "Achievement.xml"); StreamReader r = fileInfo.OpenText(); _data = r.ReadToEnd(); r.Close(); } if(_data.ToString() != "") { reward = (Reward)DeserializeObject(_data); } } void OnGUI() { GUI.Label(new Rect(0,0,Screen.width,Screen.height),"data:"+_data); if(Input.GetKey(KeyCode.Space)) { Application.Quit(); } } IEnumerator LoadWWW() { WWW www = new WWW(Application.streamingAssetsPath+"/Achievement.xml"); yield return www; _data =www.text; } public void Save() { _data = SerializeObject(reward); StreamWriter writer; fileInfo.Delete(); writer = fileInfo.CreateText(); writer.Write(_data); writer.Close(); } string UTF8ByteArrayToString(byte[] characters) { UTF8Encoding encoding = new UTF8Encoding(); string constructedString = encoding.GetString(characters); return (constructedString); } byte[] StringToUTF8ByteArray(string pXmlString) { UTF8Encoding encoding = new UTF8Encoding(); byte[] byteArray = encoding.GetBytes(pXmlString); return byteArray; } // Here we serialize our Reward object of reward string SerializeObject(object pObject) { string XmlizedString = null; MemoryStream memoryStream = new MemoryStream(); XmlSerializer xs = new XmlSerializer(typeof(Reward)); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); xs.Serialize(xmlTextWriter, pObject); memoryStream = (MemoryStream)xmlTextWriter.BaseStream; XmlizedString = UTF8ByteArrayToString(memoryStream.ToArray()); return XmlizedString; } // Here we deserialize it back into its original form object DeserializeObject(string pXmlizedString) { XmlSerializer xs = new XmlSerializer(typeof(Reward)); MemoryStream memoryStream = new MemoryStream(StringToUTF8ByteArray(pXmlizedString)); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); return xs.Deserialize(memoryStream); } }
注:其实每个平台的路径都可以是Application.streamingAssetsPath+"/Achievement.xml"。但是android平台必须要用WWW加载,其他的平台貌似也可以的,自己试试哈,呵呵~~~
SC8825/device/sprd/sp8825ea/base.mk
此文件可以配置system/app下面的apk,可以定制:
PRODUCT_PROPERTY_OVERRIDES := PRODUCT_PACKAGES := \ libjni_pinyinime \ Camera \ DeskClock \ AlarmProvider \ Bluetooth \ Calculator \ Calendar \ CertInstaller \ DrmProvider \ Email \ Exchange \ Gallery2 \ LatinIME \ Music \ MusicFX \ Provision \ QuickSearchBox \ Sync \ SystemUI \ Updater \ CalendarProvider \ SyncProvider \ bluetooth-health \ hostapd \ wpa_supplicant.conf \ hciconfig \ hcitool \ hcidump