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

2.x #1

Open
wants to merge 43 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e8100dc
yang compiler
airlenet Aug 6, 2020
5d00778
TypeDef Type List 支持JNC 转换
airlenet Aug 8, 2020
78ff31a
yang jnc translator
airlenet Aug 11, 2020
b2507f0
add javadoc custom gen packageName
airlenet Aug 12, 2020
2c71348
update readme
airlenet Aug 12, 2020
83e3a4d
update yang-java
airlenet Aug 13, 2020
5cab110
update yang-jnc add YangAnyXml etc
airlenet Aug 15, 2020
c588d18
remove gen *.ser and Temp
airlenet Aug 15, 2020
fff08de
add Action TailfAction
airlenet Nov 27, 2020
492c50f
update list augment
airlenet Nov 28, 2020
ae7f53c
update list augment
airlenet Nov 28, 2020
796af54
a
airlenet Nov 28, 2020
df21ee7
augment statment
airlenet Nov 28, 2020
9d51641
update augment childrenname
airlenet Nov 28, 2020
07e34f0
rename jnc method
airlenet Nov 30, 2020
5439fde
import 优化
airlenet Nov 30, 2020
d05a09e
update enum class add static final string
airlenet Nov 30, 2020
5c83bcc
枚举类增加field常量
airlenet Dec 24, 2020
cf3fcda
Windows环境适配,支持Windows系统运行
airlenet Dec 24, 2020
d5ee9a3
生成代码修改,增加augment 等
airlenet Dec 26, 2020
6c3b4d6
prefix bugfix
airlenet Dec 26, 2020
ce5edcb
leaf节点顺序fix
airlenet Dec 28, 2020
be76d4a
修改tailfAction转换
airlenet Dec 29, 2020
682a421
增加yang版本管理,input、output节点leaf生成
airlenet Jan 11, 2021
f340775
支持rpc生成
airlenet Jan 11, 2021
7f2cfa9
yang模型,支持 module区分
airlenet Jan 15, 2021
c12c636
update Capabilities
airlenet Jan 16, 2021
7a739e7
update add tailf
airlenet Jan 29, 2021
313f0fe
fix range ''
airlenet Jan 29, 2021
92ada23
update tailf action
airlenet Feb 2, 2021
bf14ed2
update add yang.module generator
airlenet Feb 25, 2021
8e06e20
update jnc
airlenet Mar 3, 2021
283b105
update 2.0.1-SNAPSHOT
airlenet Mar 26, 2021
83e0cd3
增加 PackageName etc
airlenet Apr 17, 2021
60aa2c0
增加 PackageName etc
airlenet Apr 17, 2021
adbc55d
增加 单会话 NS/LocalName-->Package映射
airlenet Apr 19, 2021
a6cf7e1
Enum add EnumValues
airlenet Apr 19, 2021
2def2a4
update assert and get***ToString
airlenet Apr 20, 2021
42f612a
update jnc
airlenet Apr 21, 2021
dc8c27e
fix
airlenet Apr 23, 2021
504c152
add xpath ns package
airlenet May 12, 2021
a209ee1
add uri
airlenet May 14, 2021
52434d1
update
airlenet May 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
117 changes: 117 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {

private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
4 changes: 4 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
distributionUrl=https://mirror.bit.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zip
#wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
wrapperUrl=https://repo.spring.io/libs-release/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
98 changes: 44 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# play-yang
Play Yang based on JNC,and a plugin for pyang to generate Java classes from YANG models.
# yang-java
Yang file is parsed by Java antlr4; Yang file is parsed by java code and JNC code is generated.
Its principle is based on JNC and onos-yang-tools


Reference
[JNC](https://github.com/tail-f-systems/JNC)
[pyang](https://github.com/mbj4668/pyang)
# play-jnc
[antlr](https://www.antlr.org/)
[onos-yang-tools](https://github.com/opennetworkinglab/onos-yang-tools)
# yang-jnc

Modify based on [JNC](https://github.com/tail-f-systems/JNC)

# yang-maven-plugin
Expand All @@ -20,10 +25,6 @@ Download [the latest JAR](https://search.maven.org/remote_content?g=com.airlenet
<version>LATEST</version>
</dependency>
```
or Gradle:
```groovy
compile 'com.airlenet.yang:yang-maven-plugin:LATEST'
```

Snapshots of the development version are available in [Sonatype's `snapshots` repository](https://oss.sonatype.org/content/repositories/snapshots/com/airlenet/yang/yang-maven-plugin).

Expand All @@ -37,68 +38,57 @@ Usage
<artifactId>yang-maven-plugin</artifactId>
<version>2.0.0-SNAPSHOT</version>
<configuration>
<skip>false</skip>
<showWarnings>false</showWarnings>
<errorAbort>false</errorAbort>
<excludes>
<exclude>tailf/*.yang</exclude>
<exclude>ietf/*.yang</exclude>
<exclude>iana/*.yang</exclude>
</excludes>
<yangFilesDir>src/main/yang</yangFilesDir>
<packageName>com.test.yang.model.gen</packageName>
<classFileDir>src/main/java</classFileDir>
</configuration>
<executions>
<execution>
<id>process</id>
<id>default</id>
<goals>
<goal>process</goal>
<goal>yang2java</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory><!-- src/main/java -->
<packageName>com.airlenet.yang.model</packageName>
</configuration>
</execution>
</executions>
</plugin>
<!-- add source resource: java class & resource -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>target/generated-sources/java</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>target/generated-sources/java</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
```
```
mvn package # generator java class from yang model,compile,package

mvn yang:validate # validate yang model
```
[yang-example](https://github.com/airshiplay/play-yang/tree/master/yang-example)

Expand Down
Loading